Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit939d10c

Browse files
committed
Guard against null arguments in binary_upgrade_create_empty_extension().
The CHECK_IS_BINARY_UPGRADE macro is not sufficient security protectionif we're going to dereference pass-by-reference arguments before it.But in any case we really need to explicitly check PG_ARGISNULL for allthe arguments of a non-strict function, not only the ones we expect nullvalues for.Oversight in commits30982be andf92fc4c. Found by Andreas Seltenreich.(The other usages in pg_upgrade_support.c seem safe.)
1 parentc6aeba3 commit939d10c

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

‎src/backend/utils/adt/pg_upgrade_support.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,28 @@ binary_upgrade_set_next_pg_authid_oid(PG_FUNCTION_ARGS)
129129
Datum
130130
binary_upgrade_create_empty_extension(PG_FUNCTION_ARGS)
131131
{
132-
text*extName=PG_GETARG_TEXT_PP(0);
133-
text*schemaName=PG_GETARG_TEXT_PP(1);
134-
boolrelocatable=PG_GETARG_BOOL(2);
135-
text*extVersion=PG_GETARG_TEXT_PP(3);
132+
text*extName;
133+
text*schemaName;
134+
boolrelocatable;
135+
text*extVersion;
136136
DatumextConfig;
137137
DatumextCondition;
138138
List*requiredExtensions;
139139

140140
CHECK_IS_BINARY_UPGRADE;
141141

142+
/* We must check these things before dereferencing the arguments */
143+
if (PG_ARGISNULL(0)||
144+
PG_ARGISNULL(1)||
145+
PG_ARGISNULL(2)||
146+
PG_ARGISNULL(3))
147+
elog(ERROR,"null argument to binary_upgrade_create_empty_extension is not allowed");
148+
149+
extName=PG_GETARG_TEXT_PP(0);
150+
schemaName=PG_GETARG_TEXT_PP(1);
151+
relocatable=PG_GETARG_BOOL(2);
152+
extVersion=PG_GETARG_TEXT_PP(3);
153+
142154
if (PG_ARGISNULL(4))
143155
extConfig=PointerGetDatum(NULL);
144156
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp