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

Commit97e82dc

Browse files
committed
Clean up pg_dump coredumps caused by change of output formatting for
oidvector/int2vector. pg_dump code was assuming that it would seeexactly FUNC_MAX_ARGS integers in the string returned by the backend.That's no longer true. (Perhaps that change wasn't such a good ideaafter all --- will it break any other applications??)
1 parent255e07e commit97e82dc

File tree

3 files changed

+53
-43
lines changed

3 files changed

+53
-43
lines changed

‎src/bin/pg_dump/common.c

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.36 1999/12/27 15:42:43 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.37 2000/01/16 03:54:58 tgl Exp $
1111
*
1212
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
1313
*
@@ -156,13 +156,12 @@ findParentsByOid(TableInfo *tblinfo, int numTables,
156156
}
157157

158158
/*
159-
* parseArgTypes
160-
* parse a string of eight numbers delimited by spaces
161-
* into a character array
159+
* parseNumericArray
160+
* parse a string of numbers delimited by spaces into a character array
162161
*/
163162

164163
void
165-
parseArgTypes(char**argtypes,constchar*str)
164+
parseNumericArray(constchar*str,char**array,intarraysize)
166165
{
167166
intj,
168167
argNum;
@@ -171,28 +170,37 @@ parseArgTypes(char **argtypes, const char *str)
171170

172171
argNum=0;
173172
j=0;
174-
while ((s=*str)!='\0')
173+
for (;;)
175174
{
176-
if (s==' ')
175+
s=*str++;
176+
if (s==' '||s=='\0')
177177
{
178-
temp[j]='\0';
179-
argtypes[argNum]=strdup(temp);
180-
argNum++;
181-
j=0;
178+
if (j>0)
179+
{
180+
if (argNum >=arraysize)
181+
{
182+
fprintf(stderr,"parseNumericArray: too many numbers\n");
183+
exit(2);
184+
}
185+
temp[j]='\0';
186+
array[argNum++]=strdup(temp);
187+
j=0;
188+
}
189+
if (s=='\0')
190+
break;
182191
}
183192
else
184193
{
185-
temp[j]=s;
186-
j++;
194+
if (!isdigit(s)||j >=sizeof(temp)-1)
195+
{
196+
fprintf(stderr,"parseNumericArray: bogus number\n");
197+
exit(2);
198+
}
199+
temp[j++]=s;
187200
}
188-
str++;
189201
}
190-
if (j!=0)
191-
{
192-
temp[j]='\0';
193-
argtypes[argNum]=strdup(temp);
194-
}
195-
202+
while (argNum<arraysize)
203+
array[argNum++]=strdup("0");
196204
}
197205

198206

‎src/bin/pg_dump/pg_dump.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
*
2323
* IDENTIFICATION
24-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.131 2000/01/10 17:14:40 momjian Exp $
24+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.132 2000/01/16 03:54:58 tgl Exp $
2525
*
2626
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
2727
*
@@ -1387,6 +1387,8 @@ getFuncs(int *numFuncs)
13871387

13881388
finfo= (FuncInfo*)malloc(ntups*sizeof(FuncInfo));
13891389

1390+
memset((char*)finfo,0,ntups*sizeof(FuncInfo));
1391+
13901392
i_oid=PQfnumber(res,"oid");
13911393
i_proname=PQfnumber(res,"proname");
13921394
i_prolang=PQfnumber(res,"prolang");
@@ -1410,11 +1412,16 @@ getFuncs(int *numFuncs)
14101412
finfo[i].retset= (strcmp(PQgetvalue(res,i,i_proretset),"t")==0);
14111413
finfo[i].nargs=atoi(PQgetvalue(res,i,i_pronargs));
14121414
finfo[i].lang=atoi(PQgetvalue(res,i,i_prolang));
1413-
14141415
finfo[i].usename=strdup(PQgetvalue(res,i,i_usename));
1415-
1416-
parseArgTypes(finfo[i].argtypes,PQgetvalue(res,i,i_proargtypes));
1417-
1416+
if (finfo[i].nargs<0||finfo[i].nargs>FUNC_MAX_ARGS)
1417+
{
1418+
fprintf(stderr,"failed sanity check: %s has %d args\n",
1419+
finfo[i].proname,finfo[i].nargs);
1420+
exit(2);
1421+
}
1422+
parseNumericArray(PQgetvalue(res,i,i_proargtypes),
1423+
finfo[i].argtypes,
1424+
finfo[i].nargs);
14181425
finfo[i].dumped=0;
14191426
}
14201427

