Fixing 0000280: stack smashing detected
authorMuhammad Usama <m.usama@gmail.com>
Thu, 26 Jan 2017 20:48:38 +0000 (01:48 +0500)
committerMuhammad Usama <m.usama@gmail.com>
Thu, 26 Jan 2017 20:48:38 +0000 (01:48 +0500)
It was a buffer overflow in wd_get_cmd function.

watchdog/wd_if.c

index fc472a427dfa80e241cd982af69cd4067d28480d..169b8958f30ba843d6e124fa0495792cd79833e5 100644 (file)
@@ -147,12 +147,12 @@ wd_get_cmd(char * buf, char * cmd)
 {
        int i,j;
        i = 0;
-       while(isspace(cmd[i]) != 0)
+       while(cmd[i] && isspace(cmd[i]) != 0)
        {
                i++;
        }
        j = 0;
-       while(isspace(cmd[i]) == 0)
+       while(cmd[i] && isspace(cmd[i]) == 0)
        {
                buf[j++] = cmd[i++];
        }