exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit 60323e2ceb2b585c6d3865458f39a8811e42b452
parent 9834089c99d9e22a3e399cebbd532ceb3ea62858
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 30 Jun 2026 10:42:05 +0200

check libpq input better

Diffstat:
Msrc/kyclogic/kyclogic_sanctions.c | 11+++++++++++
Msrc/pq/pq_result_helper.c | 15+++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/kyclogic/kyclogic_sanctions.c b/src/kyclogic/kyclogic_sanctions.c @@ -152,6 +152,11 @@ fail_hard (struct TALER_KYCLOGIC_SanctionRater *sr) GNUNET_SCHEDULER_cancel (sr->read_task); sr->read_task = NULL; } + if (NULL != sr->write_task) + { + GNUNET_SCHEDULER_cancel (sr->write_task); + sr->write_task = NULL; + } if (NULL != sr->helper) { GNUNET_process_destroy (sr->helper); @@ -245,9 +250,15 @@ process_buffer (struct TALER_KYCLOGIC_SanctionRater *sr) strcpy (best_match, "<none>"); } + { struct TALER_KYCLOGIC_EvaluationEntry *ee = sr->ee_tail; + /* This assertion would fail if the helper outputs more lines + than we sent it queries, pointing to some kind of + desynchronization. Failing hard as we cannot really handle + this case nicely. */ + GNUNET_assert (NULL != ee); GNUNET_CONTAINER_DLL_remove (sr->ee_head, sr->ee_tail, ee); diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c @@ -1227,6 +1227,7 @@ extract_array_generic ( { char *in = data + sizeof(header); + const char *const data_end = data + (size_t) data_sz; switch (info->typ) { @@ -1247,11 +1248,13 @@ extract_array_generic ( uint32_t val; size_t sz; + FAIL_IF (sizeof(val) > (size_t) (data_end - in)); GNUNET_memcpy (&val, in, sizeof(val)); sz = ntohl (val); in += sizeof(val); + FAIL_IF (sz > (size_t) (data_end - in)); /* total size for this array-entry */ FAIL_IF (sizeof(ap) != sz); @@ -1288,11 +1291,13 @@ extract_array_generic ( uint32_t val; size_t sz; + FAIL_IF (sizeof(val) > (size_t) (data_end - in)); GNUNET_memcpy (&val, in, sizeof(val)); sz = ntohl (val); in += sizeof(val); + FAIL_IF (sz > (size_t) (data_end - in)); FAIL_IF ( (sz >= sizeof(ap)) || (sz <= sizeof(ap) - TALER_CURRENCY_LEN) ); @@ -1330,12 +1335,14 @@ extract_array_generic ( uint32_t val; size_t sz; + FAIL_IF (sizeof(val) > (size_t) (data_end - in)); GNUNET_memcpy (&val, in, sizeof(val)); sz = ntohl (val); FAIL_IF (sz != sizeof(struct TALER_DenominationHashP)); in += sizeof(uint32_t); + FAIL_IF (sz > (size_t) (data_end - in)); *(struct TALER_DenominationHashP *) out = *(struct TALER_DenominationHashP *) in; in += sz; @@ -1354,12 +1361,14 @@ extract_array_generic ( uint32_t val; size_t sz; + FAIL_IF (sizeof(val) > (size_t) (data_end - in)); GNUNET_memcpy (&val, in, sizeof(val)); sz = ntohl (val); FAIL_IF (sz != sizeof(struct GNUNET_HashCode)); in += sizeof(uint32_t); + FAIL_IF (sz > (size_t) (data_end - in)); *(struct GNUNET_HashCode *) out = *(struct GNUNET_HashCode *) in; in += sz; @@ -1378,12 +1387,14 @@ extract_array_generic ( uint32_t val; size_t sz; + FAIL_IF (sizeof(val) > (size_t) (data_end - in)); GNUNET_memcpy (&val, in, sizeof(val)); sz = ntohl (val); FAIL_IF (sz != sizeof(struct TALER_BlindedCoinHashP)); in += sizeof(uint32_t); + FAIL_IF (sz > (size_t) (data_end - in)); *(struct TALER_BlindedCoinHashP *) out = *(struct TALER_BlindedCoinHashP *) in; in += sz; @@ -1402,12 +1413,14 @@ extract_array_generic ( uint32_t val; size_t sz; + FAIL_IF (sizeof(val) > (size_t) (data_end - in)); GNUNET_memcpy (&val, in, sizeof(val)); sz = ntohl (val); FAIL_IF (sz != sizeof(struct GNUNET_CRYPTO_CSPublicRPairP)); in += sizeof(uint32_t); + FAIL_IF (sz > (size_t) (data_end - in)); *(struct GNUNET_CRYPTO_CSPublicRPairP *) out = *(struct GNUNET_CRYPTO_CSPublicRPairP *) in; in += sz; @@ -1438,6 +1451,7 @@ extract_array_generic ( uint32_t val; size_t sz; + FAIL_IF (sizeof(val) > (size_t) (data_end - in)); GNUNET_memcpy (&val, in, sizeof(val)); @@ -1445,6 +1459,7 @@ extract_array_generic ( FAIL_IF (sizeof(be) > sz); in += sizeof(val); + FAIL_IF (sz > (size_t) (data_end - in)); GNUNET_memcpy (&be, in, sizeof(be));