diff options
author | 2005-04-11 18:34:09 +0000 | |
---|---|---|
committer | 2005-04-11 18:34:09 +0000 | |
commit | 704fb109a00ac7e16db43a796b758ad2384e7598 (patch) | |
tree | a0344d202d8223191123d65fac82e459d1e08565 /lib | |
parent | don't include sysexits.h now we don't use those error codes (diff) | |
download | wireguard-openbsd-704fb109a00ac7e16db43a796b758ad2384e7598.tar.xz wireguard-openbsd-704fb109a00ac7e16db43a796b758ad2384e7598.zip |
more snprintf return value sloppiness; ok otto
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/rpc/clnt_perror.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/libc/rpc/clnt_perror.c b/lib/libc/rpc/clnt_perror.c index 984ccc7b7f6..a50b4f61f0e 100644 --- a/lib/libc/rpc/clnt_perror.c +++ b/lib/libc/rpc/clnt_perror.c @@ -28,7 +28,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: clnt_perror.c,v 1.16 2005/04/01 07:44:03 otto Exp $"; +static char *rcsid = "$OpenBSD: clnt_perror.c,v 1.17 2005/04/11 18:34:09 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -77,6 +77,8 @@ clnt_sperror(CLIENT *rpch, char *s) ret = snprintf(str, len, "%s: %s", s, clnt_sperrno(e.re_status)); if (ret == -1) ret = 0; + else if (ret >= len) + ret = len; str += ret; len -= ret; if (str > strstart + CLNT_PERROR_BUFLEN) @@ -112,15 +114,17 @@ clnt_sperror(CLIENT *rpch, char *s) ret = snprintf(str, len, "; why = "); if (ret == -1) ret = 0; + else if (ret >= len) + ret = len; str += ret; len -= ret; if (str > strstart + CLNT_PERROR_BUFLEN) goto truncated; err = auth_errmsg(e.re_why); if (err != NULL) { - ret = snprintf(str, len, "%s\n", err); + snprintf(str, len, "%s\n", err); } else { - ret = snprintf(str, len, + snprintf(str, len, "(unknown authentication error - %d)\n", (int) e.re_why); } |