From: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
To: Jonny Grant <jg@jguk.org>
Cc: mtk.manpages@gmail.com, linux-man <linux-man@vger.kernel.org>
Subject: Re: argz_create
Date: Mon, 26 Oct 2020 17:08:21 +0100 [thread overview]
Message-ID: <e795c4f3-e273-684a-012e-2b03d1f74285@gmail.com> (raw)
In-Reply-To: <c1b5cd3d-8be5-3845-1458-10d96ef29e11@jguk.org>
Hello Jonny,
On 10/26/20 3:18 PM, Jonny Grant wrote:
> Hello
>
> https://man7.org/linux/man-pages/man3/argz_create.3.html
>
> BUGS top
> Argz vectors without a terminating null byte may lead to Segmentation
> Faults.
>
> Doesn't feel like this is a BUG to me. Is there a better section to
> add this? Almost all string handling functions may cause SEGV if
> passed a string without a null byte. Or even being passed a NULL ptr
> like strlen(NULL).. I expect some of these may crash if passed
> NULL.
Take a look at this paragraph:
An argz vector is a pointer to a character buffer together with a
length. The intended interpretation of the character buffer is an
array of strings, where the strings are separated by null bytes
('\0'). If the length is nonzero, the last byte of the buffer
must be a null byte.
These functions have a surprising interface. The 'char **argz'
are pointers to pointers to character buffers that have the form:
...\0....\0...\0
That is, the buffers are not strings, but a series of strings laid end
to end. The text you referring to is trying to say that there better
be a '\0' t the end of the buffer... I'm not sure how necessary the
sentence is, but this is not like a typical string handling function.
(Probably
> May I ask if there is a way to link error_t to the definition, should
> be in errno.h
I don't quite understand what you are suggesting. Can you elaborate.
Thanks,
Michael
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
next prev parent reply other threads:[~2020-10-26 16:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-26 14:18 argz_create Jonny Grant
2020-10-26 16:08 ` Michael Kerrisk (man-pages) [this message]
2020-10-26 16:16 ` argz_create Michael Kerrisk (man-pages)
2020-10-26 21:12 ` argz_create Jonny Grant
2020-10-27 10:43 ` argz_create Jonny Grant
2020-10-27 13:01 ` argz_create Michael Kerrisk (man-pages)
2020-10-27 15:03 ` argz_create Jonny Grant
2020-10-27 15:47 ` argz_create Michael Kerrisk (man-pages)
2020-10-26 21:08 ` argz_create Jonny Grant
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=e795c4f3-e273-684a-012e-2b03d1f74285@gmail.com \
--to=mtk.manpages@gmail.com \
--cc=jg@jguk.org \
--cc=linux-man@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