If fgets succeeds, then the resulting char array is always
terminated by a '\0'. No need to keep extra space, therefore
sizeof(buf) is the correct argument.
Signed-off-by: Tobias Stoeckmann <[email protected]>
warn("Failed to get command output for %s", cmd);
return smprintf("%s", UNKNOWN_STR);
}
warn("Failed to get command output for %s", cmd);
return smprintf("%s", UNKNOWN_STR);
}
- fgets(buf, sizeof(buf) - 1, fp);
+ fgets(buf, sizeof(buf), fp);
pclose(fp);
buf[sizeof(buf) - 1] = '\0';
pclose(fp);
buf[sizeof(buf) - 1] = '\0';