when creating the database zero the reserved space
authorAndrew Tridgell <tridge@samba.org>
Wed, 10 May 2000 12:58:20 +0000 (12:58 +0000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 10 May 2000 12:58:20 +0000 (12:58 +0000)
source/tdb/tdb.c

index 35951a0d174a36c4ff7cb923ebea854d6a44971d..bc7c90613c1b417e90e38a8578e1b30ad65be5da 100644 (file)
@@ -498,6 +498,7 @@ static int tdb_new_database(TDB_CONTEXT *tdb, int hash_size)
        tdb_off offset;
        int i, size = 0;
        tdb_off buf[16];
+       char buf2[TDB_RESERVED];
 
         /* create the header */
         memset(&header, 0, sizeof(header));
@@ -514,6 +515,13 @@ static int tdb_new_database(TDB_CONTEXT *tdb, int hash_size)
             tdb->ecode = TDB_ERR_IO;
             return -1;
         } else size += sizeof(header);
+
+       memset(buf2, 0, sizeof(buf2));
+        if (tdb->fd != -1 && write(tdb->fd, buf2, TDB_RESERVED) != 
+            TDB_RESERVED) {
+            tdb->ecode = TDB_ERR_IO;
+            return -1;
+        } else size += TDB_RESERVED;
        
         /* the freelist and hash pointers */
         offset = 0;