linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andries Brouwer <aebr@win.tue.nl>
To: Petr Vandrovec <vandrove@vc.cvut.cz>
Cc: John Belmonte <jvb@prairienet.org>,
	Ben Collins <bcollins@debian.org>,
	Linus Torvalds <torvalds@osdl.org>,
	linux-kernel@vger.kernel.org, acpi-devel@lists.sourceforge.net,
	Michael Wawrzyniak <gan@planetlaz.com>
Subject: Re: [PATCH] bad strlcpy conversion breaks toshiba_acpi
Date: Fri, 25 Jul 2003 18:57:09 +0200	[thread overview]
Message-ID: <20030725165709.GA670@win.tue.nl> (raw)
In-Reply-To: <20030725161510.GA31565@vana.vc.cvut.cz>

On Fri, Jul 25, 2003 at 06:15:10PM +0200, Petr Vandrovec wrote:

> Nope. Kernel strlcpy implementation is crap and I do not believe that there
> is single place in the kernel which can live with current implementation. 
> 
> Take a look at ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/strlcpy.c 
> or at http://www.courtesan.com/todd/papers/strlcpy.html - it copies
> at most size-1 characters. Nothing about characters beyond specified size 
> in the article.
> 
> Kernel should use strnlen() to get string length, if coding loop like
> OpenBSD does is unacceptable.

strlcpy is for strings, not for character arrays.
The *BSD version accesses the source past the size-1 characters that are copied:
	while (*s++)
		;
Thus, replacing strncpy (used to copy character arrays, possibly not 0-terminated)
by strlcpy is wrong.


  reply	other threads:[~2003-07-25 16:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-25 14:46 [PATCH] bad strlcpy conversion breaks toshiba_acpi John Belmonte
2003-07-25 16:15 ` Petr Vandrovec
2003-07-25 16:57   ` Andries Brouwer [this message]
2003-07-27 21:02     ` [ACPI] " Matthew Wilcox
2003-07-27 21:26       ` M. Warner Losh

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=20030725165709.GA670@win.tue.nl \
    --to=aebr@win.tue.nl \
    --cc=acpi-devel@lists.sourceforge.net \
    --cc=bcollins@debian.org \
    --cc=gan@planetlaz.com \
    --cc=jvb@prairienet.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=vandrove@vc.cvut.cz \
    /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).