aboutsummaryrefslogtreecommitdiff
path: root/src/pq
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-01-15 15:15:42 +0100
committerChristian Grothoff <christian@grothoff.org>2018-01-15 15:15:54 +0100
commitfa93e401ce5bd513d7df13029fef2461d0d95be1 (patch)
tree062b7b0dfcd061a03d6c0ecbb267608777ee30c2 /src/pq
parentd23759952cf9b0f541f81e773a09588795936ddf (diff)
downloadgnunet-fa93e401ce5bd513d7df13029fef2461d0d95be1.tar.gz
gnunet-fa93e401ce5bd513d7df13029fef2461d0d95be1.zip
additionally check that size returned by Postgres matches
Diffstat (limited to 'src/pq')
-rw-r--r--src/pq/pq_result_helper.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c
index 045fe74b1..d9fed26a6 100644
--- a/src/pq/pq_result_helper.c
+++ b/src/pq/pq_result_helper.c
@@ -100,8 +100,8 @@ extract_varsize_blob (void *cls,
100 idst = GNUNET_malloc (len); 100 idst = GNUNET_malloc (len);
101 *((void **) dst) = idst; 101 *((void **) dst) = idst;
102 GNUNET_memcpy (idst, 102 GNUNET_memcpy (idst,
103 res, 103 res,
104 len); 104 len);
105 return GNUNET_OK; 105 return GNUNET_OK;
106} 106}
107 107
@@ -165,7 +165,7 @@ extract_fixed_blob (void *cls,
165 { 165 {
166 GNUNET_break (0); 166 GNUNET_break (0);
167 return GNUNET_SYSERR; 167 return GNUNET_SYSERR;
168 } 168 }
169 169
170 /* if a field is null, continue but 170 /* if a field is null, continue but
171 * remember that we now return a different result */ 171 * remember that we now return a different result */
@@ -182,8 +182,8 @@ extract_fixed_blob (void *cls,
182 fnum); 182 fnum);
183 GNUNET_assert (NULL != res); 183 GNUNET_assert (NULL != res);
184 GNUNET_memcpy (dst, 184 GNUNET_memcpy (dst,
185 res, 185 res,
186 len); 186 len);
187 return GNUNET_OK; 187 return GNUNET_OK;
188} 188}
189 189
@@ -580,7 +580,7 @@ extract_uint16 (void *cls,
580 if (PQgetisnull (result, 580 if (PQgetisnull (result,
581 row, 581 row,
582 fnum)) 582 fnum))
583 { 583 {
584 GNUNET_break (0); 584 GNUNET_break (0);
585 return GNUNET_SYSERR; 585 return GNUNET_SYSERR;
586 } 586 }
@@ -590,6 +590,14 @@ extract_uint16 (void *cls,
590 GNUNET_break (0); 590 GNUNET_break (0);
591 return GNUNET_SYSERR; 591 return GNUNET_SYSERR;
592 } 592 }
593 if (sizeof (uint16_t) !=
594 PQgetlength (result,
595 row,
596 fnum))
597 {
598 GNUNET_break (0);
599 return GNUNET_SYSERR;
600 }
593 res = (uint16_t *) PQgetvalue (result, 601 res = (uint16_t *) PQgetvalue (result,
594 row, 602 row,
595 fnum); 603 fnum);
@@ -663,6 +671,14 @@ extract_uint32 (void *cls,
663 GNUNET_break (0); 671 GNUNET_break (0);
664 return GNUNET_SYSERR; 672 return GNUNET_SYSERR;
665 } 673 }
674 if (sizeof (uint32_t) !=
675 PQgetlength (result,
676 row,
677 fnum))
678 {
679 GNUNET_break (0);
680 return GNUNET_SYSERR;
681 }
666 res = (uint32_t *) PQgetvalue (result, 682 res = (uint32_t *) PQgetvalue (result,
667 row, 683 row,
668 fnum); 684 fnum);
@@ -736,6 +752,14 @@ extract_uint64 (void *cls,
736 GNUNET_break (0); 752 GNUNET_break (0);
737 return GNUNET_SYSERR; 753 return GNUNET_SYSERR;
738 } 754 }
755 if (sizeof (uint64_t) !=
756 PQgetlength (result,
757 row,
758 fnum))
759 {
760 GNUNET_break (0);
761 return GNUNET_SYSERR;
762 }
739 res = (uint64_t *) PQgetvalue (result, 763 res = (uint64_t *) PQgetvalue (result,
740 row, 764 row,
741 fnum); 765 fnum);