1
0
Fork 0

strtok() has no effect on buf && fgets() should have the full buffer length

This commit is contained in:
raiz 2016-12-27 18:54:16 +03:00
parent f62d626d9b
commit 3bfc3bbcae

View file

@ -413,11 +413,10 @@ run_command(const char *cmd)
warn("Failed to get command output for %s", cmd); warn("Failed to get command output for %s", cmd);
return smprintf(UNKNOWN_STR); return smprintf(UNKNOWN_STR);
} }
fgets(buf, sizeof(buf)-1, fp); fgets(buf, sizeof(buf), fp);
pclose(fp); pclose(fp);
buf[strlen(buf)] = '\0'; buf[strlen(buf)] = '\0';
strtok(buf, "\n");
return smprintf("%s", buf); return smprintf("%s", buf);
} }