]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/basic/time-util.c
basic/time-util: make parsing of dual_timestamp more strict
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 19 May 2017 18:49:06 +0000 (14:49 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 19 May 2017 19:01:20 +0000 (15:01 -0400)
commit9c0565b2c3dec698a526cade57b331004699e094
tree01a462a3d5ed4c3efbb8535940c4908e3b537b2f
parentbf32e385761d65459a7ee79864d43d87e6774992
basic/time-util: make parsing of dual_timestamp more strict

*scanf functions set errno on i/o error. For sscanf, this doesn't really apply,
so (based on the man page), it seems that errno is unlikely to be ever set to a
useful value. So just ignore errno. The error message includes the string that
was parsed, so it should be always pretty clear why parsing failed.

On the other hand, detect trailing characters and minus prefix that weren't
converted properly. This matches what our safe_ato* functions do. Add tests to
elucidate various edge cases.
src/basic/time-util.c
src/test/test-time.c