From d86a6615cc60ba9e9d1a70146d761160564f404a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 6 Oct 2017 22:04:51 +0200 Subject: really carefully check strtoll() return value before casting to uint64_t --- src/exchange-tools/taler-exchange-keyup.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/exchange-tools') diff --git a/src/exchange-tools/taler-exchange-keyup.c b/src/exchange-tools/taler-exchange-keyup.c index facb832d6..ccaca14f8 100644 --- a/src/exchange-tools/taler-exchange-keyup.c +++ b/src/exchange-tools/taler-exchange-keyup.c @@ -363,18 +363,22 @@ get_anchor_iter (void *cls, struct GNUNET_TIME_Absolute stamp; const char *base; char *end = NULL; + long long int bval; base = GNUNET_STRINGS_get_short_name (filename); - stamp.abs_value_us = strtoll (base, - &end, - 10); - if ((NULL == end) || (0 != *end)) + bval = strtoll (base, + &end, + 10); + if ( (NULL == end) || + (0 != *end) || + (0 > bval) ) { fprintf(stderr, "Ignoring unexpected file `%s'.\n", filename); return GNUNET_OK; } + stamp.abs_value_us = (uint64_t) bval; *anchor = GNUNET_TIME_absolute_max (stamp, *anchor); return GNUNET_OK; -- cgit v1.2.3