From: Pádraig Brady Date: Thu, 8 Sep 2016 14:17:10 +0000 (+0100) Subject: parse-datetime: restrict debug output to input string X-Git-Tag: v1.0~6652 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=2eb2659743e2d6cc3667d8df8f074d2e1e6db24f;p=gnulib.git parse-datetime: restrict debug output to input string * lib/parse-datetime.y (parse_datetime2): If we parse all of the input but determine it's invalid, ensure we don't output the now invalid input pointer. This issue was seen with `date -d 'now +1'`. --- diff --git a/ChangeLog b/ChangeLog index 3c65fdea4d..e02ca0cea6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2016-09-08 Pádraig Brady + + parse-datetime: restrict debug output to input string + * lib/parse-datetime.y (parse_datetime2): If we parse + all of the input but determine it's invalid, ensure + we don't output the now invalid input pointer. + This issue was seen with `date -d 'now +1'`. + 2016-09-07 Paul Eggert flexmember: new macro FLEXALIGNOF diff --git a/lib/parse-datetime.y b/lib/parse-datetime.y index 152cb412c9..997895555c 100644 --- a/lib/parse-datetime.y +++ b/lib/parse-datetime.y @@ -1704,6 +1704,7 @@ parse_datetime2 (struct timespec *result, char const *p, bool ok = true; char dbg_ord[DBGBUFSIZE]; char dbg_tm[DBGBUFSIZE]; + char const *input_sentinel = p + strlen (p); if (! now) { @@ -1862,7 +1863,15 @@ parse_datetime2 (struct timespec *result, char const *p, if (yyparse (&pc) != 0) { if (pc.parse_datetime_debug) - dbg_printf (_("error: parsing failed, stopped at '%s'\n"), pc.input); + { + if (input_sentinel <= pc.input) + dbg_printf (_("error: parsing failed\n"), pc.input); + else + { + dbg_printf (_("error: parsing failed, stopped at '%s'\n"), + pc.input); + } + } goto fail; }