From 468ac82c1212647ee6c31de7aaaa68bb87615efe Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Thu, 8 Mar 2001 03:27:26 +0000 Subject: [PATCH] fix last change, it was very broken git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13060 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/rpc/ChangeLog | 8 +++++--- src/lib/rpc/clnt_perror.c | 21 +++++++++------------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/lib/rpc/ChangeLog b/src/lib/rpc/ChangeLog index adca3e62b..423ea0c0a 100644 --- a/src/lib/rpc/ChangeLog +++ b/src/lib/rpc/ChangeLog @@ -1,10 +1,12 @@ 2001-03-07 Ken Raeburn * configure.in: Check for strerror. - * clnt_perror.c (strerror, sys_nerr) [!HAVE_STRERROR]: Define. - (sys_nerr) [HAVE_STRERROR]: Declare at top level instead of in + * clnt_perror.c (strerror) [!HAVE_STRERROR]: Define, with + out-of-range check using sys_nerr. + (sys_nerr) [!HAVE_STRERROR]: Declare at top level instead of in clnt_spcreateerror. - (clnt_sperror, clnt_spcreateerror): Use strerror always. + (clnt_sperror, clnt_spcreateerror): Use strerror always. Skip + range check. Sun Feb 18 17:48:35 2001 Ezra Peisach diff --git a/src/lib/rpc/clnt_perror.c b/src/lib/rpc/clnt_perror.c index 828f5a32f..7d05cc476 100644 --- a/src/lib/rpc/clnt_perror.c +++ b/src/lib/rpc/clnt_perror.c @@ -49,12 +49,9 @@ static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro"; #ifdef NEED_SYS_ERRLIST extern char *sys_errlist[]; #endif -#undef sys_nerr -#define sys_nerr 99999 /* XXX */ -#undef strerror -#define strerror(N) sys_errlist[N] -#else extern int sys_nerr; +#undef strerror +#define strerror(N) (((N) > 0 && (N) < sys_nerr) ? sys_errlist[N] : (char *)0) #endif /* HAVE_STRERROR */ static char *auth_errmsg(); @@ -276,14 +273,14 @@ clnt_spcreateerror(s) case RPC_SYSTEMERROR: (void) strncat(str, " - ", BUFSIZ - 1 - strlen(str)); - if (rpc_createerr.cf_error.re_errno > 0 - && rpc_createerr.cf_error.re_errno < sys_nerr) - (void) strncat(str, - strerror(rpc_createerr.cf_error.re_errno), - BUFSIZ - 1 - strlen(str)); - else + { + const char *m = strerror(rpc_createerr.cf_error.re_errno); + if (m) + (void) strncat(str, m, BUFSIZ - 1 - strlen(str)); + else (void) sprintf(&str[strlen(str)], "Error %d", - rpc_createerr.cf_error.re_errno); + rpc_createerr.cf_error.re_errno); + } break; } (void) strncat(str, "\n", BUFSIZ - 1 - strlen(str)); -- 2.26.2