commit c27ad69b09a218d163ace2d29ad4093fc9d86478
parent fb0c82a06aabed2f04636c13d60a1ab7a1fa3898
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 29 Jul 2026 13:07:06 +0200
restclient: NULL-check version/expiration headers before sscanf
Diffstat:
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/restclient/anastasis_api_policy_store.c b/src/restclient/anastasis_api_policy_store.c
@@ -144,20 +144,20 @@ handle_policy_store_finished (void *cls,
unsigned long long expiration;
char dummy;
- if (1 != sscanf (pso->policy_version,
- "%llu%c",
- &version,
- &dummy))
- {
- ud.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
- ud.us = ANASTASIS_US_SERVER_ERROR;
- break;
- }
- if (1 != sscanf (pso->policy_expiration,
- "%llu%c",
- &expiration,
- &dummy))
+ /* Both headers are optional on the wire: a provider that answers 204
+ without them must not send us into sscanf(NULL,...). */
+ if ( (NULL == pso->policy_version) ||
+ (NULL == pso->policy_expiration) ||
+ (1 != sscanf (pso->policy_version,
+ "%llu%c",
+ &version,
+ &dummy)) ||
+ (1 != sscanf (pso->policy_expiration,
+ "%llu%c",
+ &expiration,
+ &dummy)) )
{
+ GNUNET_break_op (0);
ud.ec = TALER_EC_GENERIC_REPLY_MALFORMED;
ud.us = ANASTASIS_US_SERVER_ERROR;
break;