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
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.