diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2005-04-20 23:38:16 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2005-04-20 23:38:16 +0000 |
commit | da604ac236ca0a40f0028a11b20354d60a9d23e6 (patch) | |
tree | 28d2df24d2b7d14d69adff8b72d638883bdafa3b | |
parent | b2256b26aef1dd6922a1ba3d5d97f73e9725aae5 (diff) |
correct strlcpy abuse
ok millert@
-rw-r--r-- | lib/libc/string/strerror_r.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/libc/string/strerror_r.c b/lib/libc/string/strerror_r.c index db264bcf505..c0ca434cbde 100644 --- a/lib/libc/string/strerror_r.c +++ b/lib/libc/string/strerror_r.c @@ -1,8 +1,8 @@ -/* $OpenBSD: strerror_r.c,v 1.2 2004/05/03 05:07:34 espie Exp $ */ +/* $OpenBSD: strerror_r.c,v 1.3 2005/04/20 23:38:15 beck Exp $ */ /* Public Domain <marc@snafu.org> */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: strerror_r.c,v 1.2 2004/05/03 05:07:34 espie Exp $"; +static char *rcsid = "$OpenBSD: strerror_r.c,v 1.3 2005/04/20 23:38:15 beck Exp $"; #endif /* LIBC_SCCS and not lint */ #ifdef NLS @@ -107,8 +107,12 @@ strerror_r(int errnum, char *strerrbuf, size_t buflen) #else len = strlcpy(strerrbuf, UPREFIX, buflen); #endif - __itoa(errnum, strerrbuf, len, buflen); - ret_errno = EINVAL; + if (len >= buflen) + ret_errno = ERANGE; + else { + __itoa(errnum, strerrbuf, len, buflen); + ret_errno = EINVAL; + } } #ifdef NLS |