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

Commit5c06abb

Browse files
committed
Validate the OID argument of pg_import_system_collations().
"SELECT pg_import_system_collations(0)" caused an assertion failure.With a random nonzero argument --- or indeed with zero, in non-assertbuilds --- it would happily make pg_collation entries with garbagevalues of collnamespace. These are harmless as far as I can tell(unless maybe the OID happens to become used for a schema, later on?).In any case this isn't a security issue, since the function issuperuser-only. But it seems like a gotcha for unwary DBAs, so let'sadd a check that the given OID belongs to some schema.Back-patch to v10 where this function was introduced.
1 parent6c20bdb commit5c06abb

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

‎src/backend/commands/collationcmds.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,14 +407,16 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
407407
Oidnspid=PG_GETARG_OID(0);
408408
intncreated=0;
409409

410-
/* silence compiler warning if we have no locale implementation at all */
411-
(void)nspid;
412-
413410
if (!superuser())
414411
ereport(ERROR,
415412
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
416413
errmsg("must be superuser to import system collations")));
417414

415+
if (!SearchSysCacheExists1(NAMESPACEOID,ObjectIdGetDatum(nspid)))
416+
ereport(ERROR,
417+
(errcode(ERRCODE_UNDEFINED_SCHEMA),
418+
errmsg("schema with OID %u does not exist",nspid)));
419+
418420
/* Load collations known to libc, using "locale -a" to enumerate them */
419421
#ifdefREAD_LOCALE_A_OUTPUT
420422
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp