Xinqi Bao's Git

run_command: strlen() will not function if string is not null terminated
authorAaron Marcher <[email protected]>
Sat, 7 Jan 2017 20:19:40 +0000 (21:19 +0100)
committerAaron Marcher <[email protected]>
Sat, 7 Jan 2017 20:19:40 +0000 (21:19 +0100)
slstatus.c

index 3ad79c0..4432e18 100644 (file)
@@ -426,7 +426,7 @@ run_command(const char *cmd)
        }
        fgets(buf, sizeof(buf), fp);
        pclose(fp);
-       buf[strlen(buf)] = '\0';
+       buf[sizeof(buf)] = '\0';
 
        if ((nlptr = strstr(buf, "\n")) != NULL) {
                nlptr[0] = '\0';