diff options
author | Mike Barcroft <mike@FreeBSD.org> | 2003-01-03 16:44:42 +0000 |
---|---|---|
committer | Mike Barcroft <mike@FreeBSD.org> | 2003-01-03 16:44:42 +0000 |
commit | e37f8b53130555dfa87abcb3d1acfc9676b44410 (patch) | |
tree | dcc6f1181fe4e0351288beb4d4f7f4524488e537 /lib/libc/string/strerror.c | |
parent | 42c43e6031ccea7e2e8c0bd974f882df60731e44 (diff) |
Notes
Diffstat (limited to 'lib/libc/string/strerror.c')
-rw-r--r-- | lib/libc/string/strerror.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/libc/string/strerror.c b/lib/libc/string/strerror.c index 428ff3865d5a..02fba0cfcd39 100644 --- a/lib/libc/string/strerror.c +++ b/lib/libc/string/strerror.c @@ -57,22 +57,20 @@ __FBSDID("$FreeBSD$"); static void errstr(int num, char *buf, size_t len) { - char *p, *t; + char *t; unsigned int uerr; char tmp[EBUFSIZE]; - if (strlcpy(buf, UPREFIX, len) >= len) - return; - t = tmp; + t = tmp + sizeof(tmp); + *--t = '\0'; uerr = (num >= 0) ? num : -num; do { - *t++ = "0123456789"[uerr % 10]; + *--t = "0123456789"[uerr % 10]; } while (uerr /= 10); if (num < 0) - *t++ = '-'; - for (p = buf + sizeof(UPREFIX) - 1; t > tmp && p < buf + len - 1;) - *p++ = *--t; - *p = '\0'; + *--t = '-'; + strlcpy(buf, UPREFIX, len); + strlcat(buf, t, len); } int |