aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2023-08-30 08:03:54 +0900
committerMichael Paquier <michael@paquier.xyz>2023-08-30 08:03:54 +0900
commit420c8dc7ec67ca050d53c559d1e852c59e7053ef (patch)
tree811cd86fb03d37a40bff88de1b8f11721240be92
parenta01e479e84837cfdfae4a9b062b97ce1a261a96c (diff)
downloadpostgresql-420c8dc7ec67ca050d53c559d1e852c59e7053ef.tar.gz
postgresql-420c8dc7ec67ca050d53c559d1e852c59e7053ef.zip
Avoid possible overflow with ltsGetFreeBlock() in logtape.c
nFreeBlocks, defined as a long, stores the number of free blocks in a logical tape. ltsGetFreeBlock() has been using an int to store the value of nFreeBlocks, which could lead to overflows on platforms where long and int are not the same size (in short everything except Windows where long is 4 bytes). The problematic intermediate variable is switched to be a long instead of an int. Issue introduced by c02fdc9223015, so backpatch down to 13. Author: Ranier vilela Reviewed-by: Peter Geoghegan, David Rowley Discussion: https://postgr.es/m/CAEudQApLDWCBR_xmwNjGBrDo+f+S4E87x3s7-+hoaKqYdtC4JQ@mail.gmail.com Backpatch-through: 13
-rw-r--r--src/backend/utils/sort/logtape.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/utils/sort/logtape.c b/src/backend/utils/sort/logtape.c
index c6fcb87d744..720f9dfe2b7 100644
--- a/src/backend/utils/sort/logtape.c
+++ b/src/backend/utils/sort/logtape.c
@@ -389,7 +389,7 @@ ltsGetFreeBlock(LogicalTapeSet *lts)
{
long *heap = lts->freeBlocks;
long blocknum;
- int heapsize;
+ long heapsize;
unsigned long pos;
/* freelist empty; allocate a new block */