[OpenWrt-Devel] [PATCH procd] system: fix undefined behavior in wdt offline check
Alexander Couzens
lynxis at fe80.eu
Wed Sep 23 09:04:18 EDT 2015
watchdog_fd() is returning a char* and not a int. checking against < 0 could
lead in undefined behaviour.
Signed-off-by: Alexander Couzens <lynxis at fe80.eu>
---
system.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system.c b/system.c
index 82c672e..fb7fbe4 100644
--- a/system.c
+++ b/system.c
@@ -282,7 +282,7 @@ static int watchdog_set(struct ubus_context *ctx, struct ubus_object *obj,
if (tb[WDT_STOP])
watchdog_set_stopped(blobmsg_get_bool(tb[WDT_STOP]));
- if (watchdog_fd() < 0)
+ if (watchdog_fd() == NULL)
status = "offline";
else if (watchdog_get_stopped())
status = "stopped";
--
2.5.3
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list