]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
staging: rtl8192u: ieee80211: Replace snprintf with scnprintf
authorRohit Sarkar <rohitsarkar5398@gmail.com>
Tue, 10 Sep 2019 18:24:15 +0000 (23:54 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 30 Sep 2019 19:57:57 +0000 (21:57 +0200)
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 <rohitsarkar5398@gmail.com>
Link: https://lore.kernel.org/r/20190910182415.GA5768@SARKAR
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c

index 5c33bcb0db2eeaa5999dab6207235f295cb42d5a..00fea127bdc394e7530c971aaf91856cf81623e5 100644 (file)
@@ -1620,7 +1620,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
@@ -1647,7 +1647,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
index 9dd5c04181ea35b4d1d5732217cf74f11b14150d..33c596f9ec96cb9b0080b0880a11793183f12c97 100644 (file)
@@ -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;
@@ -214,7 +214,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)