All of lore.kernel.org
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] critical bug in strncpy() - solved
Date: Tue, 29 Mar 2005 07:19:44 +0000	[thread overview]
Message-ID: <42490190.5090703@bfs.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 790 bytes --]

mea culpa,
for some odd reason i did not see "the dest will be padded with nulls."
i will send a fix for the documentation to the mainling list.

re,
walter


Matthew Wilcox wrote:
> There is no bug in lib/string.c's implementation of strncpy().
> Most people do not realise that strncpy is a stupid function that is
> almost impossible to use correctly.  Read the manpage:
> 
>        The strncpy() function is similar, except that not more than n bytes of
>        src  are copied. Thus, if there is no null byte among the first n bytes
>        of src, the result will not be null-terminated.
> 
>        In the case where the length of src is less than that of n, the remain-
>        der of dest will be padded with nulls.
> 
> This agrees with POSIX, ANSI C and Single Unix, fwiw.
> 

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

                 reply	other threads:[~2005-03-29  7:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=42490190.5090703@bfs.de \
    --to=wharms@bfs.de \
    --cc=kernel-janitors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.