diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-01-21 02:10:04 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-01-21 02:10:04 +0100 |
commit | 7ed02994541af600b0d080829e944ab414445dcc (patch) | |
tree | 35edde9faf285b335717a1211b80b9d0c26540f3 /src/util | |
parent | a0afe6fbcc277decf4680957abc77fba896cb567 (diff) | |
download | gnunet-7ed02994541af600b0d080829e944ab414445dcc.tar.gz gnunet-7ed02994541af600b0d080829e944ab414445dcc.zip |
fix use of strptime
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/strings.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/util/strings.c b/src/util/strings.c index 535c998cd..2cbdb640b 100644 --- a/src/util/strings.c +++ b/src/util/strings.c | |||
@@ -385,6 +385,7 @@ GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time, | |||
385 | { | 385 | { |
386 | struct tm tv; | 386 | struct tm tv; |
387 | time_t t; | 387 | time_t t; |
388 | const char *eos; | ||
388 | 389 | ||
389 | if (0 == strcasecmp ("end of time", | 390 | if (0 == strcasecmp ("end of time", |
390 | fancy_time)) | 391 | fancy_time)) |
@@ -392,17 +393,18 @@ GNUNET_STRINGS_fancy_time_to_absolute (const char *fancy_time, | |||
392 | *atime = GNUNET_TIME_UNIT_FOREVER_ABS; | 393 | *atime = GNUNET_TIME_UNIT_FOREVER_ABS; |
393 | return GNUNET_OK; | 394 | return GNUNET_OK; |
394 | } | 395 | } |
396 | eos = &fancy_time[strlen (fancy_time)]; | ||
395 | memset (&tv, 0, sizeof (tv)); | 397 | memset (&tv, 0, sizeof (tv)); |
396 | if ( (NULL == strptime (fancy_time, "%a %b %d %H:%M:%S %Y", &tv)) && | 398 | if ( (eos != strptime (fancy_time, "%a %b %d %H:%M:%S %Y", &tv)) && |
397 | (NULL == strptime (fancy_time, "%c", &tv)) && | 399 | (eos != strptime (fancy_time, "%c", &tv)) && |
398 | (NULL == strptime (fancy_time, "%Ec", &tv)) && | 400 | (eos != strptime (fancy_time, "%Ec", &tv)) && |
399 | (NULL == strptime (fancy_time, "%Y-%m-%d %H:%M:%S", &tv)) && | 401 | (eos != strptime (fancy_time, "%Y-%m-%d %H:%M:%S", &tv)) && |
400 | (NULL == strptime (fancy_time, "%Y-%m-%d %H:%M", &tv)) && | 402 | (eos != strptime (fancy_time, "%Y-%m-%d %H:%M", &tv)) && |
401 | (NULL == strptime (fancy_time, "%x", &tv)) && | 403 | (eos != strptime (fancy_time, "%x", &tv)) && |
402 | (NULL == strptime (fancy_time, "%Ex", &tv)) && | 404 | (eos != strptime (fancy_time, "%Ex", &tv)) && |
403 | (NULL == strptime (fancy_time, "%Y-%m-%d", &tv)) && | 405 | (eos != strptime (fancy_time, "%Y-%m-%d", &tv)) && |
404 | (NULL == strptime (fancy_time, "%Y-%m", &tv)) && | 406 | (eos != strptime (fancy_time, "%Y-%m", &tv)) && |
405 | (NULL == strptime (fancy_time, "%Y", &tv)) ) | 407 | (eos != strptime (fancy_time, "%Y", &tv)) ) |
406 | return GNUNET_SYSERR; | 408 | return GNUNET_SYSERR; |
407 | t = mktime (&tv); | 409 | t = mktime (&tv); |
408 | atime->abs_value_us = (uint64_t) ((uint64_t) t * 1000LL * 1000LL); | 410 | atime->abs_value_us = (uint64_t) ((uint64_t) t * 1000LL * 1000LL); |