Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3ace845

Browse files
committed
Defend against omitted paramLengths[] array in PQsendQueryParams.
Per Volkan Yazici.
1 parent 0b8e46e commit 3ace845

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/interfaces/libpq/fe-exec.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.167 2005/04/29 13:42:21 momjian Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.168 2005/06/09 20:01:16 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -30,7 +30,7 @@
3030
#endif
3131

3232
/* keep this in same order as ExecStatusType in libpq-fe.h */
33-
char *const pgresStatus[] = {
33+
char *const pgresStatus[] = {
3434
"PGRES_EMPTY_QUERY",
3535
"PGRES_COMMAND_OK",
3636
"PGRES_TUPLES_OK",
@@ -960,7 +960,14 @@ PQsendQueryGuts(PGconn *conn,
960960
if (paramFormats && paramFormats[i] != 0)
961961
{
962962
/* binary parameter */
963-
nbytes = paramLengths[i];
963+
if (paramLengths)
964+
nbytes = paramLengths[i];
965+
else
966+
{
967+
printfPQExpBuffer(&conn->errorMessage,
968+
libpq_gettext("length must be given for binary parameter\n"));
969+
goto sendFailed;
970+
}
964971
}
965972
else
966973
{

src/interfaces/libpq/libpq-fe.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.116 2004/12/31 22:03:50 pgsql Exp $
10+
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.117 2005/06/09 20:01:16 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -156,7 +156,7 @@ typedef struct _PQprintOpt
156156
char *fieldSep; /* field separator */
157157
char *tableOpt; /* insert to HTML <table ...> */
158158
char *caption; /* HTML <caption> */
159-
char **fieldName; /* null terminated array of repalcement
159+
char **fieldName; /* null terminated array of replacement
160160
* field names */
161161
} PQprintOpt;
162162

0 commit comments

Comments
 (0)