diff options
Diffstat (limited to 'lib/libc/rpc')
-rw-r--r-- | lib/libc/rpc/clnt_perror.c | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/lib/libc/rpc/clnt_perror.c b/lib/libc/rpc/clnt_perror.c index e0043e6d8c4..14656344c4d 100644 --- a/lib/libc/rpc/clnt_perror.c +++ b/lib/libc/rpc/clnt_perror.c @@ -5,30 +5,30 @@ * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. - * + * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * + * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. - * + * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. - * + * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. - * + * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: clnt_perror.c,v 1.5 1996/12/19 18:38:40 deraadt Exp $"; +static char *rcsid = "$OpenBSD: clnt_perror.c,v 1.6 1997/01/21 06:07:22 millert Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -76,14 +76,15 @@ clnt_sperror(rpch, s) return (0); CLNT_GETERR(rpch, &e); - (void) sprintf(str, "%s: %s", s, clnt_sperrno(e.re_status)); + (void) snprintf(str, CLNT_PERROR_BUFLEN, "%s: %s", s, + clnt_sperrno(e.re_status)); str += strlen(str); switch (e.re_status) { case RPC_SUCCESS: case RPC_CANTENCODEARGS: case RPC_CANTDECODERES: - case RPC_TIMEDOUT: + case RPC_TIMEDOUT: case RPC_PROGUNAVAIL: case RPC_PROCUNAVAIL: case RPC_CANTDECODEARGS: @@ -102,40 +103,42 @@ clnt_sperror(rpch, s) break; case RPC_VERSMISMATCH: - (void) sprintf(str, - "; low version = %lu, high version = %lu\n", + (void) snprintf(str, CLNT_PERROR_BUFLEN - (str - strstart), + "; low version = %lu, high version = %lu\n", e.re_vers.low, e.re_vers.high); break; case RPC_AUTHERROR: err = auth_errmsg(e.re_why); - (void) sprintf(str, "; why = "); + (void) snprintf(str, CLNT_PERROR_BUFLEN - (str - strstart), + "; why = "); str += strlen(str); if (err != NULL) { - (void) sprintf(str, "%s\n", err); + (void) snprintf(str, CLNT_PERROR_BUFLEN - + (str - strstart), "%s\n", err); } else { - (void) sprintf(str, + (void) snprintf(str, CLNT_PERROR_BUFLEN - + (str - strstart), "(unknown authentication error - %d)\n", (int) e.re_why); } break; case RPC_PROGVERSMISMATCH: - (void) sprintf(str, + (void) snprintf(str, CLNT_PERROR_BUFLEN - (str - strstart), "; low version = %lu, high version = %lu\n", e.re_vers.low, e.re_vers.high); break; default: /* unknown */ - (void) sprintf(str, + (void) snprintf(str, CLNT_PERROR_BUFLEN - (str - strstart), "; s1 = %lu, s2 = %lu\n", e.re_lb.s1, e.re_lb.s2); - str += strlen(str); break; } strstart[CLNT_PERROR_BUFLEN-2] = '\n'; strstart[CLNT_PERROR_BUFLEN-1] = '\0'; - return(strstart); + return (strstart) ; } void @@ -143,7 +146,7 @@ clnt_perror(rpch, s) CLIENT *rpch; char *s; { - (void) fprintf(stderr,"%s\n",clnt_sperror(rpch,s)); + (void) fprintf(stderr, "%s\n", clnt_sperror(rpch, s)); } static const char *const rpc_errlist[] = { @@ -187,7 +190,7 @@ void clnt_perrno(num) enum clnt_stat num; { - (void) fprintf(stderr,"%s\n",clnt_sperrno(num)); + (void) fprintf(stderr, "%s\n", clnt_sperrno(num)); } @@ -198,18 +201,21 @@ clnt_spcreateerror(s) char *str = _buf(); if (str == 0) - return(0); + return (0); + switch (rpc_createerr.cf_stat) { case RPC_PMAPFAILURE: (void) snprintf(str, CLNT_PERROR_BUFLEN, "%s: %s - %s\n", s, clnt_sperrno(rpc_createerr.cf_stat), clnt_sperrno(rpc_createerr.cf_error.re_status)); break; + case RPC_SYSTEMERROR: (void) snprintf(str, CLNT_PERROR_BUFLEN, "%s: %s - %s\n", s, clnt_sperrno(rpc_createerr.cf_stat), strerror(rpc_createerr.cf_error.re_errno)); break; + default: (void) snprintf(str, CLNT_PERROR_BUFLEN, "%s: %s\n", s, clnt_sperrno(rpc_createerr.cf_stat)); @@ -224,7 +230,7 @@ void clnt_pcreateerror(s) char *s; { - (void) fprintf(stderr,"%s\n",clnt_spcreateerror(s)); + (void) fprintf(stderr, "%s\n", clnt_spcreateerror(s)); } static const char *const auth_errlist[] = { @@ -247,5 +253,5 @@ auth_errmsg(stat) if (errnum < (sizeof(auth_errlist)/sizeof(auth_errlist[0]))) return (char *)auth_errlist[errnum]; - return(NULL); + return (NULL); } |