Skip to content

Commit

Permalink
Be more careful about overflows
Browse files Browse the repository at this point in the history
  • Loading branch information
oschwald committed Jan 9, 2024
1 parent 0602d2e commit 5fd2c21
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/maxminddb.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ int MMDB_open(const char *const filename, uint32_t flags, MMDB_s *const mmdb) {

mmdb->data_section =
mmdb->file_content + search_tree_size + MMDB_DATA_SECTION_SEPARATOR;
if (search_tree_size + MMDB_DATA_SECTION_SEPARATOR > mmdb->file_size) {
if (mmdb->file_size < MMDB_DATA_SECTION_SEPARATOR ||
search_tree_size > mmdb->file_size - MMDB_DATA_SECTION_SEPARATOR) {
status = MMDB_INVALID_METADATA_ERROR;
goto cleanup;
}
Expand Down

0 comments on commit 5fd2c21

Please sign in to comment.