Skip to content

Commit 1096895

Browse files
committed
Fixed access to uninit'd mem in repack_indexdef
If the tablespace is the last token in the indexdef, skip_ident returns a pointer *after* the term zero, so garbage may end up after the statement.
1 parent 52e7761 commit 1096895

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/repack.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,12 +662,13 @@ repack_indexdef(PG_FUNCTION_ARGS)
662662
else
663663
{
664664
/* tablespace is to replace */
665-
char *tmp;
665+
char *tmp, *limit;
666+
limit = strchr(stmt.options, '\0');
666667
tmp = skip_const(index, stmt.options, " TABLESPACE", NULL);
667668
appendStringInfoString(&str, stmt.options);
668669
appendStringInfo(&str, " %s", NameStr(*tablespace));
669670
tmp = skip_ident(index, tmp);
670-
if (*tmp)
671+
if (tmp < limit)
671672
appendStringInfo(&str, " %s", tmp);
672673
}
673674
}

0 commit comments

Comments
 (0)