all repos — slstatus @ 1289bdb742adab134cf4874447b66ab386deb724

my build of slstatus (tools.suckless.org/slstatus/)

Merge pull request #38 from stoeckmann/terminating-nul

Fixed out of boundary write on long lines.
Aaron Marcher info@nulltime.net
Sun, 02 Apr 2017 15:27:09 +0200
commit

1289bdb742adab134cf4874447b66ab386deb724

parent

cceeec0efada64579525b90b30e5597cd24dfc6c

1 files changed, 6 insertions(+), 6 deletions(-)

jump to
M slstatus.cslstatus.c

@@ -447,9 +447,9 @@ if (fp == NULL) {

warn("Failed to get command output for %s", cmd); return smprintf("%s", UNKNOWN_STR); } - fgets(buf, sizeof(buf), fp); + fgets(buf, sizeof(buf) - 1, fp); pclose(fp); - buf[sizeof(buf)] = '\0'; + buf[sizeof(buf) - 1] = '\0'; if ((nlptr = strstr(buf, "\n")) != NULL) { nlptr[0] = '\0';

@@ -473,7 +473,7 @@ warn("Failed to open file /proc/meminfo");

return smprintf("%s", UNKNOWN_STR); } - if ((bytes_read = fread(buf, sizeof(char), sizeof(buf), fp)) == 0) { + if ((bytes_read = fread(buf, sizeof(char), sizeof(buf) - 1, fp)) == 0) { warn("swap_free: read error"); fclose(fp); return smprintf("%s", UNKNOWN_STR);

@@ -510,7 +510,7 @@ warn("Failed to open file /proc/meminfo");

return smprintf("%s", UNKNOWN_STR); } - if ((bytes_read = fread(buf, sizeof(char), sizeof(buf), fp)) == 0) { + if ((bytes_read = fread(buf, sizeof(char), sizeof(buf) - 1, fp)) == 0) { warn("swap_perc: read error"); fclose(fp); return smprintf("%s", UNKNOWN_STR);

@@ -551,7 +551,7 @@ if (fp == NULL) {

warn("Failed to open file /proc/meminfo"); return smprintf("%s", UNKNOWN_STR); } - if ((bytes_read = fread(buf, sizeof(char), sizeof(buf), fp)) == 0) { + if ((bytes_read = fread(buf, sizeof(char), sizeof(buf) - 1, fp)) == 0) { warn("swap_total: read error"); fclose(fp); return smprintf("%s", UNKNOWN_STR);

@@ -582,7 +582,7 @@ if (fp == NULL) {

warn("Failed to open file /proc/meminfo"); return smprintf("%s", UNKNOWN_STR); } - if ((bytes_read = fread(buf, sizeof(char), sizeof(buf), fp)) == 0) { + if ((bytes_read = fread(buf, sizeof(char), sizeof(buf) - 1, fp)) == 0) { warn("swap_used: read error"); fclose(fp); return smprintf("%s", UNKNOWN_STR);