diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-04-07 18:18:58 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-04-07 18:19:16 -0400 |
commit | 80a96e066eecb6bd1788964b5911a405d932a784 (patch) | |
tree | ec025af2953d528eb5901e3989bd9359b7c59074 /src/backend/utils/adt/ruleutils.c | |
parent | 1c5d9270e339662cdd78d51d0b859d4f0a11aa91 (diff) | |
download | postgresql-80a96e066eecb6bd1788964b5911a405d932a784.tar.gz postgresql-80a96e066eecb6bd1788964b5911a405d932a784.zip |
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.
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 7b142e3b188..0c7a533e697 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -1308,7 +1308,6 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, for (keyno = 0; keyno < idxrec->indnatts; keyno++) { AttrNumber attnum = idxrec->indkey.values[keyno]; - int16 opt = indoption->values[keyno]; Oid keycoltype; Oid keycolcollation; @@ -1370,10 +1369,10 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, if (!attrsOnly && keyno < idxrec->indnkeyatts && (!colno || colno == keyno + 1)) { - Oid indcoll; + int16 opt = indoption->values[keyno]; + Oid indcoll = indcollation->values[keyno]; /* Add collation, if not default for column */ - indcoll = indcollation->values[keyno]; if (OidIsValid(indcoll) && indcoll != keycolcollation) appendStringInfo(&buf, " COLLATE %s", generate_collation_name((indcoll))); |