@@ -2045,6 +2052,8 @@ getIndices(int *numIndices)
20452052

20462053
indinfo= (IndInfo*)malloc(ntups*sizeof(IndInfo));
20472054

2055+
memset((char*)indinfo,0,ntups*sizeof(IndInfo));
2056+
20482057
i_indexrelname=PQfnumber(res,"indexrelname");
20492058
i_indrelname=PQfnumber(res,"indrelname");
20502059
i_indamname=PQfnumber(res,"indamname");
@@ -2059,10 +2068,12 @@ getIndices(int *numIndices)
20592068
indinfo[i].indrelname=strdup(PQgetvalue(res,i,i_indrelname));
20602069
indinfo[i].indamname=strdup(PQgetvalue(res,i,i_indamname));
20612070
indinfo[i].indproc=strdup(PQgetvalue(res,i,i_indproc));
2062-
parseArgTypes((char**)indinfo[i].indkey,
2063-
(constchar*)PQgetvalue(res,i,i_indkey));
2064-
parseArgTypes((char**)indinfo[i].indclass,
2065-
(constchar*)PQgetvalue(res,i,i_indclass));
2071+
parseNumericArray(PQgetvalue(res,i,i_indkey),
2072+
indinfo[i].indkey,
2073+
INDEX_MAX_KEYS);
2074+
parseNumericArray(PQgetvalue(res,i,i_indclass),
2075+
indinfo[i].indclass,
2076+
INDEX_MAX_KEYS);
20662077
indinfo[i].indisunique=strdup(PQgetvalue(res,i,i_indisunique));
20672078
}
20682079
PQclear(res);

‎src/bin/pg_dump/pg_dump.h

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 1994, Regents of the University of California
77
*
8-
* $Id: pg_dump.h,v 1.44 2000/01/10 17:14:40 momjian Exp $
8+
* $Id: pg_dump.h,v 1.45 2000/01/16 03:54:58 tgl Exp $
99
*
1010
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
1111
*
@@ -25,14 +25,7 @@
2525
#include"pqexpbuffer.h"
2626
#include"catalog/pg_index.h"
2727

28-
/*
29-
* Very temporary hack --- remove this when all pg_dump's uses of it are gone!
30-
*/
31-
#defineMAX_QUERY_SIZE(BLCKSZ*2)
32-
33-
34-
/* The *Info data structures run-time C structures used to store
35-
system catalog information */
28+
/* The data structures used to store system catalog information */
3629

3730
typedefstruct_typeInfo
3831
{
@@ -61,11 +54,9 @@ typedef struct _funcInfo
6154
char*proowner;
6255
intlang;
6356
intnargs;
64-
char*argtypes[FUNC_MAX_ARGS];/* should be derived from obj/fmgr.h
65-
* instead of hardwired */
57+
char*argtypes[FUNC_MAX_ARGS];
6658
char*prorettype;
67-
intretset;/* 1 if the function returns a set, 0
68-
* otherwise */
59+
intretset;/* 1 if the function returns a set, else 0 */
6960
char*prosrc;
7061
char*probin;
7162
char*usename;
@@ -198,7 +189,7 @@ extern intfindFuncByName(FuncInfo *finfo, int numFuncs, const char *name);
198189
externintfindTableByName(TableInfo*tbinfo,intnumTables,constchar*relname);
199190

200191
externvoidcheck_conn_and_db(void);
201-
externvoidparseArgTypes(char**argtypes,constchar*str);
192+
externvoidparseNumericArray(constchar*str,char**array,intarraysize);
202193

203194
/*
204195
* version specific routines

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp