tdb: Add another overflow check to tdb_expand_adjust
authorVolker Lendecke <vl@samba.org>
Thu, 30 May 2013 14:23:17 +0000 (16:23 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 3 Jun 2013 12:08:53 +0000 (14:08 +0200)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Rusty Russell <rusty@rustcorp.com.au>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Jun  3 14:08:54 CEST 2013 on sn-devel-104

lib/tdb/common/io.c

index 87d47b970b0a239117c9d20903d8929837c7668a..11dfefd102b68cdb924680c5c0d94ebe8bf0d734 100644 (file)
@@ -405,6 +405,12 @@ tdb_off_t tdb_expand_adjust(tdb_off_t map_size, tdb_off_t size, int page_size)
 
        /* Round the database up to a multiple of the page size */
        new_size = MAX(top_size, new_size);
+
+       if (new_size + page_size < new_size) {
+               /* There's a "+" in TDB_ALIGN that might overflow... */
+               goto overflow;
+       }
+
        return TDB_ALIGN(new_size, page_size) - map_size;
 
 overflow: