[PATCH] ieee802_1x: remove useless NULL terminations

Baruch Siach baruch
Thu Jul 5 07:21:07 PDT 2012


snprintf() is guaranteed to terminate its destination string.

Signed-hostap: Baruch Siach <baruch at tkos.co.il>
---
 src/ap/ieee802_1x.c |    3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/ap/ieee802_1x.c b/src/ap/ieee802_1x.c
index dd0df1d..7544027 100644
--- a/src/ap/ieee802_1x.c
+++ b/src/ap/ieee802_1x.c
@@ -482,7 +482,6 @@ static void ieee802_1x_encapsulate_radius(struct hostapd_data *hapd,
 
 	os_snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT ":%s",
 		    MAC2STR(hapd->own_addr), hapd->conf->ssid.ssid);
-	buf[sizeof(buf) - 1] = '\0';
 	if (!hostapd_config_get_radius_attr(hapd->conf->radius_auth_req_attr,
 					    RADIUS_ATTR_CALLED_STATION_ID) &&
 	    !radius_msg_add_attr(msg, RADIUS_ATTR_CALLED_STATION_ID,
@@ -493,7 +492,6 @@ static void ieee802_1x_encapsulate_radius(struct hostapd_data *hapd,
 
 	os_snprintf(buf, sizeof(buf), RADIUS_802_1X_ADDR_FORMAT,
 		    MAC2STR(sta->addr));
-	buf[sizeof(buf) - 1] = '\0';
 	if (!radius_msg_add_attr(msg, RADIUS_ATTR_CALLING_STATION_ID,
 				 (u8 *) buf, os_strlen(buf))) {
 		printf("Could not add Calling-Station-Id\n");
@@ -526,7 +524,6 @@ static void ieee802_1x_encapsulate_radius(struct hostapd_data *hapd,
 			    radius_sta_rate(hapd, sta) / 2,
 			    (radius_sta_rate(hapd, sta) & 1) ? ".5" : "",
 			    radius_mode_txt(hapd));
-		buf[sizeof(buf) - 1] = '\0';
 	}
 	if (!hostapd_config_get_radius_attr(hapd->conf->radius_auth_req_attr,
 					    RADIUS_ATTR_CONNECT_INFO) &&
-- 
1.7.10




More information about the Hostap mailing list