linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qiujun Huang <anenbupt@gmail.com>
To: syzbot <syzbot+df767d588771697b0433@syzkaller.appspotmail.com>
Cc: andreyknvl@google.com, devel@driverdev.osuosl.org,
	gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org, syzkaller-bugs@googlegroups.com,
	tranmanphong@gmail.com
Subject: Re: WARNING in hwahc_probe
Date: Sun, 22 Mar 2020 15:53:44 +0800	[thread overview]
Message-ID: <CADG63jBdvJMAem7_VF3GbCUSXGRuFrrv6_GqFc=KcKkxcNebCA@mail.gmail.com> (raw)
In-Reply-To: <0000000000001a033405a15e3acb@google.com>

The return value of snprintf is longer than expected if the string is
truncated. Bytes need to be checked here.

diff --git a/drivers/staging/wusbcore/host/hwa-hc.c
b/drivers/staging/wusbcore/host/hwa-hc.c
index 8d959e9..1475a48 100644
--- a/drivers/staging/wusbcore/host/hwa-hc.c
+++ b/drivers/staging/wusbcore/host/hwa-hc.c
@@ -680,10 +680,12 @@ static int hwahc_security_create(struct hwahc *hwahc)
                        break;
                }
                itr += etd->bLength;
-               bytes += snprintf(buf + bytes, sizeof(buf) - bytes,
-                                 "%s (0x%02x) ",
-                                 wusb_et_name(etd->bEncryptionType),
-                                 etd->bEncryptionValue);
+
+               if (sizeof(buf) > bytes)
+                       bytes += snprintf(buf + bytes, sizeof(buf) - bytes,
+                                       "%s (0x%02x) ",
+                                       wusb_et_name(etd->bEncryptionType),
+                                       etd->bEncryptionValue);
                wusbhc->ccm1_etd = etd;
        }
        dev_info(dev, "supported encryption types: %s\n", buf);

  reply	other threads:[~2020-03-22  7:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-21 14:29 WARNING in hwahc_probe syzbot
2020-03-22  7:53 ` Qiujun Huang [this message]
2020-03-22  7:58   ` Greg KH
2020-03-22  8:15     ` Qiujun Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADG63jBdvJMAem7_VF3GbCUSXGRuFrrv6_GqFc=KcKkxcNebCA@mail.gmail.com' \
    --to=anenbupt@gmail.com \
    --cc=andreyknvl@google.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=syzbot+df767d588771697b0433@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tranmanphong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).