diff options
author | Tony Cook <tony@develop-help.com> | 2022-06-02 11:01:44 +1000 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2022-06-03 10:31:56 +1000 |
commit | 34e6e2fba776f00fec86643349436bb01ce33e85 (patch) | |
tree | 2f8af4f15bba42d22891d32149801c2738db79df /ext/GDBM_File | |
parent | a1f822c22a9381f509361dddb9844877f462e6a0 (diff) | |
download | perl-34e6e2fba776f00fec86643349436bb01ce33e85.tar.gz |
GDBM_File: fix fetching mmapsize
Originally this came up from a Coverity complaint.
GDBM_SETMAXMAPSIZE accepts any of unsigned, unsigned long or size_t,
but GDBM_GETMAXMAPSIZE only accepts size_t. Since this is the only
case that uses unsigned values we can safely switch it to size_t.
Unfortunately Coverity's analysis was pretty broken, it complained
about c_uv being uninitialised at the call to newSVuv, but its example
code flow went through the opt_dbname case, which sets vptr to != &c_uv
so the newSVuv() wouldn't execute anyway.
Before looking closely at the Coverity analysis and after finding the
bug fixed here I thought for a moment that Coverity had been tracing
into libgdbm, which could have caught the actual problem, but alas
that was not the case.
I expect this fix will not close CID 351943, and if it remains after
this is applied I'll close it as a false positive.
CID 351943.
Diffstat (limited to 'ext/GDBM_File')
-rw-r--r-- | ext/GDBM_File/GDBM_File.xs | 2 | ||||
-rw-r--r-- | ext/GDBM_File/t/opt.t | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/ext/GDBM_File/GDBM_File.xs b/ext/GDBM_File/GDBM_File.xs index c01fd28401..27e3fe44e4 100644 --- a/ext/GDBM_File/GDBM_File.xs +++ b/ext/GDBM_File/GDBM_File.xs @@ -878,7 +878,7 @@ gdbm_flags(db, ...) PREINIT: int opcode = -1; int c_iv; - unsigned c_uv; + size_t c_uv; char *c_cv; OPTVALPTR vptr = (OPTVALPTR) &c_iv; size_t vsiz = sizeof(c_iv); diff --git a/ext/GDBM_File/t/opt.t b/ext/GDBM_File/t/opt.t index 72390ac32e..9d45241e5d 100644 --- a/ext/GDBM_File/t/opt.t +++ b/ext/GDBM_File/t/opt.t @@ -14,7 +14,7 @@ BEGIN { plan(skip_all => "GDBM_File is flaky in $^O") if $^O =~ /darwin/; - plan(tests => 8); + plan(tests => 9); use_ok('GDBM_File'); } @@ -34,4 +34,9 @@ SKIP: { is($db->sync_mode, 0, 'get sync_mode'); is($db->sync_mode(1), 1, 'set sync_mode'); is($db->sync_mode, 1, 'get sync_mode'); + SKIP: { + my ($maj, $min) = GDBM_File->GDBM_version; + skip "gdbm too old", 1 if $maj != 1 || $maj == 1 && $min < 9; + isnt($db->mmapsize, 0, "get mmapsize"); + } } |