From: raiz Date: Tue, 27 Dec 2016 17:09:07 +0000 (+0300) Subject: don't allow the use of perc if uninitialized X-Git-Url: https://git.atheridis.org/?a=commitdiff_plain;h=11fec4fa9501bd20aace72235c4525dc87d5d281;p=suckless%2Fslstatus.git don't allow the use of perc if uninitialized --- diff --git a/slstatus.c b/slstatus.c index ad0b960..7b02205 100644 --- a/slstatus.c +++ b/slstatus.c @@ -699,11 +699,11 @@ wifi_perc(const char *iface) 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); }