chiark / gitweb /
sd-daemon: explicitly filter out -1 when parsing watchdog timeout
authorLennart Poettering <lennart@poettering.net>
Tue, 3 Nov 2015 11:27:12 +0000 (12:27 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 26 Apr 2017 10:58:55 +0000 (12:58 +0200)
We already filter out 0, and as -1 is usually special (meaning infinity,
as in USEC_INFINITY) we should better not accept it either. Better safe
than sorry...

src/libelogind/sd-daemon/sd-daemon.c

index 3ea9764..e47da68 100644 (file)
@@ -595,7 +595,7 @@ _public_ int sd_watchdog_enabled(int unset_environment, uint64_t *usec) {
         r = safe_atou64(s, &u);
         if (r < 0)
                 goto finish;
         r = safe_atou64(s, &u);
         if (r < 0)
                 goto finish;
-        if (u <= 0) {
+        if (u <= 0 || u >= USEC_INFINITY) {
                 r = -EINVAL;
                 goto finish;
         }
                 r = -EINVAL;
                 goto finish;
         }