summaryrefslogtreecommitdiff
path: root/src/shared/time-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-04-21 20:22:51 +0200
committerLennart Poettering <lennart@poettering.net>2015-04-21 20:23:41 +0200
commite911de996a72af7659e4019f03b80f11c476f3f3 (patch)
treee2c114f7cf21a6a187110c08c24ed132e2ea5652 /src/shared/time-util.c
parentf34beace377a6cce4e148182b434c6d975b0d012 (diff)
core: make unit deserialization more defensive
Diffstat (limited to 'src/shared/time-util.c')
-rw-r--r--src/shared/time-util.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/shared/time-util.c b/src/shared/time-util.c
index 1c36c577c4..12f1b193be 100644
--- a/src/shared/time-util.c
+++ b/src/shared/time-util.c
@@ -398,18 +398,21 @@ void dual_timestamp_serialize(FILE *f, const char *name, dual_timestamp *t) {
t->monotonic);
}
-void dual_timestamp_deserialize(const char *value, dual_timestamp *t) {
+int dual_timestamp_deserialize(const char *value, dual_timestamp *t) {
unsigned long long a, b;
assert(value);
assert(t);
- if (sscanf(value, "%llu %llu", &a, &b) != 2)
- log_debug("Failed to parse finish timestamp value %s", value);
- else {
- t->realtime = a;
- t->monotonic = b;
+ if (sscanf(value, "%llu %llu", &a, &b) != 2) {
+ log_debug("Failed to parse finish timestamp value %s.", value);
+ return -EINVAL;
}
+
+ t->realtime = a;
+ t->monotonic = b;
+
+ return 0;
}
int parse_timestamp(const char *t, usec_t *usec) {