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

Commit152133b

Browse files
committed
Add some comments about the safety of accessing rolpassword without using
the normal heap_getattr() machinery. Per Greg Stark.
1 parent8be9b50 commit152133b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

‎src/backend/utils/init/flatfiles.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
2424
* Portions Copyright (c) 1994, Regents of the University of California
2525
*
26-
* $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.25 2007/04/06 04:21:43 tgl Exp $
26+
* $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.26 2007/06/12 17:16:52 tgl Exp $
2727
*
2828
*-------------------------------------------------------------------------
2929
*/
@@ -441,7 +441,10 @@ write_auth_file(Relation rel_authid, Relation rel_authmem)
441441
* We can't use heap_getattr() here because during startup we will not
442442
* have any tupdesc for pg_authid.Fortunately it's not too hard to
443443
* work around this. rolpassword is the first possibly-null field so
444-
* we can compute its offset directly.
444+
* we can compute its offset directly. Note that this only works
445+
* reliably because the preceding field (rolconnlimit) is int4, and
446+
* therefore rolpassword is always 4-byte-aligned, and will be at
447+
* the same offset no matter whether it uses 1-byte or 4-byte header.
445448
*/
446449
tp= (char*)tup+tup->t_hoff;
447450
off= offsetof(FormData_pg_authid,rolpassword);
@@ -460,6 +463,10 @@ write_auth_file(Relation rel_authid, Relation rel_authmem)
460463
/*
461464
* The password probably shouldn't ever be out-of-line toasted; if
462465
* it is, ignore it, since we can't handle that in startup mode.
466+
*
467+
* It is entirely likely that it's 1-byte format not 4-byte, and
468+
* theoretically possible that it's compressed inline, but textout
469+
* should be able to handle those cases even in startup mode.
463470
*/
464471
if (VARATT_IS_EXTERNAL(DatumGetPointer(datum)))
465472
auth_info[curr_role].rolpassword=pstrdup("");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp