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

[perl #30807] Misleading error message from Storable

Thread Previous
From:
Dan Collins via RT
Date:
July 7, 2016 03:26
Subject:
[perl #30807] Misleading error message from Storable
Message ID:
rt-4.0.18-1784-1467861984-1893.30807-15-0@perl.org
Storable.xs:

    /*
     * 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)
        GETMARK(version_minor);

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
https://rt.perl.org/Ticket/Display.html?id=30807

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About