aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/file/buffile.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2023-11-20 09:14:53 +0900
committerMichael Paquier <michael@paquier.xyz>2023-11-20 09:14:53 +0900
commit3650e7a3933166b40f7f9043bd91f45d3467c74d (patch)
tree3f6fe6968c6678b0126d00ed4d509ac8ab368703 /src/backend/storage/file/buffile.c
parent28f84f72fbafe3bef675d3a176eb53177f4a9433 (diff)
downloadpostgresql-3650e7a3933166b40f7f9043bd91f45d3467c74d.tar.gz
postgresql-3650e7a3933166b40f7f9043bd91f45d3467c74d.zip
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 b1e5c9fa9ac4, but there's no reason not to be clean about it. Per report from Coverity, with a fix suggested by Tom Lane.
Diffstat (limited to 'src/backend/storage/file/buffile.c')
-rw-r--r--src/backend/storage/file/buffile.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c
index 2ca37832331..73e9aca9d21 100644
--- a/src/backend/storage/file/buffile.c
+++ b/src/backend/storage/file/buffile.c
@@ -904,7 +904,7 @@ BufFileSize(BufFile *file)
int64
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 i;