Skip to content

Commit 832b6d0

Browse files
committed
Properly enforce pg_dump -F formation options; only single letter or
full words support, per report from Mark Stosberg.
1 parent 8f65c02 commit 832b6d0

File tree

1 file changed

+27
-32
lines changed

1 file changed

+27
-32
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.461 2007/03/19 23:38:30 wieck Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.462 2007/03/22 19:42:02 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -476,38 +476,33 @@ main(int argc, char **argv)
476476
}
477477

478478
/* open the output file */
479-
switch (format[0])
479+
if (strcasecmp(format, "a") == 0 || strcasecmp(format, "append") == 0)
480480
{
481-
case 'a':
482-
case 'A':
483-
plainText = 1;
484-
g_fout = CreateArchive(filename, archNull, 0, archModeAppend);
485-
break;
486-
487-
case 'c':
488-
case 'C':
489-
g_fout = CreateArchive(filename, archCustom, compressLevel, archModeWrite);
490-
break;
491-
492-
case 'f':
493-
case 'F':
494-
g_fout = CreateArchive(filename, archFiles, compressLevel, archModeWrite);
495-
break;
496-
497-
case 'p':
498-
case 'P':
499-
plainText = 1;
500-
g_fout = CreateArchive(filename, archNull, 0, archModeWrite);
501-
break;
502-
503-
case 't':
504-
case 'T':
505-
g_fout = CreateArchive(filename, archTar, compressLevel, archModeWrite);
506-
break;
507-
508-
default:
509-
write_msg(NULL, "invalid output format \"%s\" specified\n", format);
510-
exit(1);
481+
/* not documented */
482+
plainText = 1;
483+
g_fout = CreateArchive(filename, archNull, 0, archModeAppend);
484+
}
485+
else if (strcasecmp(format, "c") == 0 || strcasecmp(format, "custom") == 0)
486+
g_fout = CreateArchive(filename, archCustom, compressLevel, archModeWrite);
487+
else if (strcasecmp(format, "f") == 0 || strcasecmp(format, "file") == 0)
488+
{
489+
/*
490+
* Dump files into the current directory; for demonstration only, not
491+
* documented.
492+
*/
493+
g_fout = CreateArchive(filename, archFiles, compressLevel, archModeWrite);
494+
}
495+
else if (strcasecmp(format, "p") == 0 || strcasecmp(format, "plain") == 0)
496+
{
497+
plainText = 1;
498+
g_fout = CreateArchive(filename, archNull, 0, archModeWrite);
499+
}
500+
else if (strcasecmp(format, "t") == 0 || strcasecmp(format, "tar") == 0)
501+
g_fout = CreateArchive(filename, archTar, compressLevel, archModeWrite);
502+
else
503+
{
504+
write_msg(NULL, "invalid output format \"%s\" specified\n", format);
505+
exit(1);
511506
}
512507

513508
if (g_fout == NULL)

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