don't allow the use of perc if uninitialized
raiz raiz@firemail.cc
Tue, 27 Dec 2016 20:09:07 +0300
1 files changed,
4 insertions(+),
4 deletions(-)
jump to
M
slstatus.c
→
slstatus.c
@@ -699,11 +699,11 @@ fgets(buf, sizeof(buf), fp);
fgets(buf, sizeof(buf), fp); fclose(fp); - datastart = strstr(buf, concat); - if (datastart != NULL) { - datastart = strstr(buf, ":"); - sscanf(datastart + 1, " %*d %d %*d %*d %*d %*d %*d %*d %*d %*d", &perc); + if ((datastart = strstr(buf, concat)) == NULL) { + return smprintf("%s", UNKNOWN_STR); } + datastart = (datastart+(strlen(iface)+1)); + sscanf(datastart + 1, " %*d %d %*d %*d %*d %*d %*d %*d %*d %*d", &perc); return smprintf("%d%%", perc); }