i32 overflow checking
authoradam <adamansky@gmail.com>
Wed, 24 Jul 2013 19:13:40 +0000 (02:13 +0700)
committeradam <adamansky@gmail.com>
Wed, 24 Jul 2013 19:13:40 +0000 (02:13 +0700)
in the wake of http://jira.incubaid.com/browse/ARAKOON-373

tcejdb/tcbmgr.c
tcejdb/tchdb.c

index 5530d27..d99fab0 100644 (file)
@@ -985,6 +985,10 @@ static int procimporttsv(const char *path, const char *file, int omode, bool sc)
         cnt++;
     }
     printf(" (%08d)\n", cnt);
+    if (!tcbdbsync(bdb)) {
+        printerr(bdb);
+        err = true;
+    }
     if (!tcbdbclose(bdb)) {
         if (!err) printerr(bdb);
         err = true;
index b0f6b0b..b4e2632 100644 (file)
@@ -2806,6 +2806,9 @@ static bool tchdbfbpsearch(TCHDB *hdb, TCHREC *rec) {
    The return value is whether splicing succeeded or not. */
 static bool tchdbfbpsplice(TCHDB *hdb, TCHREC *rec, uint32_t nsiz) {
     assert(hdb && rec && nsiz > 0);
+    if (nsiz > (0x80000000 - hdb->align)) {
+        return false;
+    }
     if (hdb->mmtx) {
         if (hdb->fbpnum < 1) {
             return false;