linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: bill o gallmeister <bgallmeister-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Bob Eggers <Bob.Eggers-C65YXLrEp3M@public.gmane.org>
Cc: "mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
	<mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re:
Date: Mon, 21 Jun 2010 14:05:53 -0700	[thread overview]
Message-ID: <4C1FD431.6030505@gmail.com> (raw)
In-Reply-To: <460216361116404BB61933403540E169B645A3E596@ushqwmb03>

I believe that's the correct result for a NULL-terminated string of length 1.

- bog

On 06/21/2010 01:30 PM, Bob Eggers wrote:
> I noticed an error in and example on the man page for strncpy(). The page is http://www.kernel.org/doc/man-pages/online/pages/man3/strncpy.3.html
> 
> The error is in the section, "NOTES", specifically in the code example after the text:
> 
>       If there is no terminating null byte in the first n characters of src,
>        strncpy() produces an unterminated string in dest.  Programmers often prevent
>        this mistake by forcing termination as follows:
> 
>            strncpy(buf, str, n);
>            if (n > 0)
>                buf[n - 1]= '\0';
> 
> Substituting 1 for n and "123" for str, this would equate to:
> 
>            strncpy(buf, "123", 1);  // buf is now "1"
>            if (1 > 0)
>                buf[1 - 1]= '\0';                // buf is now ""
> 
> Bob Eggers--
> To unsubscribe from this list: send the line "unsubscribe linux-man" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


-- 
Bill O. Gallmeister
bgallmeister-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
http://geekwhisperer.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2010-06-21 21:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-21 20:30 (unknown), Bob Eggers
2010-06-21 21:05 ` bill o gallmeister [this message]
     [not found]   ` <4C1FD431.6030505-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-06-26 12:52     ` Michael Kerrisk
2017-02-23 15:09 Qin's Yanjun
2017-05-04 23:57 Tammy
2017-11-13 14:55 Re: Amos Kalonzo
     [not found] <CAGkTAxsV0zS_E64criQM-WtPKpSyW2PL=+fjACvnx2=m7piwXg@mail.gmail.com>
2019-09-27  6:37 ` Re: Michael Kerrisk (man-pages)
     [not found] <60a57e3a.lbqA81rLGmtH2qoy%Radisson97@gmx.de>
2021-05-21 11:04 ` Re: Alejandro Colomar (man-pages)
     [not found] <20230122193117.GA28689@Debian-50-lenny-64-minimal>
2023-01-22 21:42 ` Re: Alejandro Colomar
2023-01-24 20:01   ` Re: Helge Kreutzmann

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=4C1FD431.6030505@gmail.com \
    --to=bgallmeister-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=Bob.Eggers-C65YXLrEp3M@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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).