aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-06-09 20:01:16 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-06-09 20:01:16 +0000
commit3ace84594e3626f12caddfe3a2efed1a2e2982ee (patch)
tree314ee8ba8ea0c80166533904bf456cd9ccf9ac31 /src
parent0b8e46e49b6236b64744659afe43a74c46042951 (diff)
downloadpostgresql-3ace84594e3626f12caddfe3a2efed1a2e2982ee.tar.gz
postgresql-3ace84594e3626f12caddfe3a2efed1a2e2982ee.zip
Defend against omitted paramLengths[] array in PQsendQueryParams.
Per Volkan Yazici.
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/libpq/fe-exec.c13
-rw-r--r--src/interfaces/libpq/libpq-fe.h4
2 files changed, 12 insertions, 5 deletions
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index a8ef01ad0da..1a01a4c627c 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.167 2005/04/29 13:42:21 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.168 2005/06/09 20:01:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -30,7 +30,7 @@
#endif
/* keep this in same order as ExecStatusType in libpq-fe.h */
-char *const pgresStatus[] = {
+char *const pgresStatus[] = {
"PGRES_EMPTY_QUERY",
"PGRES_COMMAND_OK",
"PGRES_TUPLES_OK",
@@ -960,7 +960,14 @@ PQsendQueryGuts(PGconn *conn,
if (paramFormats && paramFormats[i] != 0)
{
/* binary parameter */
- nbytes = paramLengths[i];
+ if (paramLengths)
+ nbytes = paramLengths[i];
+ else
+ {
+ printfPQExpBuffer(&conn->errorMessage,
+ libpq_gettext("length must be given for binary parameter\n"));
+ goto sendFailed;
+ }
}
else
{
diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h
index f7f379748b4..8976d45e258 100644
--- a/src/interfaces/libpq/libpq-fe.h
+++ b/src/interfaces/libpq/libpq-fe.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.116 2004/12/31 22:03:50 pgsql Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.117 2005/06/09 20:01:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -156,7 +156,7 @@ typedef struct _PQprintOpt
char *fieldSep; /* field separator */
char *tableOpt; /* insert to HTML <table ...> */
char *caption; /* HTML <caption> */
- char **fieldName; /* null terminated array of repalcement
+ char **fieldName; /* null terminated array of replacement
* field names */
} PQprintOpt;