Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6036961ybe; Tue, 10 Sep 2019 12:31:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOQaPF7VDD1gUfQWmd1loXuYwBf9mxWPnx0oJFkd6gCrYoiMnLGXh2qS3OX9wbU5yJsmLZ X-Received: by 2002:a17:906:5915:: with SMTP id h21mr25806889ejq.28.1568143886956; Tue, 10 Sep 2019 12:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568143886; cv=none; d=google.com; s=arc-20160816; b=G+NDxTpSOFsGJwpzsXdyA8opkEZft29hEJYM1DOCqj0+QkBsRcT3tJfklmXFREhCZT kmTi6aXPZlFbPgkvWhgnJgPdvB3G1OVYRSySxEdNwidgwmquEFx+XVDkyiLwZ/I3OaTi qACWUFcgFiQOg5F8WzVUczQ5E2BnM/2L1UdhZszdnSrqeVd2itmmj/hEFxolsRTCsmLD J7fMklXCBVfctzhfBFBkD+PuBlPHDEmFqNhHVSZyQ0KNJ8CU8VksYX7ER9w9ig6kM05S XxywN9UZ2rxc5p5PY7WoeMQC/yHXvSPd74TX+hTV1MPRjX5Jp/v+tqUPAJArLuQcMMdT NpZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=0I346vx91sUiAeUkNi54oztkGxRJ6TRG5+oqyFk02bY=; b=rRoba1BJZp2nn4Iva4GhkhYXrXPoNPaXgsneylwA+lC7GSYbP1NOYd1wneUHR+pcdH 4VC8jh1knCxssR9QA1dkAPPvQwWeXMSitXwfoICXQBfgLnaN+X4spgB55fQUG2kmogpt 1hKBpg8vfz223AUr8ch83OpLM7QvA5BM5XrykXcJwYeOmapd2WfEyMYMJC48J64l4fgH BU45DKDIY9um6VuY8kUUZ2Ps8OKrge9CdD6d33EswNtGmLivtURC4/F/hJb9vT5iKi2P uJWtKv8MeBGWh4sswxFGqAjf+0gFrzmeyi7neWRHu5pIcNTI7bM1TcC1DgFdbAnMUfXO 7kfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Tek+1Zjh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j18si10058844ejb.240.2019.09.10.12.31.03; Tue, 10 Sep 2019 12:31:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Tek+1Zjh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728232AbfIJSYW (ORCPT + 99 others); Tue, 10 Sep 2019 14:24:22 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42280 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726613AbfIJSYW (ORCPT ); Tue, 10 Sep 2019 14:24:22 -0400 Received: by mail-pg1-f195.google.com with SMTP id p3so10151777pgb.9 for ; Tue, 10 Sep 2019 11:24:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=0I346vx91sUiAeUkNi54oztkGxRJ6TRG5+oqyFk02bY=; b=Tek+1ZjhvQoukKmunz9oWSi7ehimuA5KNE4USUlNH47zOHVd7hK0lshi8vdBQQkbft Y+iykjcmDFByvT0DrQj25tk3pbgmrZ1AcmvSU8+8z2lSWZLPwQWvSuVxWC21ApMyga2A yG+q1sDyeQ6DN+YIJUtFgFBoE3iV+h8EvN++Y3O+9vAiayxcmUZwiloMHp0ijIqcaF0r Hy1BK9ziX1IvLaq7/XZ5KN9NmyX+QBXkuIlC665PpUyuLLdIVS8LHHvCVe9DEuNUxJtE UuW59djanWpWgRWGAdhnyGGGyTKYYvRDzhuPP6gynSHQZGjd208Vs/hTeflWpKMNYWt/ nv8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=0I346vx91sUiAeUkNi54oztkGxRJ6TRG5+oqyFk02bY=; b=IhKCtaBQdbOFQFkA0u6ZFep7VHeRyjZGx68FcRPbUDo4IHHQGKK3JdPrw6kUDVWcU5 XLaDR9eDWueuQt4Z/eJ5jnkJ45PuJSdmdbkMRfCsIuj8N5vmwiRd46XK1KOPQfi1UAyi 47bixa4cY1Sht+lzEAO7MWJZPT497EaeJuOAwtuxQHYVFR7r1FKrgQlx3ZMtjM9Ec6FT +vDBQ+SPzBnV0/mt4GOFHpnsSlUGUyVuWsoVdbICGz4HYjC7ZZ5xbBJYP9nfI3pjrMIc EXScZCqFc50FZO/eEteUucMepefSapJAKc5sBJoy4wyKi87w4ngnqETTVSd2i/ACZVWd 9P3g== X-Gm-Message-State: APjAAAUkxOhbQIyASGuxh9tLzS4Du2e2bNVts7EBMJ3SVpcXyGexhKCs NW+2C9+GZN51nqI9N8Ly3N1GF9X0LG493A== X-Received: by 2002:a17:90a:1c01:: with SMTP id s1mr930789pjs.76.1568139861681; Tue, 10 Sep 2019 11:24:21 -0700 (PDT) Received: from SARKAR ([1.186.12.73]) by smtp.gmail.com with ESMTPSA id u1sm14384025pgi.28.2019.09.10.11.24.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2019 11:24:21 -0700 (PDT) Date: Tue, 10 Sep 2019 23:54:15 +0530 From: Rohit Sarkar To: gregkh@linuxfoundation.org, johnfwhitmore@gmail.com, devel@driverdev.osuosl.org Cc: rohitsarkar5398@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH] staging: rtl8192u: ieee80211: Replace snprintf with scnprintf Message-ID: <20190910182415.GA5768@SARKAR> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 ++-- drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 0a3e478fccd6..b0a78508f378 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -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 diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c index be08cd1d37a7..8f378ba0e62a 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c @@ -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) -- 2.17.1