diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-11-10 16:08:14 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-11-10 16:09:01 -0500 |
commit | cf22e851b6ae8737f3e767dffcadf1722fbb36a7 (patch) | |
tree | 28672f5691aa325398dd653d3b3df9498fa930cf /src/bin/pg_dump/pg_dump.c | |
parent | 409b8c75ba71fe6f3a7f9ccc094810966ef3a177 (diff) | |
download | postgresql-cf22e851b6ae8737f3e767dffcadf1722fbb36a7.tar.gz postgresql-cf22e851b6ae8737f3e767dffcadf1722fbb36a7.zip |
Avoid platform-dependent infinite loop in pg_dump.
If malloc(0) returns NULL, the binary search in findSecLabels() will
probably go into an infinite loop when there are no security labels,
because NULL-1 is greater than NULL after wraparound.
(We've seen this pathology before ... I wonder whether there's a way to
detect the class of bugs automatically?)
Diagnosis and patch by Steve Singer, cosmetic adjustments by me
Diffstat (limited to 'src/bin/pg_dump/pg_dump.c')
-rw-r--r-- | src/bin/pg_dump/pg_dump.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 88a867fe8e3..973f0b335d7 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -645,9 +645,10 @@ main(int argc, char **argv) do_sql_command(g_conn, "SET quote_all_identifiers = true"); /* - * Disables security label support if server version < v9.1.x + * Disable security label support if server version < v9.1.x (prevents + * access to nonexistent pg_seclabel catalog) */ - if (!no_security_labels && g_fout->remoteVersion < 90100) + if (g_fout->remoteVersion < 90100) no_security_labels = 1; /* @@ -11993,6 +11994,12 @@ findSecLabels(Archive *fout, Oid classoid, Oid objoid, SecLabelItem **items) if (nlabels < 0) nlabels = collectSecLabels(fout, &labels); + if (nlabels <= 0) /* no labels, so no match is possible */ + { + *items = NULL; + return 0; + } + /* * Do binary search to find some item matching the object. */ |