cURL / Mailing Lists / curl-library / Single Mail


Re: strerror

From: Jeroen Koekkoek <>
Date: Sun, 06 Apr 2014 01:10:25 +0200


Fair enough. This is the response I got from UK Customer Support. The
MAXERRSTR_SIZE might have been available in previous versions of
VxWorks, I don't know, but it's not anymore. I think the comment should
be updated to at least reflect why a 256 byte buffer should be used, but
that's just my opinion. I just thought I'd let you guys know.

----- quote -----
Hi Jeroen,
I will be assisting on this question.
You don't say what OS/ compiler version you are using so I will show the
method as well as the answer....

Looking at vxWorks 6.9.3 the code for strerror_r (kernel version) is
located in target/src/libc/strerror.c

There we also see the descriptive comment block:
* strerror_r - map an error number to an error string
* This routine maps the error number in <errcode> to an error message
* It stores the error string in <buffer>. The size of <buffer> should
* NAME_MAX + 1 - using a smaller buffer may lead to stack corruption.
* is defined in limits.h.
And some further searching shows
#define NAME_MAX _PARM_NAME_MAX /* max filename length excluding
EOS */
#define _PARM_NAME_MAX 255

Therefore the maximum length will be 256.

It is also possible to get this by examining the code:
STATUS strerror_r
    int errcode, /* error code */
    char * buffer /* string buffer */
    char * str;

    if (buffer == NULL)
        return (ERROR);

    str = strerrorIf (errcode);

    if (str != NULL)
        strlcpy (buffer, str, (size_t) NAME_MAX + 1);
        snprintf (buffer, (size_t) NAME_MAX + 1, "errno = %#x",

    return (OK);
Where we clearly see the NAME_MAX+1 restriction on the strlcpy and
snprintf lines.

You should be able to apply the same techniques to whatever version you
have presuming you have source code. If you don't I can look if you
tell me the precise OS version & whether this is for kernel or RTP.

Please reply to say if this answer your question.
Best regards,
Robert Varley
----- /quote -----

Best regards,
Jeroen Koekkoek

On Sat, 2014-04-05 at 22:37 +0200, Daniel Stenberg wrote:
> On Sat, 5 Apr 2014, Jeroen Koekkoek wrote:
> > In your strerror function in cURL there is a quote that states the buffer
> > should be 150 bytes on VxWorks, this quote is incorrect. A buffer of 256 is
> > used, which is correct. You might want to update the quote. Please see
> >
> > for details.
> You referring to your own question and your own answer on stackoverflow is not
> a reliable source. This change was brought by a person who built and used
> libcurl on vxworks back in 2009.
> Also, please use the curl-library mailing list for libcurl discussions.
> --
> /

List admin:
Received on 2014-04-06