linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Murray J. Root" <murrayr@brain.org>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2.6]: IPv6: strcpy -> strlcpy
Date: Thu, 27 Nov 2003 16:14:00 -0500	[thread overview]
Message-ID: <20031127211400.GD1560@Master> (raw)
In-Reply-To: <20031128.054724.116712136.yoshfuji@linux-ipv6.org>

On Fri, Nov 28, 2003 at 05:47:24AM +0900, YOSHIFUJI Hideaki / ?$B5HF#1QL@ wrote:
> In article <20031127200041.B25015@flint.arm.linux.org.uk> (at Thu, 27 Nov 2003 20:00:41 +0000), Russell King <rmk+lkml@arm.linux.org.uk> says:
> 
> > The thing that worries me is that an incorrect strlcpy() conversion
> > gives the impression that someone has thought about buffer underruns
> > as well as overruns, and, unless someone /has/ actually thought about
> > it, there could well still be a security problem lurking there.
> 
> Hmm, what do you actually mean by "buffer underruns?"
> 
> (If I'm correct) do you suggest that we should zero-out rest of 
> destination buffer?
> 
> if so, we may want to have a function, say strlcpy0(), like this:
> 
> size_t strlcpy0(char *dst, const char *src, size_t maxlen)
> {
>   size_t len = strlcpy(dst, src, maxlen);
>   if (maxlen && len < maxlen - 1)
>     memset(dst + len + 1, 0, maxlen - len - 1);
>   return len;
> }
> 

size_t strlcpy0(char *dst, const char *src, size_t maxlen)
{
  memset(dst, 0, maxlen);
  size_t len = strlcpy(dst, src, maxlen);
  return len;
}

-- 
Murray J. Root


  reply	other threads:[~2003-11-27 21:14 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-27  8:14 [PATCH 2.6]: IPv6: strcpy -> strlcpy Felipe Alfaro Solana
2003-11-27  8:33 ` YOSHIFUJI Hideaki / 吉藤英明
2003-11-27 10:59   ` David S. Miller
2003-11-27 12:04     ` Felipe Alfaro Solana
2003-11-27 12:09       ` YOSHIFUJI Hideaki / 吉藤英明
2003-11-27 19:46         ` Russell King
2003-11-27 19:54           ` YOSHIFUJI Hideaki / 吉藤英明
2003-11-27 20:00             ` Russell King
2003-11-27 20:47               ` YOSHIFUJI Hideaki / 吉藤英明
2003-11-27 21:14                 ` Murray J. Root [this message]
2003-11-27 22:06               ` Felipe Alfaro Solana
2003-11-27 22:19                 ` Russell King
2003-11-27 22:33                   ` Russell King
2003-11-28  1:34                     ` Mitchell Blank Jr
2003-11-27 23:03                   ` Felipe Alfaro Solana
2003-11-28  0:23                     ` YOSHIFUJI Hideaki / 吉藤英明
2003-11-28  0:26                       ` YOSHIFUJI Hideaki / 吉藤英明
2003-11-28  0:40                         ` YOSHIFUJI Hideaki / 吉藤英明
2003-11-28 11:22                           ` Jörn Engel
     [not found] <Wt8p.1R5.13@gated-at.bofh.it>
     [not found] ` <Wti7.2fc.19@gated-at.bofh.it>
     [not found]   ` <WAjQ.83K.37@gated-at.bofh.it>
     [not found]     ` <WAte.8iX.5@gated-at.bofh.it>
     [not found]       ` <WACW.a9.19@gated-at.bofh.it>
     [not found]         ` <WCuZ.2Tm.11@gated-at.bofh.it>
     [not found]           ` <WCOd.3u0.1@gated-at.bofh.it>
2003-11-28 14:04             ` Ihar 'Philips' Filipau

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=20031127211400.GD1560@Master \
    --to=murrayr@brain.org \
    --cc=linux-kernel@vger.kernel.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).