aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2023-08-30 08:03:48 +0900
committerMichael Paquier <michael@paquier.xyz>2023-08-30 08:03:48 +0900
commit1d2939b6dc638f9b9f9e747bec478cb1a7a459b6 (patch)
tree2f00d03c58526633970fa895861e7f857626d095 /src
parent39d4207e876fa55971cd20a7677b78f067971fd3 (diff)
downloadpostgresql-1d2939b6dc638f9b9f9e747bec478cb1a7a459b6.tar.gz
postgresql-1d2939b6dc638f9b9f9e747bec478cb1a7a459b6.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
Diffstat (limited to 'src')
-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 52b8898d5ed..f31878bdee1 100644
--- a/src/backend/utils/sort/logtape.c
+++ b/src/backend/utils/sort/logtape.c
@@ -372,7 +372,7 @@ ltsGetFreeBlock(LogicalTapeSet *lts)
{
long *heap = lts->freeBlocks;
long blocknum;
- int heapsize;
+ long heapsize;
long holeval;
unsigned long holepos;