fix last change, it was very broken
authorKen Raeburn <raeburn@mit.edu>
Thu, 8 Mar 2001 03:27:26 +0000 (03:27 +0000)
committerKen Raeburn <raeburn@mit.edu>
Thu, 8 Mar 2001 03:27:26 +0000 (03:27 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13060 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/rpc/ChangeLog
src/lib/rpc/clnt_perror.c

index adca3e62b5184b0d351c56ca620ff6fe63c4cd98..423ea0c0a75b3a18c5138aee8226278a268ebb09 100644 (file)
@@ -1,10 +1,12 @@
 2001-03-07  Ken Raeburn  <raeburn@mit.edu>
 
        * 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  <epeisach@kangaroo.mit.edu>
 
index 828f5a32f4780f704d07a4d735df94a64825b844..7d05cc476f735ce3fda59c72bc5aea908adda230 100644 (file)
@@ -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));