Skip to content

Commit 80a96e0

Browse files
committed
Avoid fetching past the end of the indoption array.
pg_get_indexdef_worker carelessly fetched indoption entries even for non-key index columns that don't have one. 99.999% of the time this would be harmless, since the code wouldn't examine the value ... but some fine day this will be a fetch off the end of memory, resulting in SIGSEGV. Detected through valgrind testing. Odd that the buildfarm's valgrind critters haven't noticed.
1 parent 1c5d927 commit 80a96e0

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/backend/utils/adt/ruleutils.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,6 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
13081308
for (keyno = 0; keyno < idxrec->indnatts; keyno++)
13091309
{
13101310
AttrNumber attnum = idxrec->indkey.values[keyno];
1311-
int16 opt = indoption->values[keyno];
13121311
Oid keycoltype;
13131312
Oid keycolcollation;
13141313

@@ -1370,10 +1369,10 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
13701369
if (!attrsOnly && keyno < idxrec->indnkeyatts &&
13711370
(!colno || colno == keyno + 1))
13721371
{
1373-
Oid indcoll;
1372+
int16 opt = indoption->values[keyno];
1373+
Oid indcoll = indcollation->values[keyno];
13741374

13751375
/* Add collation, if not default for column */
1376-
indcoll = indcollation->values[keyno];
13771376
if (OidIsValid(indcoll) && indcoll != keycolcollation)
13781377
appendStringInfo(&buf, " COLLATE %s",
13791378
generate_collation_name((indcoll)));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy