mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +03:00
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 b1e5c9fa9a
, but there's no reason not to be clean about
it.
Per report from Coverity, with a fix suggested by Tom Lane.
This commit is contained in:
@ -904,7 +904,7 @@ BufFileSize(BufFile *file)
|
|||||||
int64
|
int64
|
||||||
BufFileAppend(BufFile *target, BufFile *source)
|
BufFileAppend(BufFile *target, BufFile *source)
|
||||||
{
|
{
|
||||||
int64 startBlock = target->numFiles * BUFFILE_SEG_SIZE;
|
int64 startBlock = (int64) target->numFiles * BUFFILE_SEG_SIZE;
|
||||||
int newNumFiles = target->numFiles + source->numFiles;
|
int newNumFiles = target->numFiles + source->numFiles;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user