netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chen Gang <gang.chen@asianux.com>
To: David Miller <davem@davemloft.net>
Cc: samuel@sortiz.org, netdev@vger.kernel.org
Subject: Re: [PATCH] net: irda: using kzalloc() instead of kmalloc() to avoid strncpy() issue.
Date: Mon, 20 May 2013 09:04:42 +0800	[thread overview]
Message-ID: <519976AA.2010901@asianux.com> (raw)
In-Reply-To: <20130519.151112.787320797896644755.davem@davemloft.net>

On 05/20/2013 06:11 AM, David Miller wrote:
> From: Chen Gang <gang.chen@asianux.com>
> Date: Fri, 17 May 2013 17:13:04 +0800
> 
>> > 
>> > 'discovery->data.info' length is 22, NICKNAME_MAX_LEN is 21, so the
>> > strncpy() will always left the last byte of 'discovery->data.info'
>> > uninitialized.
>> > 
>> > When 'text' length is longer than 21 (NICKNAME_MAX_LEN), if still left
>> > the last byte of 'discovery->data.info' uninitialized, the next
>> > strlen() will cause issue.
>> > 
>> > Also 'discovery->data' is 'struct irda_device_info' which defined in
>> > "include/uapi/...", it may copy to user mode, so need whole initialized.
>> > 
>> > All together, need use kzalloc() instead of kmalloc() to initialize all
>> > members firstly.
>> > 
>> > Signed-off-by: Chen Gang <gang.chen@asianux.com>
> Applied, thanks.
> 
> 

Thank you, too.


Thanks.
-- 
Chen Gang

Asianux Corporation

      reply	other threads:[~2013-05-20  1:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-17  9:13 [PATCH] net: irda: using kzalloc() instead of kmalloc() to avoid strncpy() issue Chen Gang
2013-05-19 22:11 ` David Miller
2013-05-20  1:04   ` Chen Gang [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=519976AA.2010901@asianux.com \
    --to=gang.chen@asianux.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=samuel@sortiz.org \
    /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).