Skip to content

Commit a7ca25c

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 10e3991 commit a7ca25c

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
@@ -1305,7 +1305,6 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
13051305
for (keyno = 0; keyno < idxrec->indnatts; keyno++)
13061306
{
13071307
AttrNumber attnum = idxrec->indkey.values[keyno];
1308-
int16 opt = indoption->values[keyno];
13091308
Oid keycoltype;
13101309
Oid keycolcollation;
13111310

@@ -1367,10 +1366,10 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
13671366
if (!attrsOnly && keyno < idxrec->indnkeyatts &&
13681367
(!colno || colno == keyno + 1))
13691368
{
1370-
Oid indcoll;
1369+
int16 opt = indoption->values[keyno];
1370+
Oid indcoll = indcollation->values[keyno];
13711371

13721372
/* Add collation, if not default for column */
1373-
indcoll = indcollation->values[keyno];
13741373
if (OidIsValid(indcoll) && indcoll != keycolcollation)
13751374
appendStringInfo(&buf, " COLLATE %s",
13761375
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