From: Dan Carpenter <dan.carpenter@oracle.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Ivan Safonov <insafonov@gmail.com>,
devel@driverdev.osuosl.org, Bryan Paul <bryan.paul@yahoo.com>,
Vaishali Thakkar <vthakkar1994@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Larry Finger <Larry.Finger@lwfinger.net>
Subject: Re: [PATCH 2/3] staging: rtl8188eu: if/else replaced by min_t
Date: Sat, 7 Nov 2015 00:57:55 +0300 [thread overview]
Message-ID: <20151106215755.GC18797@mwanda> (raw)
In-Reply-To: <CAHp75Vfxw6U9xg3R3H3=H+0Gv7aZzK3SXC6v+owZa8wE996oEw@mail.gmail.com>
On Fri, Nov 06, 2015 at 11:42:50PM +0200, Andy Shevchenko wrote:
> On Fri, Nov 6, 2015 at 5:18 PM, Ivan Safonov <insafonov@gmail.com> wrote:
> > psecuritypriv->authenticator_ie[0] = (unsigned char)psecnetwork->IELength;
> >
> > - if ((psecnetwork->IELength-12) < (256-1))
> > - memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], psecnetwork->IELength-12);
> > - else
> > - memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], (256-1));
> > + memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], min_t(int, psecnetwork->IELength - 12, 256 - 1));
> >
>
> Run checkpatch.pl.
The long line was there in the original so it's forgivable but probably
should be changed in v2.
The main thing though is that this looks to introduce a memory
corruption but because the original used unsigned comparison and we have
changed it to doing "int" comparison. It should be u32 like in the
original code. Or size_t would be ok too.
>
> 256 looks like sizeof(…).
Yup.
regards,
dan carpenter
prev parent reply other threads:[~2015-11-06 21:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-06 15:18 [PATCH 2/3] staging: rtl8188eu: if/else replaced by min_t Ivan Safonov
2015-11-06 21:42 ` Andy Shevchenko
2015-11-06 21:57 ` Dan Carpenter [this message]
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=20151106215755.GC18797@mwanda \
--to=dan.carpenter@oracle.com \
--cc=Larry.Finger@lwfinger.net \
--cc=andy.shevchenko@gmail.com \
--cc=bryan.paul@yahoo.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=insafonov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vthakkar1994@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