Merge pull request #39 from stoeckmann/fgets

On success, fgets always terminates the result.
This commit is contained in:
Aaron Marcher 2017-04-20 22:14:56 +02:00 committed by GitHub
commit 95ceafcae7

View File

@ -447,7 +447,7 @@ 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("%s", UNKNOWN_STR); return smprintf("%s", UNKNOWN_STR);
} }
fgets(buf, sizeof(buf) - 1, fp); fgets(buf, sizeof(buf), fp);
pclose(fp); pclose(fp);
buf[sizeof(buf) - 1] = '\0'; buf[sizeof(buf) - 1] = '\0';