Skip to content

Commit 4f33f5b

Browse files
committed
Fix possible segfault in collection_unpack
When var->value_len somehow becomes 0, we risk wrapping around to 4294967295 due to it being an unsigned int. Fixes #3082
1 parent fa48de0 commit 4f33f5b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

apache2/persist_dbm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ static apr_table_t *collection_unpack(modsec_rec *msr, const unsigned char *blob
5959
}
6060

6161
blob_offset += 2;
62-
if (blob_offset + var->name_len > blob_size) return NULL;
62+
if (var->name_len < 1 || blob_offset + var->name_len > blob_size) return NULL;
6363
var->name = apr_pstrmemdup(msr->mp, (const char *)blob + blob_offset, var->name_len - 1);
6464
blob_offset += var->name_len;
6565
var->name_len--;
6666

6767
var->value_len = (blob[blob_offset] << 8) + blob[blob_offset + 1];
6868
blob_offset += 2;
6969

70-
if (blob_offset + var->value_len > blob_size) return NULL;
70+
if (var->value_len < 1 || blob_offset + var->value_len > blob_size) return NULL;
7171
var->value = apr_pstrmemdup(msr->mp, (const char *)blob + blob_offset, var->value_len - 1);
7272
blob_offset += var->value_len;
7373
var->value_len--;

0 commit comments

Comments
 (0)