View Issue Details

IDProjectCategoryView StatusLast Update
0012216Talerexchangepublic2026-11-18 16:41
Reporterbot-cg [agent]  
PrioritynormalSeverityminor 
Status new 
Product Versiongit (master) 
Summary0012216: TALER_EXCHANGEDB_do_import_credits reads uninitialized duplicate flags when the procedure returns fewer rows than transfers
Descriptionhelper_cb() (src/exchangedb/do_import_credits.c) refuses more result rows than reserve transfers, but not fewer, although its comment says the counts must be equal. TALER_EXCHANGEDB_do_import_credits() then reads transaction_duplicates[i] for every i < rlen, so with fewer rows the trailing entries are uninitialized stack memory, and the reserve results and duplicate count that taler-exchange-wirewatch acts on are indeterminate.

The shipped exchange_do_import_credits() returns exactly one row per reserve transfer, so this only matters if the procedure and the C code drift apart. Confirmed by reading the code at 2a57cbcaf.

The attached patch refuses any row count other than the number of reserve transfers.
TagsNo tags attached.
Attached Files
12216-exchangedb-require-one-do_import_credits-row-per-res.patch (1,313 bytes)   
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Christian Grothoff <christian@grothoff.org>
Date: Wed, 18 Nov 2026 17:41:26 +0100
Subject: [PATCH] exchangedb: require one do_import_credits row per reserve
 transfer

Fewer rows than transfers left entries of the duplicate flags unset, and
the caller read them all.

Issue: https://bugs.taler.net/n/12216

Assisted by LLM
---
 src/exchangedb/do_import_credits.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/exchangedb/do_import_credits.c b/src/exchangedb/do_import_credits.c
index 0900a5bad..50447dda9 100644
--- a/src/exchangedb/do_import_credits.c
+++ b/src/exchangedb/do_import_credits.c
@@ -99,11 +99,12 @@ helper_cb (void *cls,
 {
   struct Context *ctx = cls;
 
-  if (num_results > ctx->length)
+  if (num_results != ctx->length)
   {
     /* The procedure returns one row per reserve transfer we passed in; a
-       different count means the two have drifted apart, and writing past the
-       caller's array is not the way to find that out. */
+       different count means the two have drifted apart.  More rows would
+       write past the caller's array, fewer would leave entries of it
+       unset. */
     GNUNET_break (0);
     ctx->status = GNUNET_SYSERR;
     return;
-- 
2.47.3

Required notifications

Address or linkRemarkAdded byNotifiedActions

Relationships

child of 0012186 new Unchecked array lengths and counts in exchange, merchant and anastasis: review after 2a57cbcaf [meta] 

Activities

Issue History

Date ModifiedUsernameFieldChange
2026-11-18 16:41bot-cgNew Issue
2026-11-18 16:41bot-cgRelationship addedchild of 0012186
2026-11-18 16:41bot-cgImplementer => oec
2026-11-18 16:41bot-cgReviewer => Christian Grothoff
2026-11-18 16:41bot-cgRelease signed by => Christian Grothoff
2026-11-18 16:41bot-cgDeployed by => Christian Grothoff
2026-11-18 16:41bot-cgVerifier => oec
2026-11-18 16:41bot-cgCommunicator => CM_7
2026-11-18 16:41bot-cgFile Added: 12216-exchangedb-require-one-do_import_credits-row-per-res.patch