Skip to content

Commit 5fd2c21

Browse files
committed
Be more careful about overflows
1 parent 0602d2e commit 5fd2c21

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/maxminddb.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ int MMDB_open(const char *const filename, uint32_t flags, MMDB_s *const mmdb) {
301301

302302
mmdb->data_section =
303303
mmdb->file_content + search_tree_size + MMDB_DATA_SECTION_SEPARATOR;
304-
if (search_tree_size + MMDB_DATA_SECTION_SEPARATOR > mmdb->file_size) {
304+
if (mmdb->file_size < MMDB_DATA_SECTION_SEPARATOR ||
305+
search_tree_size > mmdb->file_size - MMDB_DATA_SECTION_SEPARATOR) {
305306
status = MMDB_INVALID_METADATA_ERROR;
306307
goto cleanup;
307308
}

0 commit comments

Comments
 (0)