Skip to content

Commit

Permalink
Merge pull request #376 from jwrdegoede/oss-fuzz-36187-null-ptr-deref…
Browse files Browse the repository at this point in the history
…-fix

Fix null-ptr deref when table->map_sz is 0
  • Loading branch information
evanmiller committed Jan 25, 2022
2 parents bcad261 + 4febc7b commit 2da65ff
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/libmdb/table.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ MdbTableDef *mdb_read_table(MdbCatalogEntry *entry)
mdb_free_tabledef(table);
return NULL;
}
/* First byte of usage_map is the map-type and must always be present */
if (table->map_sz < 1) {
fprintf(stderr, "mdb_read_table: invalid map-size: %zu\n", table->map_sz);
mdb_free_tabledef(table);
return NULL;
}
table->usage_map = g_memdup2((char*)buf + row_start, table->map_sz);
if (mdb_get_option(MDB_DEBUG_USAGE))
mdb_buffer_dump(buf, row_start, table->map_sz);
Expand Down

0 comments on commit 2da65ff

Please sign in to comment.