1
0
Fork 0

wifi_essid: add boundary check && prevent the use of direct string literal as a format string in snprintf()

This commit is contained in:
raiz 2016-12-27 20:14:45 +03:00
parent 11fec4fa95
commit 94e87eb8ba

View file

@ -717,7 +717,8 @@ wifi_essid(const char *iface)
memset(&wreq, 0, sizeof(struct iwreq)); memset(&wreq, 0, sizeof(struct iwreq));
wreq.u.essid.length = IW_ESSID_MAX_SIZE+1; wreq.u.essid.length = IW_ESSID_MAX_SIZE+1;
sprintf(wreq.ifr_name, iface); snprintf(wreq.ifr_name, ifrn_name, "%s", iface);
if (sockfd == -1) { if (sockfd == -1) {
warn("Failed to get ESSID for interface %s", iface); warn("Failed to get ESSID for interface %s", iface);
return smprintf("%s", UNKNOWN_STR); return smprintf("%s", UNKNOWN_STR);