Skip to content

Commit 6fc0d99

Browse files
michaelpqpull[bot]
authored andcommitted
Prevent overflow for block number in buffile.c
As coded, the start block calculated by BufFileAppend() would overflow once more than 16k files are used with a default block size. This issue existed before b1e5c9f, but there's no reason not to be clean about it. Per report from Coverity, with a fix suggested by Tom Lane.
1 parent 7321abe commit 6fc0d99

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/storage/file/buffile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ BufFileSize(BufFile *file)
904904
int64
905905
BufFileAppend(BufFile *target, BufFile *source)
906906
{
907-
int64 startBlock = target->numFiles * BUFFILE_SEG_SIZE;
907+
int64 startBlock = (int64) target->numFiles * BUFFILE_SEG_SIZE;
908908
int newNumFiles = target->numFiles + source->numFiles;
909909
int i;
910910

0 commit comments

Comments
 (0)