mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Guard against null arguments in binary_upgrade_create_empty_extension().
The CHECK_IS_BINARY_UPGRADE macro is not sufficient security protection if we're going to dereference pass-by-reference arguments before it. But in any case we really need to explicitly check PG_ARGISNULL for all the arguments of a non-strict function, not only the ones we expect null values for. Oversight in commits30982be4e5
andf92fc4c95d
. Found by Andreas Seltenreich. (The other usages in pg_upgrade_support.c seem safe.)
This commit is contained in:
@ -129,16 +129,28 @@ binary_upgrade_set_next_pg_authid_oid(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
binary_upgrade_create_empty_extension(PG_FUNCTION_ARGS)
|
binary_upgrade_create_empty_extension(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
text *extName = PG_GETARG_TEXT_PP(0);
|
text *extName;
|
||||||
text *schemaName = PG_GETARG_TEXT_PP(1);
|
text *schemaName;
|
||||||
bool relocatable = PG_GETARG_BOOL(2);
|
bool relocatable;
|
||||||
text *extVersion = PG_GETARG_TEXT_PP(3);
|
text *extVersion;
|
||||||
Datum extConfig;
|
Datum extConfig;
|
||||||
Datum extCondition;
|
Datum extCondition;
|
||||||
List *requiredExtensions;
|
List *requiredExtensions;
|
||||||
|
|
||||||
CHECK_IS_BINARY_UPGRADE;
|
CHECK_IS_BINARY_UPGRADE;
|
||||||
|
|
||||||
|
/* We must check these things before dereferencing the arguments */
|
||||||
|
if (PG_ARGISNULL(0) ||
|
||||||
|
PG_ARGISNULL(1) ||
|
||||||
|
PG_ARGISNULL(2) ||
|
||||||
|
PG_ARGISNULL(3))
|
||||||
|
elog(ERROR, "null argument to binary_upgrade_create_empty_extension is not allowed");
|
||||||
|
|
||||||
|
extName = PG_GETARG_TEXT_PP(0);
|
||||||
|
schemaName = PG_GETARG_TEXT_PP(1);
|
||||||
|
relocatable = PG_GETARG_BOOL(2);
|
||||||
|
extVersion = PG_GETARG_TEXT_PP(3);
|
||||||
|
|
||||||
if (PG_ARGISNULL(4))
|
if (PG_ARGISNULL(4))
|
||||||
extConfig = PointerGetDatum(NULL);
|
extConfig = PointerGetDatum(NULL);
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user