summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/common.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-01-16 03:54:58 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-01-16 03:54:58 +0000
commit97e82dc72c0cabf72bcfe760073995b89d4a73d6 (patch)
treee727d78af96f4e2840654bb922ab9946182d6d4c /src/bin/pg_dump/common.c
parent255e07e829f07a6d7acbd58e0513de3ae20ef0a5 (diff)
downloadpostgresql-97e82dc72c0cabf72bcfe760073995b89d4a73d6.tar.gz
Clean up pg_dump coredumps caused by change of output formatting for
oidvector/int2vector. pg_dump code was assuming that it would see exactly FUNC_MAX_ARGS integers in the string returned by the backend. That's no longer true. (Perhaps that change wasn't such a good idea after all --- will it break any other applications??)
Diffstat (limited to 'src/bin/pg_dump/common.c')
-rw-r--r--src/bin/pg_dump/common.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c
index 299943f485..9089062c58 100644
--- a/src/bin/pg_dump/common.c
+++ b/src/bin/pg_dump/common.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.36 1999/12/27 15:42:43 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.37 2000/01/16 03:54:58 tgl Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
@@ -156,13 +156,12 @@ findParentsByOid(TableInfo *tblinfo, int numTables,
}
/*
- * parseArgTypes
- * parse a string of eight numbers delimited by spaces
- * into a character array
+ * parseNumericArray
+ * parse a string of numbers delimited by spaces into a character array
*/
void
-parseArgTypes(char **argtypes, const char *str)
+parseNumericArray(const char *str, char **array, int arraysize)
{
int j,
argNum;
@@ -171,28 +170,37 @@ parseArgTypes(char **argtypes, const char *str)
argNum = 0;
j = 0;
- while ((s = *str) != '\0')
+ for (;;)
{
- if (s == ' ')
+ s = *str++;
+ if (s == ' ' || s == '\0')
{
- temp[j] = '\0';
- argtypes[argNum] = strdup(temp);
- argNum++;
- j = 0;
+ if (j > 0)
+ {
+ if (argNum >= arraysize)
+ {
+ fprintf(stderr, "parseNumericArray: too many numbers\n");
+ exit(2);
+ }
+ temp[j] = '\0';
+ array[argNum++] = strdup(temp);
+ j = 0;
+ }
+ if (s == '\0')
+ break;
}
else
{
- temp[j] = s;
- j++;
+ if (!isdigit(s) || j >= sizeof(temp)-1)
+ {
+ fprintf(stderr, "parseNumericArray: bogus number\n");
+ exit(2);
+ }
+ temp[j++] = s;
}
- str++;
}
- if (j != 0)
- {
- temp[j] = '\0';
- argtypes[argNum] = strdup(temp);
- }
-
+ while (argNum < arraysize)
+ array[argNum++] = strdup("0");
}