Skip to content

Commit cf22e85

Browse files
committed
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
1 parent 409b8c7 commit cf22e85

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,10 @@ main(int argc, char **argv)
645645
do_sql_command(g_conn, "SET quote_all_identifiers = true");
646646

647647
/*
648-
* Disables security label support if server version < v9.1.x
648+
* Disable security label support if server version < v9.1.x (prevents
649+
* access to nonexistent pg_seclabel catalog)
649650
*/
650-
if (!no_security_labels && g_fout->remoteVersion < 90100)
651+
if (g_fout->remoteVersion < 90100)
651652
no_security_labels = 1;
652653

653654
/*
@@ -11993,6 +11994,12 @@ findSecLabels(Archive *fout, Oid classoid, Oid objoid, SecLabelItem **items)
1199311994
if (nlabels < 0)
1199411995
nlabels = collectSecLabels(fout, &labels);
1199511996

11997+
if (nlabels <= 0) /* no labels, so no match is possible */
11998+
{
11999+
*items = NULL;
12000+
return 0;
12001+
}
12002+
1199612003
/*
1199712004
* Do binary search to find some item matching the object.
1199812005
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy