[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: PQ: support returning arrays of length 0
From: |
gnunet |
Subject: |
[gnunet] branch master updated: PQ: support returning arrays of length 0 (in which case ndim is also zero) |
Date: |
Sun, 26 May 2024 15:07:50 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new af21c76e8 PQ: support returning arrays of length 0 (in which case ndim
is also zero)
af21c76e8 is described below
commit af21c76e87e701fb88f7b0d535e9758ef832ec39
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun May 26 15:07:27 2024 +0200
PQ: support returning arrays of length 0 (in which case ndim is also zero)
---
src/lib/pq/Makefile.am | 2 +-
src/lib/pq/pq_result_helper.c | 46 ++++++++++++++++++++++++++++++-------------
2 files changed, 33 insertions(+), 15 deletions(-)
diff --git a/src/lib/pq/Makefile.am b/src/lib/pq/Makefile.am
index 91014dbfe..299cebccc 100644
--- a/src/lib/pq/Makefile.am
+++ b/src/lib/pq/Makefile.am
@@ -32,7 +32,7 @@ libgnunetpq_la_LIBADD = -lpq \
libgnunetpq_la_LDFLAGS = \
$(POSTGRESQL_LDFLAGS) \
$(GN_LIB_LDFLAGS) \
- -version-info 7:0:2
+ -version-info 7:1:2
if ENABLE_TEST_RUN
AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export
PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset
XDG_CONFIG_HOME;
diff --git a/src/lib/pq/pq_result_helper.c b/src/lib/pq/pq_result_helper.c
index cbb1e8e8e..c7d7f9abd 100644
--- a/src/lib/pq/pq_result_helper.c
+++ b/src/lib/pq/pq_result_helper.c
@@ -1264,22 +1264,35 @@ extract_array_generic (
*((void **) dst) = NULL;
#define FAIL_IF(cond) \
- do { \
- if ((cond)) \
- { \
- GNUNET_break (! (cond)); \
- goto FAIL; \
- } \
- } while (0)
+ do { \
+ if ((cond)) \
+ { \
+ GNUNET_break (! (cond)); \
+ goto FAIL; \
+ } \
+ } while (0)
col_num = PQfnumber (result, fname);
FAIL_IF (0 > col_num);
data_sz = PQgetlength (result, row, col_num);
FAIL_IF (0 > data_sz);
- FAIL_IF (sizeof(header) > (size_t) data_sz);
-
data = PQgetvalue (result, row, col_num);
+ if (sizeof(header) > (size_t) data_sz)
+ {
+ uint32_t ndim;
+
+ /* data_sz is shorter than header if the
+ array length is 0, in which case ndim is 0! */
+ FAIL_IF (sizeof(uint32_t) > (size_t) data_sz);
+ memcpy (&ndim,
+ data,
+ sizeof (ndim));
+ FAIL_IF (0 != ndim);
+ *info->num = 0;
+ return GNUNET_OK;
+ }
+ FAIL_IF (sizeof(header) > (size_t) data_sz);
FAIL_IF (NULL == data);
{
@@ -1391,7 +1404,8 @@ extract_array_generic (
case array_of_rel_time:
if (NULL != dst_size)
*dst_size = sizeof(struct GNUNET_TIME_Relative) * (header.dim);
- out = GNUNET_new_array (header.dim, struct GNUNET_TIME_Relative);
+ out = GNUNET_new_array (header.dim,
+ struct GNUNET_TIME_Relative);
*((void **) dst) = out;
for (uint32_t i = 0; i < header.dim; i++)
{
@@ -1408,7 +1422,8 @@ extract_array_generic (
case array_of_timestamp:
if (NULL != dst_size)
*dst_size = sizeof(struct GNUNET_TIME_Timestamp) * (header.dim);
- out = GNUNET_new_array (header.dim, struct GNUNET_TIME_Timestamp);
+ out = GNUNET_new_array (header.dim,
+ struct GNUNET_TIME_Timestamp);
*((void **) dst) = out;
for (uint32_t i = 0; i < header.dim; i++)
{
@@ -1920,7 +1935,8 @@ clean_blind_sign_pub (void *cls,
struct GNUNET_PQ_ResultSpec
GNUNET_PQ_result_spec_blind_sign_pub (const char *name,
- struct GNUNET_CRYPTO_BlindSignPublicKey
**pub)
+ struct GNUNET_CRYPTO_BlindSignPublicKey
**
+ pub)
{
struct GNUNET_PQ_ResultSpec res = {
.conv = &extract_blind_sign_pub,
@@ -2040,7 +2056,7 @@ extract_blind_sign_priv (void *cls,
*/
static void
clean_blind_sign_priv (void *cls,
- void *rd)
+ void *rd)
{
struct GNUNET_CRYPTO_BlindSignPrivateKey **priv = rd;
@@ -2052,7 +2068,8 @@ clean_blind_sign_priv (void *cls,
struct GNUNET_PQ_ResultSpec
GNUNET_PQ_result_spec_blind_sign_priv (const char *name,
- struct
GNUNET_CRYPTO_BlindSignPrivateKey **priv)
+ struct GNUNET_CRYPTO_BlindSignPrivateKey
+ **priv)
{
struct GNUNET_PQ_ResultSpec res = {
.conv = &extract_blind_sign_priv,
@@ -2064,4 +2081,5 @@ GNUNET_PQ_result_spec_blind_sign_priv (const char *name,
return res;
}
+
/* end of pq_result_helper.c */
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: PQ: support returning arrays of length 0 (in which case ndim is also zero),
gnunet <=