]> granicus.if.org Git - postgresql/commitdiff
Defend against omitted paramLengths[] array in PQsendQueryParams.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 9 Jun 2005 20:01:16 +0000 (20:01 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 9 Jun 2005 20:01:16 +0000 (20:01 +0000)
Per Volkan Yazici.

src/interfaces/libpq/fe-exec.c
src/interfaces/libpq/libpq-fe.h

index a8ef01ad0da32e4c4de8d6414cb73aba70514a32..1a01a4c627cab9617eaf9b95fea43b8bccdbc1b8 100644 (file)
@@ -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
                        {
index f7f379748b42cb069b5acfbab8c8de200351edc9..8976d45e2583a11385946928cbbbf397d48b1bad 100644 (file)
@@ -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;