Skip to content

Commit

Permalink
Fix a integer overflow in btape.
Browse files Browse the repository at this point in the history
From now on you can use blocksize bigger then 230 Kb in btape as
it caculates the max-file-size as 10000 (number of records) times
the device blocksize but that will overflow a 32 bits integer so
explicitly cast it to 64 bits.
  • Loading branch information
Marco van Wieringen committed Feb 17, 2015
1 parent 9e3ca6b commit 44c7bf7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/stored/btape.c
Expand Up @@ -1144,10 +1144,11 @@ static bool write_two_files()
* doesn't insert any additional EOF marks
*/
if (dev->max_block_size) {
dev->max_file_size = 2 * num_recs * dev->max_block_size;
dev->max_file_size = (uint64_t)2 * (num_recs * dev->max_block_size);
} else {
dev->max_file_size = 2 * num_recs * DEFAULT_BLOCK_SIZE;
dev->max_file_size = 2 * (num_recs * DEFAULT_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"
Expand Down

0 comments on commit 44c7bf7

Please sign in to comment.