1
0

don't allow the use of perc if uninitialized

This commit is contained in:
raiz 2016-12-27 20:09:07 +03:00
parent 8b5b72b65e
commit 11fec4fa95

View File

@ -699,11 +699,11 @@ wifi_perc(const char *iface)
fgets(buf, sizeof(buf), fp); fgets(buf, sizeof(buf), fp);
fclose(fp); fclose(fp);
datastart = strstr(buf, concat); if ((datastart = strstr(buf, concat)) == NULL) {
if (datastart != NULL) { return smprintf("%s", UNKNOWN_STR);
datastart = strstr(buf, ":");
sscanf(datastart + 1, " %*d %d %*d %*d %*d %*d %*d %*d %*d %*d", &perc);
} }
datastart = (datastart+(strlen(iface)+1));
sscanf(datastart + 1, " %*d %d %*d %*d %*d %*d %*d %*d %*d %*d", &perc);
return smprintf("%d%%", perc); return smprintf("%d%%", perc);
} }