Is this code safe:
strerror_r(errcode,buffer,length);
printf("Error: %s",buffer);
That is, can I trust buffer to be null terminated in case the buffer is to small? From the man page:
The XSI-compliant strerror_r() is preferred for portable applications. It returns the error string in the user-supplied buffer buf of length buflen.
The GNU-specific strerror_r() returns a pointer to a string containing the error message. This may be either a pointer to a string that the function stores in buf, or a pointer to some (immutable) static string (in which case buf is unused). If the function stores a string in buf, then at most buflen bytes are stored (the string may be truncated if buflen is too small and errnum is unknown). The string always includes a terminating null byte ('\0').
Am I right that if I use the XSI-compliant version, it may happen that buffer is not null terminated.