staging: rtl8192u: ieee80211: Replace snprintf with scnprintf
PATCH 1/1 staging: rtl8192u: ieee80211: Replace snprintf with scnprintf
When the number of bytes to be printed exceeds the limit snprintf returns the number of bytes that would have been printed (if there was no truncation). This might cause issues, hence use scnprintf which returns the actual number of bytes printed to buffer always.
Signed-off-by Rohit Sarkar <[email protected]>
--- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 ++-- drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +2 -2
@@ -1647,7 +1647,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,for (i =0 ; i < network->rates_len; i++) { network->rates[i] = info_element->data[i];#ifdef CONFIG_IEEE80211_DEBUG - p +=snprintf (p,sizeof (rates_str) - + p +=scnprintf (p,sizeof (rates_str) - (p - rates_str),"%02X " , network->rates[i]);#endif
@@ -1674,7 +1674,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee,for (i =0 ; i < network->rates_ex_len; i++) { network->rates_ex[i] = info_element->data[i];#ifdef CONFIG_IEEE80211_DEBUG - p +=snprintf (p,sizeof (rates_str) - + p +=scnprintf (p,sizeof (rates_str) - (p - rates_str),"%02X " , network->rates_ex[i]);#endif
drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +4 -4
@@ -109,7 +109,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,/* Add basic and extended rates */ max_rate =0 ; p = custom; - p +=snprintf (p,MAX_CUSTOM_LEN - (p - custom)," Rates (Mb/s): " ); + p +=scnprintf (p,MAX_CUSTOM_LEN - (p - custom)," Rates (Mb/s): " );for (i =0 , j =0 ; i < network->rates_len; ) { if (j < network->rates_ex_len && ((network->rates_ex[j] & 0x7F) <
@@ -119,12 +119,12 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, rate = network->rates[i++] &0x7F ;if (rate > max_rate) max_rate = rate; - p +=snprintf (p,MAX_CUSTOM_LEN - (p - custom), + p +=scnprintf (p,MAX_CUSTOM_LEN - (p - custom),"%d%s " , rate >>1 , (rate &1 ) ?".5" :"" ); }for (; j < network->rates_ex_len; j++) { rate = network->rates_ex[j] &0x7F ; - p +=snprintf (p,MAX_CUSTOM_LEN - (p - custom), + p +=scnprintf (p,MAX_CUSTOM_LEN - (p - custom),"%d%s " , rate >>1 , (rate &1 ) ?".5" :"" );if (rate > max_rate) max_rate = rate;
@@ -215,7 +215,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee,* for given network. */ iwe.cmd =IWEVCUSTOM ; p = custom; - p +=snprintf (p,MAX_CUSTOM_LEN - (p - custom), + p +=scnprintf (p,MAX_CUSTOM_LEN - (p - custom)," Last beacon: %lums ago" , (jiffies - network->last_scanned) / (HZ /100 )); iwe.u.data.length = p - custom;if (iwe.u.data.length)
Signature · 1 line
2.17.1