summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2005-04-11 18:34:10 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2005-04-11 18:34:10 +0000
commit5fd1dbf48cdd6b86eaa496175dac21435caff009 (patch)
treee34083bd58188abc4bd1ad851f0a668f27333c10 /lib
parent463dbb3ab54a29ffb2011e73fdca4dc52e4f162d (diff)
more snprintf return value sloppiness; ok otto
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/rpc/clnt_perror.c10
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);
}