Date: Thu, 6 Dec 2001 19:46:04 +1100 (EST) From: Bruce Evans <bde@zeta.org.au> To: Wes Peters <wes@softweyr.com> Cc: Bill Fenner <fenner@research.att.com>, <mike@FreeBSD.org>, <freebsd-standards@bostonradio.org> Subject: Re: strerror_r() implementation Message-ID: <20011206192801.M14527-100000@gamplex.bde.org> In-Reply-To: <3C0C77B8.26C050B0@softweyr.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 4 Dec 2001, Wes Peters wrote: > int > strerror_r(int errnum, char *strerrbuf, size_t buflen) > { > unsigned int uerr; > char *p, *t; > char tmp[NUMSTRINGLEN]; > int len; > > uerr = errnum; > if (uerr < sys_nerr) { > len = strlcpy(strerrbuf, (char *)sys_errlist[uerr], buflen); > return (len <= buflen) ? 0 : ERANGE; > } I just noticed a non-cosmetic bug (which is also in 1.5, later mail, and 1.6). The check of strlcpy()'s return value is of by 1. This causes truncated messages. E.g., char buf[23]; strerror_r(1, buf, 23) writes "Operation not permitte" in buf and bogusly succeeds. STANDALONE_TEST doesn't go near this since it always uses a large enough buffer. Bruce 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?20011206192801.M14527-100000>