Skip to content

Commit 95c196d

Browse files
schmiddydvarrazzo
authored andcommitted
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.
1 parent 7b84eeb commit 95c196d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/repack.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,12 @@ repack_drop(PG_FUNCTION_ARGS)
797797
const char *relname = get_quoted_relname(oid);
798798
const char *nspname = get_quoted_nspname(oid);
799799

800+
if (!(relname && nspname))
801+
{
802+
elog(ERROR, "table name not found for OID %u", oid);
803+
PG_RETURN_VOID();
804+
}
805+
800806
/* authority check */
801807
must_be_superuser("repack_drop");
802808

@@ -895,13 +901,15 @@ repack_prepare(const char *src, int nargs, Oid *argtypes)
895901
static const char *
896902
get_quoted_relname(Oid oid)
897903
{
898-
return quote_identifier(get_rel_name(oid));
904+
const char *relname = get_rel_name(oid);
905+
return (relname ? quote_identifier(relname) : NULL);
899906
}
900907

901908
static const char *
902909
get_quoted_nspname(Oid oid)
903910
{
904-
return quote_identifier(get_namespace_name(get_rel_namespace(oid)));
911+
const char *nspname = get_namespace_name(get_rel_namespace(oid));
912+
return (nspname ? quote_identifier(nspname) : NULL);
905913
}
906914

907915
/*

0 commit comments

Comments
 (0)