From: raiz <raiz@firemail.cc>
Date: Tue, 27 Dec 2016 17:14:45 +0000 (+0300)
Subject: wifi_essid: add boundary check && prevent the use of direct string literal as a forma... 
X-Git-Url: https://git.xinqibao.xyz/slstatus.git/commitdiff_plain/94e87eb8baaf1c20d02602ba3d01bc1babdb2e35

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

diff --git a/slstatus.c b/slstatus.c
index 7b02205..c852b2f 100644
--- a/slstatus.c
+++ b/slstatus.c
@@ -717,7 +717,8 @@ wifi_essid(const char *iface)
 
 	memset(&wreq, 0, sizeof(struct iwreq));
 	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) {
 		warn("Failed to get ESSID for interface %s", iface);
 		return smprintf("%s", UNKNOWN_STR);