git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 28f84f7)
Prevent overflow for block number in buffile.c
2023年11月20日 00:14:53 +0000 (09:14 +0900)
2023年11月20日 00:14:53 +0000 (09:14 +0900)
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.


diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c
index 2ca37832331c49d5fcd2c8b4a77b0f03db0e26c9..73e9aca9d215fc72dc7329aa0ddd7fc079e00e32 100644 (file)
--- 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;
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /