develooper Front page | perl.perl5.porters | Postings from July 2016

[perl #30807] Misleading error message from Storable

Thread Previous
Dan Collins via RT
July 7, 2016 03:26
[perl #30807] Misleading error message from Storable
Message ID:

     * The "magic number" is only for files, not when freezing in memory.

a is decimal 97 is ascii. The first two bytes are interpreted as major.minor version, but the first byte is first rightshifted - apparently the least significant bit is used to encode something else.

So, "aa" actually survives partway through magic_check(), when Storable discovers that 48.97 is much too high a version. "a" is the unusual case, because there isn't a second byte to read:

    if (version_major > 1)

And there is no character to be had, so it returns from magic_check without setting any other diagnostics.

In any event - there is no magic number that we can possibly check for thaw() from memory. The first two bytes are the version number. There are a number of different ways we can get weird error messages. So we should really just give a better error message in the cases that are most likely to be accidentally stumbled on.

I think that's the "version more recent" error as well as the "byte order not compatible" error (which you can get by passing in "\004\012\000xxxx"). Any other error message requires a crafted string like "\004\012\01012345678xxxx", which seems unlikely to happen by accident.

Will upload the patch momentarily.

via perlbug:  queue: perl5 status: open

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About