additionally check that size returned by Postgres matches
authorChristian Grothoff <christian@grothoff.org>
Mon, 15 Jan 2018 14:15:42 +0000 (15:15 +0100)
committerChristian Grothoff <christian@grothoff.org>
Mon, 15 Jan 2018 14:15:54 +0000 (15:15 +0100)
src/pq/pq_result_helper.c

index 045fe74b14e4cb3efe020e68d6c037d01db361e4..d9fed26a6abdfc4feabdef077b5702c609235b63 100644 (file)
@@ -100,8 +100,8 @@ extract_varsize_blob (void *cls,
   idst = GNUNET_malloc (len);
   *((void **) dst) = idst;
   GNUNET_memcpy (idst,
-         res,
-         len);
+                 res,
+                 len);
   return GNUNET_OK;
 }
 
@@ -165,7 +165,7 @@ extract_fixed_blob (void *cls,
   {
     GNUNET_break (0);
     return GNUNET_SYSERR;
-  } 
+  }
 
   /* if a field is null, continue but
    * remember that we now return a different result */
@@ -182,8 +182,8 @@ extract_fixed_blob (void *cls,
                    fnum);
   GNUNET_assert (NULL != res);
   GNUNET_memcpy (dst,
-         res,
-         len);
+                 res,
+                 len);
   return GNUNET_OK;
 }
 
@@ -580,7 +580,7 @@ extract_uint16 (void *cls,
   if (PQgetisnull (result,
                   row,
                   fnum))
-  { 
+  {
     GNUNET_break (0);
     return GNUNET_SYSERR;
   }
@@ -590,6 +590,14 @@ extract_uint16 (void *cls,
     GNUNET_break (0);
     return GNUNET_SYSERR;
   }
+  if (sizeof (uint16_t) !=
+      PQgetlength (result,
+                   row,
+                   fnum))
+  {
+    GNUNET_break (0);
+    return GNUNET_SYSERR;
+  }
   res = (uint16_t *) PQgetvalue (result,
                                 row,
                                 fnum);
@@ -663,6 +671,14 @@ extract_uint32 (void *cls,
     GNUNET_break (0);
     return GNUNET_SYSERR;
   }
+  if (sizeof (uint32_t) !=
+      PQgetlength (result,
+                   row,
+                   fnum))
+  {
+    GNUNET_break (0);
+    return GNUNET_SYSERR;
+  }
   res = (uint32_t *) PQgetvalue (result,
                                 row,
                                 fnum);
@@ -736,6 +752,14 @@ extract_uint64 (void *cls,
     GNUNET_break (0);
     return GNUNET_SYSERR;
   }
+  if (sizeof (uint64_t) !=
+      PQgetlength (result,
+                   row,
+                   fnum))
+  {
+    GNUNET_break (0);
+    return GNUNET_SYSERR;
+  }
   res = (uint64_t *) PQgetvalue (result,
                                 row,
                                 fnum);