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>
#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();
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));