This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
(perl #132147) don't cache invalid pages
authorTony Cook <tony@develop-help.com>
Tue, 6 Nov 2018 03:23:48 +0000 (14:23 +1100)
committerTony Cook <tony@develop-help.com>
Mon, 19 Nov 2018 00:27:33 +0000 (11:27 +1100)
commit36a4593dbe09b6c81f17ce4f7388de3c53b890ac
treefdbf509d0e24f085705fd768f31326e0c212173f
parent7f4a9bc72716574716b99e45c11129541a8fbeb7
(perl #132147) don't cache invalid pages

When sdbm loads its page buffer from disk, in most cases it validates
the page and doesn't continue processing if it fails validation.

Unfortunately, in a few places it still marked the buffer as loaded
from that page, and later calls would then use that cached page,
causing a variety of problems, including buffer read overflows.

sdbm_firstkey() didn't validate the loaded page at all, it now does.

All places that validate the loaded page now on a failed validation:
  - invalidate the cached page (set pagbno to -1)
  - set the I/O error flag on the database object
  - set errno ($!) to EINVAL

The first ensures that later calls don't end up using an invalid cached
page.

The others allow the caller to check whether an error has occurred.
ext/SDBM_File/sdbm.c