From: Andreas Gustafsson Date: Mon, 22 Oct 2001 23:28:26 +0000 (+0000) Subject: pullup: X-Git-Tag: v9.2.0rc8~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a78ccdf1f6bef69b31f70351310bd5caaeb6b78;p=thirdparty%2Fbind9.git pullup: 1068. [bug] errno could be overwritten by catgets(). [RT #1921] 1066. [bug] Provide a thread safe wrapper for strerror(). [RT #1689] (Also some changes to configure.in, config.h.in, and acconfig.h that were necessary to allow config.h.in to be correctly regenerated with the HAVE_STRERROR definition needed by 1066.) --- diff --git a/CHANGES b/CHANGES index bb5fb7bb4da..8a5247ffe5f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +1068. [bug] errno could be overwritten by catgets(). [RT #1921] + +1066. [bug] Provide a thread safe wrapper for strerror(). + [RT #1689] + 1064. [bug] Do not shut down active network interfaces if we are unable to scan the interface list. [RT #1921] diff --git a/acconfig.h b/acconfig.h index cd3877bc0fd..f1df4cda48a 100644 --- a/acconfig.h +++ b/acconfig.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: acconfig.h,v 1.35 2001/07/14 01:55:04 gson Exp $ */ +/* $Id: acconfig.h,v 1.35.2.1 2001/10/22 23:28:07 gson Exp $ */ /*** *** This file is not to be included by any public header files, because @@ -23,6 +23,9 @@ ***/ @TOP@ +/* define to `int' if doesn't define. */ +#undef ssize_t + /* define on DEC OSF to enable 4.4BSD style sa_len support */ #undef _SOCKADDR_LEN @@ -44,6 +47,9 @@ /* define if sysconf() is available */ #undef HAVE_SYSCONF +/* define if sysctlbyname() is available */ +#undef HAVE_SYSCTLBYNAME + /* define if catgets() is available */ #undef HAVE_CATGETS @@ -120,3 +126,6 @@ int sigwait(const unsigned int *set, int *sig); /* define if pthread_attr_getstacksize() is available */ #undef HAVE_PTHREAD_ATTR_GETSTACKSIZE + +/* define if you have strerror in the C library. */ +#undef HAVE_STRERROR diff --git a/bin/named/unix/os.c b/bin/named/unix/os.c index da1874f5e26..ab7652fe6c9 100644 --- a/bin/named/unix/os.c +++ b/bin/named/unix/os.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: os.c,v 1.46 2001/08/29 18:03:36 gson Exp $ */ +/* $Id: os.c,v 1.46.2.1 2001/10/22 23:28:12 gson Exp $ */ #include #include @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -133,6 +134,7 @@ static void linux_setcaps(unsigned int caps) { struct __user_cap_header_struct caphead; struct __user_cap_data_struct cap; + char strbuf[ISC_STRERRORSIZE]; if ((getuid() != 0 && !non_root_caps) || non_root) return; @@ -144,8 +146,10 @@ linux_setcaps(unsigned int caps) { cap.effective = caps; cap.permitted = caps; cap.inheritable = caps; - if (syscall(SYS_capset, &caphead, &cap) < 0) - ns_main_earlyfatal("capset failed: %s", strerror(errno)); + if (syscall(SYS_capset, &caphead, &cap) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + ns_main_earlyfatal("capset failed: %s", strbuf); + } } static void @@ -233,15 +237,17 @@ linux_minprivs(void) { #ifdef HAVE_SYS_PRCTL_H static void linux_keepcaps(void) { + char strbuf[ISC_STRERRORSIZE]; /* * Ask the kernel to allow us to keep our capabilities after we * setuid(). */ if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) < 0) { - if (errno != EINVAL) - ns_main_earlyfatal("prctl() failed: %s", - strerror(errno)); + if (errno != EINVAL) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + ns_main_earlyfatal("prctl() failed: %s", strbuf); + } } else { non_root_caps = ISC_TRUE; if (getuid() != 0) @@ -280,10 +286,13 @@ void ns_os_daemonize(void) { pid_t pid; int fd; + char strbuf[ISC_STRERRORSIZE]; pid = fork(); - if (pid == -1) - ns_main_earlyfatal("fork(): %s", strerror(errno)); + if (pid == -1) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + ns_main_earlyfatal("fork(): %s", strbuf); + } if (pid != 0) _exit(0); @@ -295,8 +304,10 @@ ns_os_daemonize(void) { mainpid = getpid(); #endif - if (setsid() == -1) - ns_main_earlyfatal("setsid(): %s", strerror(errno)); + if (setsid() == -1) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + ns_main_earlyfatal("setsid(): %s", strbuf); + } /* * Try to set stdin, stdout, and stderr to /dev/null, but press @@ -337,16 +348,22 @@ all_digits(const char *s) { void ns_os_chroot(const char *root) { + char strbuf[ISC_STRERRORSIZE]; if (root != NULL) { - if (chroot(root) < 0) - ns_main_earlyfatal("chroot(): %s", strerror(errno)); - if (chdir("/") < 0) - ns_main_earlyfatal("chdir(/): %s", strerror(errno)); + if (chroot(root) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + ns_main_earlyfatal("chroot(): %s", strbuf); + } + if (chdir("/") < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + ns_main_earlyfatal("chdir(/): %s", strbuf); + } } } void ns_os_inituserinfo(const char *username) { + char strbuf[ISC_STRERRORSIZE]; if (username == NULL) return; @@ -360,14 +377,17 @@ ns_os_inituserinfo(const char *username) { ns_main_earlyfatal("user '%s' unknown", username); if (getuid() == 0) { - if (initgroups(runas_pw->pw_name, runas_pw->pw_gid) < 0) - ns_main_earlyfatal("initgroups(): %s", strerror(errno)); + if (initgroups(runas_pw->pw_name, runas_pw->pw_gid) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + ns_main_earlyfatal("initgroups(): %s", strbuf); + } } } void ns_os_changeuser(void) { + char strbuf[ISC_STRERRORSIZE]; if (runas_pw == NULL || done_setuid) return; @@ -382,11 +402,15 @@ ns_os_changeuser(void) { "2.3.99-pre3 or 2.2.18 when using threads"); #endif - if (setgid(runas_pw->pw_gid) < 0) - ns_main_earlyfatal("setgid(): %s", strerror(errno)); + if (setgid(runas_pw->pw_gid) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + ns_main_earlyfatal("setgid(): %s", strbuf); + } - if (setuid(runas_pw->pw_uid) < 0) - ns_main_earlyfatal("setuid(): %s", strerror(errno)); + if (setuid(runas_pw->pw_uid) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); + ns_main_earlyfatal("setuid(): %s", strbuf); + } #if defined(HAVE_LINUX_CAPABILITY_H) && !defined(HAVE_LINUXTHREADS) linux_minprivs(); @@ -447,6 +471,7 @@ ns_os_writepidfile(const char *filename) { FILE *lockfile; size_t len; pid_t pid; + char strbuf[ISC_STRERRORSIZE]; /* * The caller must ensure any required synchronization. @@ -456,20 +481,26 @@ ns_os_writepidfile(const char *filename) { len = strlen(filename); pidfile = malloc(len + 1); - if (pidfile == NULL) + if (pidfile == NULL) { + isc__strerror(errno, strbuf, sizeof(strbuf)); ns_main_earlyfatal("couldn't malloc '%s': %s", - filename, strerror(errno)); + filename, strbuf); + } /* This is safe. */ strcpy(pidfile, filename); fd = safe_open(filename, ISC_FALSE); - if (fd < 0) + if (fd < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); ns_main_earlyfatal("couldn't open pid file '%s': %s", - filename, strerror(errno)); + filename, strbuf); + } lockfile = fdopen(fd, "w"); - if (lockfile == NULL) + if (lockfile == NULL) { + isc__strerror(errno, strbuf, sizeof(strbuf)); ns_main_earlyfatal("could not fdopen() pid file '%s': %s", - filename, strerror(errno)); + filename, strbuf); + } #ifdef HAVE_LINUXTHREADS pid = mainpid; #else diff --git a/config.h.in b/config.h.in index ef1ea35db14..98cc14ade5a 100644 --- a/config.h.in +++ b/config.h.in @@ -16,7 +16,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: config.h.in,v 1.47 2001/08/16 06:19:56 marka Exp $ */ +/* $Id: config.h.in,v 1.47.2.1 2001/10/22 23:28:08 gson Exp $ */ /*** *** This file is not to be included by any public header files, because @@ -32,9 +32,6 @@ /* Define to `unsigned' if doesn't define. */ #undef size_t -/* Define to `int' if doesn't define. */ -#undef ssize_t - /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS @@ -45,6 +42,9 @@ byte first (like Motorola and SPARC, unlike Intel and VAX). */ #undef WORDS_BIGENDIAN +/* define to `int' if doesn't define. */ +#undef ssize_t + /* define on DEC OSF to enable 4.4BSD style sa_len support */ #undef _SOCKADDR_LEN @@ -138,6 +138,9 @@ int sigwait(const unsigned int *set, int *sig); /* define if pthread_attr_getstacksize() is available */ #undef HAVE_PTHREAD_ATTR_GETSTACKSIZE +/* define if you have strerror in the C library. */ +#undef HAVE_STRERROR + /* Define if you have the header file. */ #undef HAVE_DLFCN_H @@ -153,12 +156,12 @@ int sigwait(const unsigned int *set, int *sig); /* Define if you have the header file. */ #undef HAVE_SYS_SELECT_H -/* Define if you have the header file. */ -#undef HAVE_SYS_SYSCTL_H - /* Define if you have the header file. */ #undef HAVE_SYS_SOCKIO_H +/* Define if you have the header file. */ +#undef HAVE_SYS_SYSCTL_H + /* Define if you have the header file. */ #undef HAVE_SYS_TIME_H diff --git a/configure.in b/configure.in index 272865ff8c8..00ec4acd2a1 100644 --- a/configure.in +++ b/configure.in @@ -18,7 +18,7 @@ AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl esyscmd([sed "s/^/# /" COPYRIGHT])dnl AC_DIVERT_POP()dnl -AC_REVISION($Revision: 1.294.2.2 $) +AC_REVISION($Revision: 1.294.2.3 $) AC_INIT(lib/dns/name.c) AC_PREREQ(2.13) @@ -198,7 +198,7 @@ AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h sys/sockio.h sys/select.h sys/sysct AC_C_CONST AC_C_INLINE -AC_CHECK_FUNC(sysctlbyname, AC_DEFINE(HAVE_SYSCTLBYNAME),) +AC_CHECK_FUNC(sysctlbyname, AC_DEFINE(HAVE_SYSCTLBYNAME)) # # UnixWare 7.1.1 with the feature supplement to the UDK compiler @@ -1223,8 +1223,7 @@ AC_TRY_COMPILE([ #include ], [struct rrsetinfo r; return (0);], [AC_MSG_RESULT(yes) - ISC_LWRES_NEEDRRSETINFO="#undef ISC_LWRES_NEEDRRSETINFO" - AC_DEFINE(HAVE_RRSETINFO)], + ISC_LWRES_NEEDRRSETINFO="#undef ISC_LWRES_NEEDRRSETINFO"], [AC_MSG_RESULT(no) ISC_LWRES_NEEDRRSETINFO="#define ISC_LWRES_NEEDRRSETINFO 1"]) AC_SUBST(ISC_LWRES_NEEDRRSETINFO) @@ -1345,6 +1344,7 @@ AC_CHECK_FUNC(vsnprintf, ISC_PLATFORM_NEEDVSNPRINTF="#define ISC_PLATFORM_NEEDVSNPRINTF 1"]) AC_SUBST(ISC_PLATFORM_NEEDSTRSEP) AC_SUBST(ISC_PLATFORM_NEEDVSNPRINTF) +AC_CHECK_FUNC(strerror, AC_DEFINE(HAVE_STRERROR)) AC_SUBST(ISC_EXTRA_OBJS) AC_SUBST(ISC_EXTRA_SRCS) diff --git a/lib/isc/Makefile.in b/lib/isc/Makefile.in index 65b0735255e..40a2ee6ebb9 100644 --- a/lib/isc/Makefile.in +++ b/lib/isc/Makefile.in @@ -13,7 +13,7 @@ # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# $Id: Makefile.in,v 1.71 2001/03/02 19:25:15 bwelling Exp $ +# $Id: Makefile.in,v 1.71.2.1 2001/10/22 23:28:13 gson Exp $ srcdir = @srcdir@ VPATH = @srcdir@ @@ -36,7 +36,7 @@ UNIXOBJS = @ISC_ISCIPV6_O@ \ unix/errno2result.@O@ unix/file.@O@ unix/fsaccess.@O@ \ unix/interfaceiter.@O@ unix/keyboard.@O@ unix/net.@O@ \ unix/os.@O@ unix/resource.@O@ unix/socket.@O@ unix/stdio.@O@ \ - unix/stdtime.@O@ unix/syslog.@O@ unix/time.@O@ + unix/stdtime.@O@ unix/strerror.@O@ unix/syslog.@O@ unix/time.@O@ NLSOBJS = nls/msgcat.@O@ diff --git a/lib/isc/pthreads/condition.c b/lib/isc/pthreads/condition.c index fb3bdffe68a..49b92ac5d3a 100644 --- a/lib/isc/pthreads/condition.c +++ b/lib/isc/pthreads/condition.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: condition.c,v 1.30 2001/01/23 02:27:19 bwelling Exp $ */ +/* $Id: condition.c,v 1.30.2.1 2001/10/22 23:28:14 gson Exp $ */ #include @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -32,6 +33,7 @@ isc_condition_waituntil(isc_condition_t *c, isc_mutex_t *m, isc_time_t *t) { int presult; isc_result_t result; struct timespec ts; + char strbuf[ISC_STRERRORSIZE]; REQUIRE(c != NULL && m != NULL && t != NULL); @@ -60,10 +62,11 @@ isc_condition_waituntil(isc_condition_t *c, isc_mutex_t *m, isc_time_t *t) { return (ISC_R_TIMEDOUT); } while (presult == EINTR); + isc__strerror(presult, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "pthread_cond_timedwait() %s %s", isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, ISC_MSG_RETURNED, "returned"), - strerror(presult)); + strbuf); return (ISC_R_UNEXPECTED); } diff --git a/lib/isc/unix/Makefile.in b/lib/isc/unix/Makefile.in index 7dc2fb827be..82928194ad3 100644 --- a/lib/isc/unix/Makefile.in +++ b/lib/isc/unix/Makefile.in @@ -13,7 +13,7 @@ # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# $Id: Makefile.in,v 1.35 2001/03/02 19:25:16 bwelling Exp $ +# $Id: Makefile.in,v 1.35.2.1 2001/10/22 23:28:16 gson Exp $ srcdir = @srcdir@ VPATH = @srcdir@ @@ -33,14 +33,14 @@ OBJS = @ISC_IPV6_O@ \ app.@O@ dir.@O@ entropy.@O@ errno2result.@O@ file.@O@ \ fsaccess.@O@ interfaceiter.@O@ keyboard.@O@ net.@O@ \ os.@O@ resource.@O@ socket.@O@ stdio.@O@ stdtime.@O@ \ - syslog.@O@ time.@O@ + strerror.@O@ syslog.@O@ time.@O@ # Alphabetically SRCS = @ISC_IPV6_C@ \ app.c dir.c entropy.c errno2result.c file.c \ fsaccess.c interfaceiter.c keyboard.c net.c \ os.c resource.c socket.c stdio.c stdtime.c \ - syslog.c time.c + strerror.c syslog.c time.c SUBDIRS = include TARGETS = ${OBJS} diff --git a/lib/isc/unix/app.c b/lib/isc/unix/app.c index a9f7359bb13..4eb7020a9bd 100644 --- a/lib/isc/unix/app.c +++ b/lib/isc/unix/app.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: app.c,v 1.43 2001/07/09 21:05:57 gson Exp $ */ +/* $Id: app.c,v 1.43.2.1 2001/10/22 23:28:17 gson Exp $ */ #include @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -97,17 +98,19 @@ reload_action(int arg) { static isc_result_t handle_signal(int sig, void (*handler)(int)) { struct sigaction sa; + char strbuf[ISC_STRERRORSIZE]; memset(&sa, 0, sizeof sa); sa.sa_handler = handler; if (sigfillset(&sa.sa_mask) != 0 || sigaction(sig, &sa, NULL) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, isc_msgcat_get(isc_msgcat, ISC_MSGSET_APP, ISC_MSG_SIGNALSETUP, "handle_signal() %d setup: %s"), - sig, strerror(errno)); + sig, strbuf); return (ISC_R_UNEXPECTED); } @@ -119,6 +122,7 @@ isc_app_start(void) { isc_result_t result; int presult; sigset_t sset; + char strbuf[ISC_STRERRORSIZE]; /* * Start an ISC library application. @@ -130,9 +134,9 @@ isc_app_start(void) { */ presult = pthread_init(); if (presult != 0) { + isc__strerror(presult, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_app_start() pthread_init: %s", - strerror(presult)); + "isc_app_start() pthread_init: %s", strbuf); return (ISC_R_UNEXPECTED); } #endif @@ -204,16 +208,17 @@ isc_app_start(void) { sigaddset(&sset, SIGHUP) != 0 || sigaddset(&sset, SIGINT) != 0 || sigaddset(&sset, SIGTERM) != 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_app_start() sigsetops: %s", - strerror(errno)); + "isc_app_start() sigsetops: %s", strbuf); return (ISC_R_UNEXPECTED); } presult = pthread_sigmask(SIG_BLOCK, &sset, NULL); if (presult != 0) { + isc__strerror(presult, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_app_start() pthread_sigmask: %s", - strerror(presult)); + strbuf); return (ISC_R_UNEXPECTED); } #else /* ISC_PLATFORM_USETHREADS */ @@ -228,16 +233,16 @@ isc_app_start(void) { sigaddset(&sset, SIGHUP) != 0 || sigaddset(&sset, SIGINT) != 0 || sigaddset(&sset, SIGTERM) != 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_app_start() sigsetops: %s", - strerror(errno)); + "isc_app_start() sigsetops: %s", strbuf); return (ISC_R_UNEXPECTED); } presult = sigprocmask(SIG_UNBLOCK, &sset, NULL); if (presult != 0) { + isc__strerror(presult, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_app_start() sigprocmask: %s", - strerror(presult)); + "isc_app_start() sigprocmask: %s", strbuf); return (ISC_R_UNEXPECTED); } #endif /* ISC_PLATFORM_USETHREADS */ @@ -405,6 +410,7 @@ isc_app_run(void) { isc_task_t *task; #ifdef ISC_PLATFORM_USETHREADS sigset_t sset; + char strbuf[ISC_STRERRORSIZE]; #endif /* ISC_PLATFORM_USETHREADS */ #ifdef HAVE_SIGWAIT int sig; @@ -464,9 +470,9 @@ isc_app_run(void) { sigaddset(&sset, SIGHUP) != 0 || sigaddset(&sset, SIGINT) != 0 || sigaddset(&sset, SIGTERM) != 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_app_run() sigsetops: %s", - strerror(errno)); + "isc_app_run() sigsetops: %s", strbuf); return (ISC_R_UNEXPECTED); } @@ -496,9 +502,9 @@ isc_app_run(void) { * Listen for all signals. */ if (sigemptyset(&sset) != 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_app_run() sigsetops: %s", - strerror(errno)); + "isc_app_run() sigsetops: %s", strbuf); return (ISC_R_UNEXPECTED); } result = sigsuspend(&sset); @@ -532,6 +538,7 @@ isc_app_run(void) { isc_result_t isc_app_shutdown(void) { isc_boolean_t want_kill = ISC_TRUE; + char strbuf[ISC_STRERRORSIZE]; LOCK(&lock); @@ -550,16 +557,17 @@ isc_app_shutdown(void) { result = pthread_kill(main_thread, SIGTERM); if (result != 0) { + isc__strerror(result, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_app_shutdown() pthread_kill: %s", - strerror(result)); + strbuf); return (ISC_R_UNEXPECTED); } #else if (kill(getpid(), SIGTERM) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_app_shutdown() kill: %s", - strerror(errno)); + "isc_app_shutdown() kill: %s", strbuf); return (ISC_R_UNEXPECTED); } #endif @@ -571,6 +579,7 @@ isc_app_shutdown(void) { isc_result_t isc_app_reload(void) { isc_boolean_t want_kill = ISC_TRUE; + char strbuf[ISC_STRERRORSIZE]; LOCK(&lock); @@ -590,16 +599,17 @@ isc_app_reload(void) { result = pthread_kill(main_thread, SIGHUP); if (result != 0) { + isc__strerror(result, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_app_reload() pthread_kill: %s", - strerror(result)); + strbuf); return (ISC_R_UNEXPECTED); } #else if (kill(getpid(), SIGHUP) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_app_reload() kill: %s", - strerror(errno)); + "isc_app_reload() kill: %s", strbuf); return (ISC_R_UNEXPECTED); } #endif @@ -651,4 +661,3 @@ isc_app_unblock(void) { RUNTIME_CHECK(pthread_sigmask(SIG_BLOCK, &sset, NULL) == 0); #endif /* ISC_PLATFORM_USETHREADS */ } - diff --git a/lib/isc/unix/entropy.c b/lib/isc/unix/entropy.c index c1c48b0bfe9..8c552f6f301 100644 --- a/lib/isc/unix/entropy.c +++ b/lib/isc/unix/entropy.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: entropy.c,v 1.60 2001/07/18 01:31:13 gson Exp $ */ +/* $Id: entropy.c,v 1.60.2.1 2001/10/22 23:28:18 gson Exp $ */ /* * This is the system depenedent part of the ISC entropy API. @@ -29,6 +29,7 @@ #include #include +#include #ifdef ISC_PLATFORM_NEEDSYSSELECTH #include @@ -267,15 +268,17 @@ static isc_result_t make_nonblock(int fd) { int ret; int flags; + char strbuf[ISC_STRERRORSIZE]; flags = fcntl(fd, F_GETFL, 0); flags |= O_NONBLOCK; ret = fcntl(fd, F_SETFL, flags); if (ret == -1) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "fcntl(%d, F_SETFL, %d): %s", - fd, flags, strerror(errno)); + fd, flags, strbuf); return (ISC_R_UNEXPECTED); } diff --git a/lib/isc/unix/ifiter_ioctl.c b/lib/isc/unix/ifiter_ioctl.c index 33bfabca77d..2c8fddfb5df 100644 --- a/lib/isc/unix/ifiter_ioctl.c +++ b/lib/isc/unix/ifiter_ioctl.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ifiter_ioctl.c,v 1.19 2001/07/09 21:05:58 gson Exp $ */ +/* $Id: ifiter_ioctl.c,v 1.19.2.1 2001/10/22 23:28:19 gson Exp $ */ /* * Obtain the list of network interfaces using the SIOCGLIFCONF ioctl. @@ -73,6 +73,7 @@ isc_result_t isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { isc_interfaceiter_t *iter; isc_result_t result; + char strbuf[ISC_STRERRORSIZE]; REQUIRE(mctx != NULL); REQUIRE(iterp != NULL); @@ -89,13 +90,14 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { * Create an unbound datagram socket to do the SIOCGLIFADDR ioctl on. */ if ((iter->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, isc_msgcat_get(isc_msgcat, ISC_MSGSET_IFITERIOCTL, ISC_MSG_MAKESCANSOCKET, "making interface " "scan socket: %s"), - strerror(errno)); + strbuf); result = ISC_R_UNEXPECTED; goto socket_failure; } @@ -130,13 +132,14 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) { if (ioctl(iter->socket, SIOCGLIFCONF, (char *)&iter->ifc) == -1) { if (errno != EINVAL) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, isc_msgcat_get(isc_msgcat, ISC_MSGSET_IFITERIOCTL, ISC_MSG_GETIFCONFIG, "get interface " "configuration: %s"), - strerror(errno)); + strbuf); result = ISC_R_UNEXPECTED; goto ioctl_failure; } @@ -209,6 +212,7 @@ internal_current(isc_interfaceiter_t *iter) { struct lifreq *ifrp; struct lifreq lifreq; int family; + char strbuf[ISC_STRERRORSIZE]; REQUIRE(VALID_IFITER(iter)); REQUIRE (iter->pos < (unsigned int) iter->ifc.lifc_len); @@ -244,10 +248,10 @@ internal_current(isc_interfaceiter_t *iter) { * and is really hard to shut up. */ if (ioctl(iter->socket, SIOCGLIFFLAGS, (char *) &lifreq) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "%s: getting interface flags: %s", - lifreq.lifr_name, - strerror(errno)); + lifreq.lifr_name, strbuf); return (ISC_R_IGNORE); } @@ -271,14 +275,14 @@ internal_current(isc_interfaceiter_t *iter) { */ if (ioctl(iter->socket, SIOCGLIFDSTADDR, (char *)&lifreq) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, isc_msgcat_get(isc_msgcat, ISC_MSGSET_IFITERIOCTL, ISC_MSG_GETDESTADDR, "%s: getting " "destination address: %s"), - lifreq.lifr_name, - strerror(errno)); + lifreq.lifr_name, strbuf); return (ISC_R_IGNORE); } get_addr(family, &iter->current.dstaddress, @@ -299,13 +303,13 @@ internal_current(isc_interfaceiter_t *iter) { */ if (ioctl(iter->socket, SIOCGLIFNETMASK, (char *)&lifreq) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, isc_msgcat_get(isc_msgcat, ISC_MSGSET_IFITERIOCTL, ISC_MSG_GETNETMASK, "%s: getting netmask: %s"), - lifreq.lifr_name, - strerror(errno)); + lifreq.lifr_name, strbuf); return (ISC_R_IGNORE); } get_addr(family, &iter->current.netmask, diff --git a/lib/isc/unix/interfaceiter.c b/lib/isc/unix/interfaceiter.c index 0e3fe92ddee..3883ff5fe59 100644 --- a/lib/isc/unix/interfaceiter.c +++ b/lib/isc/unix/interfaceiter.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: interfaceiter.c,v 1.22 2001/06/05 06:34:11 bwelling Exp $ */ +/* $Id: interfaceiter.c,v 1.22.2.1 2001/10/22 23:28:21 gson Exp $ */ #include @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/lib/isc/unix/net.c b/lib/isc/unix/net.c index 6de3143ccfa..ba2eb419b5e 100644 --- a/lib/isc/unix/net.c +++ b/lib/isc/unix/net.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: net.c,v 1.22 2001/07/09 21:05:59 gson Exp $ */ +/* $Id: net.c,v 1.22.2.1 2001/10/22 23:28:22 gson Exp $ */ #include @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -42,6 +43,7 @@ static isc_result_t try_proto(int domain) { int s; isc_result_t result = ISC_R_SUCCESS; + char strbuf[ISC_STRERRORSIZE]; s = socket(domain, SOCK_STREAM, 0); if (s == -1) { @@ -57,13 +59,14 @@ try_proto(int domain) { #endif return (ISC_R_NOTFOUND); default: + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "socket() %s: %s", isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, ISC_MSG_FAILED, "failed"), - strerror(errno)); + strbuf); return (ISC_R_UNEXPECTED); } } diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 88e1ea38c3c..d1e7e2cab90 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.c,v 1.207.2.1 2001/09/19 02:37:21 marka Exp $ */ +/* $Id: socket.c,v 1.207.2.2 2001/10/22 23:28:23 gson Exp $ */ #include @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -372,6 +373,7 @@ static void select_poke(isc_socketmgr_t *mgr, int fd, int msg) { int cc; int buf[2]; + char strbuf[ISC_STRERRORSIZE]; buf[0] = fd; buf[1] = msg; @@ -380,13 +382,15 @@ select_poke(isc_socketmgr_t *mgr, int fd, int msg) { cc = write(mgr->pipe_fds[1], buf, sizeof(buf)); } while (cc < 0 && SOFT_ERROR(errno)); - if (cc < 0) + if (cc < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); FATAL_ERROR(__FILE__, __LINE__, isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_WRITEFAILED, "write() failed " "during watcher poke: %s"), - strerror(errno)); + strbuf); + } INSIST(cc == sizeof(buf)); } @@ -398,6 +402,7 @@ static void select_readmsg(isc_socketmgr_t *mgr, int *fd, int *msg) { int buf[2]; int cc; + char strbuf[ISC_STRERRORSIZE]; cc = read(mgr->pipe_fds[0], buf, sizeof(buf)); if (cc < 0) { @@ -405,12 +410,13 @@ select_readmsg(isc_socketmgr_t *mgr, int *fd, int *msg) { if (SOFT_ERROR(errno)) return; + isc__strerror(errno, strbuf, sizeof(strbuf)); FATAL_ERROR(__FILE__, __LINE__, isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_READFAILED, "read() failed " "during watcher poke: %s"), - strerror(errno)); + strbuf); return; } @@ -440,15 +446,17 @@ static isc_result_t make_nonblock(int fd) { int ret; int flags; + char strbuf[ISC_STRERRORSIZE]; flags = fcntl(fd, F_GETFL, 0); flags |= O_NONBLOCK; ret = fcntl(fd, F_SETFL, flags); if (ret == -1) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "fcntl(%d, F_SETFL, %d): %s", - fd, flags, strerror(errno)); + fd, flags, strbuf); return (ISC_R_UNEXPECTED); } @@ -879,6 +887,7 @@ doio_recv(isc_socket_t *sock, isc_socketevent_t *dev) { #else char *cmsg = NULL; #endif + char strbuf[ISC_STRERRORSIZE]; build_msghdr_recv(sock, dev, &msghdr, cmsg, iov, &read_count); @@ -893,13 +902,14 @@ doio_recv(isc_socket_t *sock, isc_socketevent_t *dev) { if (SOFT_ERROR(recv_errno)) return (DOIO_SOFT); - if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL)) + if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL)) { + isc__strerror(recv_errno, strbuf, sizeof(strbuf)); socket_log(sock, NULL, IOEVENT, isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_DOIORECV, "doio_recv: recvmsg(%d) %d bytes, err %d/%s", - sock->fd, cc, recv_errno, - strerror(recv_errno)); + sock->fd, cc, recv_errno, strbuf); + } #define SOFT_OR_HARD(_system, _isc) \ if (recv_errno == _system) { \ @@ -1026,6 +1036,7 @@ doio_send(isc_socket_t *sock, isc_socketevent_t *dev) { #endif int attempts = 0; int send_errno; + char strbuf[ISC_STRERRORSIZE]; build_msghdr_send(sock, dev, &msghdr, cmsg, iov, &write_count); @@ -1083,9 +1094,9 @@ doio_send(isc_socket_t *sock, isc_socketevent_t *dev) { * a status. */ isc_sockaddr_format(&dev->address, addrbuf, sizeof(addrbuf)); - UNEXPECTED_ERROR(__FILE__, __LINE__, - "internal_send: %s: %s", - addrbuf, strerror(send_errno)); + isc__strerror(send_errno, strbuf, sizeof(strbuf)); + UNEXPECTED_ERROR(__FILE__, __LINE__, "internal_send: %s: %s", + addrbuf, strbuf); dev->result = isc__errno2result(send_errno); return (DOIO_HARD); } @@ -1273,6 +1284,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, #if defined(USE_CMSG) || defined(SO_BSDCOMPAT) int on = 1; #endif + char strbuf[ISC_STRERRORSIZE]; REQUIRE(VALID_MANAGER(manager)); REQUIRE(socketp != NULL && *socketp == NULL); @@ -1324,13 +1336,14 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, return (ISC_R_FAMILYNOSUPPORT); default: + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "socket() %s: %s", isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, ISC_MSG_FAILED, "failed"), - strerror(errno)); + strbuf); return (ISC_R_UNEXPECTED); } } @@ -1343,12 +1356,13 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, #ifdef SO_BSDCOMPAT if (setsockopt(sock->fd, SOL_SOCKET, SO_BSDCOMPAT, (void *)&on, sizeof on) < 0) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d, SO_BSDCOMPAT) %s: %s", sock->fd, isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, ISC_MSG_FAILED, "failed"), - strerror(errno)); + strbuf); /* Press on... */ } #endif @@ -1360,6 +1374,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, if (setsockopt(sock->fd, SOL_SOCKET, SO_TIMESTAMP, (void *)&on, sizeof on) < 0 && errno != ENOPROTOOPT) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d, SO_TIMESTAMP) %s: %s", sock->fd, @@ -1367,7 +1382,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, ISC_MSGSET_GENERAL, ISC_MSG_FAILED, "failed"), - strerror(errno)); + strbuf); /* Press on... */ } #endif /* SO_TIMESTAMP */ @@ -1378,6 +1393,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, if ((pf == AF_INET6) && (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, (void *)&on, sizeof (on)) < 0)) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d, IPV6_RECVPKTINFO) " "%s: %s", sock->fd, @@ -1385,13 +1401,14 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, ISC_MSGSET_GENERAL, ISC_MSG_FAILED, "failed"), - strerror(errno)); + strbuf); } #else /* 2292 */ if ((pf == AF_INET6) && (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_PKTINFO, (void *)&on, sizeof (on)) < 0)) { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d, IPV6_PKTINFO) %s: %s", sock->fd, @@ -1399,7 +1416,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, ISC_MSGSET_GENERAL, ISC_MSG_FAILED, "failed"), - strerror(errno)); + strbuf); } #endif /* IPV6_RECVPKTINFO */ #ifdef IPV6_USE_MIN_MTU /*2292bis, not too common yet*/ @@ -1659,6 +1676,7 @@ internal_accept(isc_task_t *me, isc_event_t *ev) { ISC_SOCKADDR_LEN_T addrlen; int fd; isc_result_t result = ISC_R_SUCCESS; + char strbuf[ISC_STRERRORSIZE]; UNUSED(me); @@ -1711,13 +1729,14 @@ internal_accept(isc_task_t *me, isc_event_t *ev) { if (SOFT_ERROR(errno) || errno == ECONNRESET) { goto soft_error; } else { + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "internal_accept: accept() %s: %s", isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, ISC_MSG_FAILED, "failed"), - strerror(errno)); + strbuf); fd = -1; result = ISC_R_UNEXPECTED; } @@ -2034,6 +2053,7 @@ watcher(void *uap) { fd_set writefds; int msg, fd; int maxfd; + char strbuf[ISC_STRERRORSIZE]; /* * Get the control fd here. This will never change. @@ -2052,14 +2072,17 @@ watcher(void *uap) { cc = select(maxfd, &readfds, &writefds, NULL, NULL); if (cc < 0) { - if (!SOFT_ERROR(errno)) + if (!SOFT_ERROR(errno)) { + isc__strerror(errno, strbuf, + sizeof(strbuf)); FATAL_ERROR(__FILE__, __LINE__, "select() %s: %s", isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, ISC_MSG_FAILED, "failed"), - strerror(errno)); + strbuf); + } } LOCK(&manager->lock); @@ -2126,6 +2149,9 @@ watcher(void *uap) { isc_result_t isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) { isc_socketmgr_t *manager; +#ifdef ISC_PLATFORM_USETHREADS + char strbuf[ISC_STRERRORSIZE]; +#endif REQUIRE(managerp != NULL && *managerp == NULL); @@ -2171,11 +2197,12 @@ isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) { if (pipe(manager->pipe_fds) != 0) { DESTROYLOCK(&manager->lock); isc_mem_put(mctx, manager, sizeof *manager); + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "pipe() %s: %s", isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, ISC_MSG_FAILED, "failed"), - strerror(errno)); + strbuf); return (ISC_R_UNEXPECTED); } @@ -2691,6 +2718,7 @@ isc_socket_sendto2(isc_socket_t *sock, isc_region_t *region, isc_result_t isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr) { + char strbuf[ISC_STRERRORSIZE]; int on = 1; LOCK(&sock->lock); @@ -2721,8 +2749,9 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr) { case EINVAL: return (ISC_R_BOUND); default: - UNEXPECTED_ERROR(__FILE__, __LINE__, - "bind: %s", strerror(errno)); + isc__strerror(errno, strbuf, sizeof(strbuf)); + UNEXPECTED_ERROR(__FILE__, __LINE__, "bind: %s", + strbuf); return (ISC_R_UNEXPECTED); } } @@ -2747,6 +2776,8 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr) { */ isc_result_t isc_socket_listen(isc_socket_t *sock, unsigned int backlog) { + char strbuf[ISC_STRERRORSIZE]; + REQUIRE(VALID_SOCKET(sock)); LOCK(&sock->lock); @@ -2760,8 +2791,9 @@ isc_socket_listen(isc_socket_t *sock, unsigned int backlog) { if (listen(sock->fd, (int)backlog) < 0) { UNLOCK(&sock->lock); - UNEXPECTED_ERROR(__FILE__, __LINE__, "listen: %s", - strerror(errno)); + isc__strerror(errno, strbuf, sizeof(strbuf)); + + UNEXPECTED_ERROR(__FILE__, __LINE__, "listen: %s", strbuf); return (ISC_R_UNEXPECTED); } @@ -2849,6 +2881,7 @@ isc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr, isc_task_t *ntask = NULL; isc_socketmgr_t *manager; int cc; + char strbuf[ISC_STRERRORSIZE]; REQUIRE(VALID_SOCKET(sock)); REQUIRE(addr != NULL); @@ -2905,8 +2938,8 @@ isc_socket_connect(isc_socket_t *sock, isc_sockaddr_t *addr, sock->connected = 0; - UNEXPECTED_ERROR(__FILE__, __LINE__, "%d/%s", - errno, strerror(errno)); + isc__strerror(errno, strbuf, sizeof(strbuf)); + UNEXPECTED_ERROR(__FILE__, __LINE__, "%d/%s", errno, strbuf); UNLOCK(&sock->lock); isc_event_free((isc_event_t **)&dev); @@ -2968,6 +3001,7 @@ internal_connect(isc_task_t *me, isc_event_t *ev) { isc_task_t *task; int cc; ISC_SOCKADDR_LEN_T optlen; + char strbuf[ISC_STRERRORSIZE]; UNUSED(me); INSIST(ev->ev_type == ISC_SOCKEVENT_INTW); @@ -3047,9 +3081,10 @@ internal_connect(isc_task_t *me, isc_event_t *ev) { #undef ERROR_MATCH default: dev->result = ISC_R_UNEXPECTED; + isc__strerror(errno, strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "internal_connect: connect() %s", - strerror(errno)); + strbuf); } } else { dev->result = ISC_R_SUCCESS; @@ -3091,6 +3126,7 @@ isc_result_t isc_socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp) { ISC_SOCKADDR_LEN_T len; isc_result_t ret; + char strbuf[ISC_STRERRORSIZE]; REQUIRE(VALID_SOCKET(sock)); REQUIRE(addressp != NULL); @@ -3106,8 +3142,9 @@ isc_socket_getsockname(isc_socket_t *sock, isc_sockaddr_t *addressp) { len = sizeof addressp->type; if (getsockname(sock->fd, &addressp->type.sa, (void *)&len) < 0) { - UNEXPECTED_ERROR(__FILE__, __LINE__, - "getsockname: %s", strerror(errno)); + isc__strerror(errno, strbuf, sizeof(strbuf)); + UNEXPECTED_ERROR(__FILE__, __LINE__, "getsockname: %s", + strbuf); ret = ISC_R_UNEXPECTED; goto out; } diff --git a/lib/isc/unix/strerror.c b/lib/isc/unix/strerror.c index c749cbc2aa9..697004aa5a8 100644 --- a/lib/isc/unix/strerror.c +++ b/lib/isc/unix/strerror.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: strerror.c,v 1.1 2001/08/30 04:33:19 marka Exp $ */ +/* $Id: strerror.c,v 1.1.2.1 2001/10/22 23:28:25 gson Exp $ */ #include @@ -62,9 +62,7 @@ isc__strerror(int num, char *buf, size_t size) { return (buf); #else unsigned int unum = num; - isc_once_t once = ISC_ONCE_INIT; - static lock; - + REQUIRE(buf != NULL); if (num >= 0 && num < sys_nerr) diff --git a/lib/isc/unix/time.c b/lib/isc/unix/time.c index 8a5f1a1008e..328f72b727e 100644 --- a/lib/isc/unix/time.c +++ b/lib/isc/unix/time.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: time.c,v 1.34.2.4 2001/09/06 00:34:06 marka Exp $ */ +/* $Id: time.c,v 1.34.2.5 2001/10/22 23:28:26 gson Exp $ */ #include @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -142,11 +143,13 @@ isc_time_isepoch(isc_time_t *t) { isc_result_t isc_time_now(isc_time_t *t) { struct timeval tv; + char strbuf[ISC_STRERRORSIZE]; REQUIRE(t != NULL); if (gettimeofday(&tv, NULL) == -1) { - UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strerror(errno)); + isc__strerror(errno, strbuf, sizeof(strbuf)); + UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strbuf); return (ISC_R_UNEXPECTED); } @@ -182,13 +185,15 @@ isc_time_now(isc_time_t *t) { isc_result_t isc_time_nowplusinterval(isc_time_t *t, isc_interval_t *i) { struct timeval tv; + char strbuf[ISC_STRERRORSIZE]; REQUIRE(t != NULL); REQUIRE(i != NULL); INSIST(i->nanoseconds < NS_PER_S); if (gettimeofday(&tv, NULL) == -1) { - UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strerror(errno)); + isc__strerror(errno, strbuf, sizeof(strbuf)); + UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strbuf); return (ISC_R_UNEXPECTED); }