]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix Bacula bug #2020 overflow in btape -- Andreas Koch
authorKern Sibbald <kern@sibbald.com>
Wed, 9 Apr 2014 16:56:59 +0000 (18:56 +0200)
committerKern Sibbald <kern@sibbald.com>
Wed, 9 Apr 2014 16:56:59 +0000 (18:56 +0200)
bacula/src/stored/btape.c

index 4082de27d903d37fdc68888bf74eaffb4b847d48..2b49fb99a3995a38a4a0d412217348cdb02fc840 100644 (file)
@@ -1117,8 +1117,9 @@ static bool write_two_files()
    /*
     * Set big max_file_size so that write_record_to_block
     * doesn't insert any additional EOF marks
+    * Do calculation in 64 bits to avoid overflow.  
     */
-   dev->max_file_size = 2 * num_recs * dev->max_block_size;
+   dev->max_file_size = (uint64_t)2 * (uint64_t)num_recs * (uint64_t)dev->max_block_size;
    Pmsg2(-1, _("\n=== Write, rewind, and re-read test ===\n\n"
       "I'm going to write %d records and an EOF\n"
       "then write %d records and an EOF, then rewind,\n"