diff options
author | Keith Bostic <keith@wiredtiger.com> | 2016-03-11 11:04:45 -0500 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2016-03-11 11:04:45 -0500 |
commit | c0dbe962eb38220c50a0b2ea290e4c69a66b6cee (patch) | |
tree | 1345ef330fda1629c24b08cc6e7785132777b269 /test/recovery/truncated-log.c | |
parent | d1a59d8d5342fcaaa194a31a60ca6c4c9c55ba43 (diff) | |
download | mongo-c0dbe962eb38220c50a0b2ea290e4c69a66b6cee.tar.gz |
WT-2469: Coverity 1352897: Integer overflowed argument
Don't overflow the file offset.
Don't use %u to print PRIu64 and PRIu32 types.
Diffstat (limited to 'test/recovery/truncated-log.c')
-rw-r--r-- | test/recovery/truncated-log.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/test/recovery/truncated-log.c b/test/recovery/truncated-log.c index 23269e99d35..4dd7db2b984 100644 --- a/test/recovery/truncated-log.c +++ b/test/recovery/truncated-log.c @@ -243,8 +243,10 @@ main(int argc, char *argv[]) * The offset is the beginning of the last record. Truncate to * the middle of that last record (i.e. ahead of that offset). */ + if (offset > UINT64_MAX - V_SIZE) + testutil_die(ERANGE, "offset"); new_offset = offset + V_SIZE; - printf("Parent: Truncate to %u\n", (uint32_t)new_offset); + printf("Parent: Truncate to %" PRIu64 "\n", new_offset); if ((ret = truncate(LOG_FILE_1, (wt_off_t)new_offset)) != 0) testutil_die(errno, "truncate"); @@ -267,9 +269,10 @@ main(int argc, char *argv[]) if ((ret = conn->close(conn, NULL)) != 0) testutil_die(ret, "WT_CONNECTION:close"); if (count > max_key) { - printf("expected %u records found %u\n", max_key, count); + printf("expected %" PRIu32 " records found %" PRIu32 "\n", + max_key, count); return (EXIT_FAILURE); } - printf("%u records verified\n", count); + printf("%" PRIu32 " records verified\n", count); return (EXIT_SUCCESS); } |