Have get_quoted_relname(), get_quoted_nspname(), and reorg_drop() sanity check arguments to prevent NULL pointer dereferencing and backend crash.

Fix for Issue #20.
This commit is contained in:
Josh Kupershmidt 2012-11-11 15:24:38 -05:00 committed by Daniele Varrazzo
parent 7b84eeb010
commit 95c196dd33

View File

@ -797,6 +797,12 @@ repack_drop(PG_FUNCTION_ARGS)
const char *relname = get_quoted_relname(oid);
const char *nspname = get_quoted_nspname(oid);
if (!(relname && nspname))
{
elog(ERROR, "table name not found for OID %u", oid);
PG_RETURN_VOID();
}
/* authority check */
must_be_superuser("repack_drop");
@ -895,13 +901,15 @@ repack_prepare(const char *src, int nargs, Oid *argtypes)
static const char *
get_quoted_relname(Oid oid)
{
return quote_identifier(get_rel_name(oid));
const char *relname = get_rel_name(oid);
return (relname ? quote_identifier(relname) : NULL);
}
static const char *
get_quoted_nspname(Oid oid)
{
return quote_identifier(get_namespace_name(get_rel_namespace(oid)));
const char *nspname = get_namespace_name(get_rel_namespace(oid));
return (nspname ? quote_identifier(nspname) : NULL);
}
/*