Xinqi Bao's Git

fixed run_command()
authorAaron Marcher <[email protected]>
Mon, 10 Oct 2016 07:02:24 +0000 (09:02 +0200)
committerAaron Marcher <[email protected]>
Mon, 10 Oct 2016 07:02:24 +0000 (09:02 +0200)
slstatus.c

index e7c1c3f..9272c54 100644 (file)
@@ -407,8 +407,8 @@ run_command(const char *cmd)
                warn("Failed to get command output for %s", cmd);
                return smprintf(UNKNOWN_STR);
        }
                warn("Failed to get command output for %s", cmd);
                return smprintf(UNKNOWN_STR);
        }
-       fgets(buf, sizeof(buf), fp);
-       buf[sizeof(buf)-1] = '\0';
+       fgets(buf, sizeof(buf)-1, fp);
+       buf[strlen(buf)-1] = '\0';
        pclose(fp);
 
        return smprintf("%s", buf);
        pclose(fp);
 
        return smprintf("%s", buf);