diff options
author | raiz <raiz@firemail.cc> | 2016-12-27 20:09:07 +0300 |
---|---|---|
committer | raiz <raiz@firemail.cc> | 2016-12-27 20:09:07 +0300 |
commit | 11fec4fa9501bd20aace72235c4525dc87d5d281 (patch) | |
tree | 6f1bcb073331038394e6f064da35b894c0949a5a | |
parent | 8b5b72b65efeaab5985e704f00e5865e3cfe4528 (diff) |
don't allow the use of perc if uninitialized
-rw-r--r-- | slstatus.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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); } |