Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Dec 2001 22:12:13 -0500
From:      Garance A Drosihn <drosih@rpi.edu>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        standards@FreeBSD.ORG
Subject:   Re: strerror_r() implementation
Message-ID:  <p05101002b8309917497e@[128.113.24.47]>
In-Reply-To: <20011203005459.N8502-100000@gamplex.bde.org>
References:  <20011203005459.N8502-100000@gamplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
At 1:14 AM +1100 12/3/01, Bruce Evans wrote:
>On Sat, 1 Dec 2001, Garance A Drosihn wrote:
>  > Hmm.  I do not have the standards document for strerror_r(), but I am
>>  surprised that a short buffer is expected to return a string which is
>>  not null-terminated.  Note that I am not arguing the point, I'm just
>>  surprised.  That means all callers to strerror_r() should never treat
>>  the result as a null-terminated string, even though it usually will
>>  be null-terminated.  Seems to me that is asking for trouble.
>
>I think the contents of the buffer is indeterminate when strerror_r()
>fails.  POSIX-1.200x-draft7 is not completely clear on this.

Hmm.  Should we bug someone to make that more explicit, at least for
the case of a truncated message?  I just have this fear that some OS's
will implement truncated messages to always include the terminating
null, and others will prefer to put one extra byte of the error msg
into the buffer.  Programs written on the OS which chooses the first
behavior might then run into trouble on the second group of OS's.

I don't mind too much which is chosen, but it seems to me it would be
safer to have the behavior stated explicitly in the standard.

Well, I guess I should admit that would prefer that the msg was always
terminated with a null, but I wouldn't mind if the standard explicitly
stated that a truncated message will not include a null.

-- 
Garance Alistair Drosehn            =   gad@eclipse.acs.rpi.edu
Senior Systems Programmer           or  gad@freebsd.org
Rensselaer Polytechnic Institute    or  drosih@rpi.edu

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-standards" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p05101002b8309917497e>