fixed run_command()

This commit is contained in:
Aaron Marcher 2016-10-10 09:19:44 +02:00
parent 5a70f920f0
commit 6890a27a3a
No known key found for this signature in database
GPG Key ID: 74B048E5C2474F9A
1 changed files with 4 additions and 2 deletions

View File

@ -400,7 +400,7 @@ static char *
run_command(const char *cmd) run_command(const char *cmd)
{ {
FILE *fp; FILE *fp;
char buf[64] = "n/a"; char buf[1024] = "n/a";
fp = popen(cmd, "r"); fp = popen(cmd, "r");
if (fp == NULL) { if (fp == NULL) {
@ -408,9 +408,11 @@ run_command(const char *cmd)
return smprintf(UNKNOWN_STR); return smprintf(UNKNOWN_STR);
} }
fgets(buf, sizeof(buf)-1, fp); fgets(buf, sizeof(buf)-1, fp);
buf[strlen(buf)-1] = '\0';
pclose(fp); pclose(fp);
buf[strlen(buf)] = '\0';
strtok(buf, "\n");
return smprintf("%s", buf); return smprintf("%s", buf);
} }