On 26/10/2020 16:08, Michael Kerrisk (man-pages) wrote: > 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 Yes, it's a kind of serialised buffer right? using the '\0' to denote the end of each. I'm sure everyone would '\0' terminate the end.. I saw strcpy has a similar warning BUGS, so actually that looks fine. Jonny