Re: argz_create

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux