Commit 16729357 authored by Ondřej Surý's avatar Ondřej Surý

Use strerror_r from POSIX.1-2001 (strerror_s on Windows) instead of custom isc__strerror()

parent efd613e8
......@@ -40,7 +40,6 @@
#include <isc/print.h>
#include <isc/resource.h>
#include <isc/result.h>
#include <isc/strerror.h>
#include <isc/string.h>
#include <named/globals.h>
......@@ -130,7 +129,7 @@ linux_setcaps(cap_t caps) {
return;
}
if (cap_set_proc(caps) < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlyfatal("cap_set_proc() failed: %s:"
" please ensure that the capset kernel"
" module is loaded. see insmod(8)",
......@@ -146,13 +145,13 @@ linux_setcaps(cap_t caps) {
if (err != -1 && curval) { \
err = cap_set_flag(caps, CAP_EFFECTIVE, 1, &capval, CAP_SET); \
if (err == -1) { \
isc__strerror(errno, strbuf, sizeof(strbuf)); \
strerror_r(errno, strbuf, sizeof(strbuf)); \
named_main_earlyfatal("cap_set_proc failed: %s", strbuf); \
} \
\
err = cap_set_flag(caps, CAP_PERMITTED, 1, &capval, CAP_SET); \
if (err == -1) { \
isc__strerror(errno, strbuf, sizeof(strbuf)); \
strerror_r(errno, strbuf, sizeof(strbuf)); \
named_main_earlyfatal("cap_set_proc failed: %s", strbuf); \
} \
} \
......@@ -161,12 +160,12 @@ linux_setcaps(cap_t caps) {
do { \
caps = cap_init(); \
if (caps == NULL) { \
isc__strerror(errno, strbuf, sizeof(strbuf)); \
strerror_r(errno, strbuf, sizeof(strbuf)); \
named_main_earlyfatal("cap_init failed: %s", strbuf); \
} \
curcaps = cap_get_proc(); \
if (curcaps == NULL) { \
isc__strerror(errno, strbuf, sizeof(strbuf)); \
strerror_r(errno, strbuf, sizeof(strbuf)); \
named_main_earlyfatal("cap_get_proc failed: %s", strbuf); \
} \
} while (0)
......@@ -286,7 +285,7 @@ linux_keepcaps(void) {
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) < 0) {
if (errno != EINVAL) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlyfatal("prctl() failed: %s", strbuf);
}
} else {
......@@ -331,13 +330,13 @@ named_os_daemonize(void) {
char strbuf[ISC_STRERRORSIZE];
if (pipe(dfd) == -1) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlyfatal("pipe(): %s", strbuf);
}
pid = fork();
if (pid == -1) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlyfatal("fork(): %s", strbuf);
}
if (pid != 0) {
......@@ -367,7 +366,7 @@ named_os_daemonize(void) {
#endif
if (setsid() == -1) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlyfatal("setsid(): %s", strbuf);
}
......@@ -450,14 +449,14 @@ named_os_chroot(const char *root) {
if (root != NULL) {
#ifdef HAVE_CHROOT
if (chroot(root) < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlyfatal("chroot(): %s", strbuf);
}
#else
named_main_earlyfatal("chroot(): disabled");
#endif
if (chdir("/") < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlyfatal("chdir(/): %s", strbuf);
}
#ifdef HAVE_LIBSCF
......@@ -484,7 +483,7 @@ named_os_inituserinfo(const char *username) {
if (getuid() == 0) {
if (initgroups(runas_pw->pw_name, runas_pw->pw_gid) < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlyfatal("initgroups(): %s", strbuf);
}
}
......@@ -514,12 +513,12 @@ named_os_changeuser(void) {
#endif
if (setgid(runas_pw->pw_gid) < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlyfatal("setgid(): %s", strbuf);
}
if (setuid(runas_pw->pw_uid) < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlyfatal("setuid(): %s", strbuf);
}
......@@ -529,7 +528,7 @@ named_os_changeuser(void) {
* call has disabled it.
*/
if (prctl(PR_SET_DUMPABLE,1,0,0,0) < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlywarning("prctl(PR_SET_DUMPABLE) failed: %s",
strbuf);
}
......@@ -648,7 +647,7 @@ mkdirpath(char *filename, void (*report)(const char *, ...)) {
if (stat(filename, &sb) == -1) {
if (errno != ENOENT) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
(*report)("couldn't stat '%s': %s", filename,
strbuf);
goto error;
......@@ -668,7 +667,7 @@ mkdirpath(char *filename, void (*report)(const char *, ...)) {
mode |= S_IRGRP | S_IXGRP; /* g=rx */
mode |= S_IROTH | S_IXOTH; /* o=rx */
if (mkdir(filename, mode) == -1) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
(*report)("couldn't mkdir '%s': %s", filename,
strbuf);
goto error;
......@@ -676,7 +675,7 @@ mkdirpath(char *filename, void (*report)(const char *, ...)) {
if (runas_pw != NULL &&
chown(filename, runas_pw->pw_uid,
runas_pw->pw_gid) == -1) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
(*report)("couldn't chown '%s': %s", filename,
strbuf);
}
......@@ -703,7 +702,7 @@ setperms(uid_t uid, gid_t gid) {
#endif
#if defined(HAVE_SETEGID)
if (getegid() != gid && setegid(gid) == -1) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlywarning("unable to set effective "
"gid to %ld: %s",
(long)gid, strbuf);
......@@ -711,7 +710,7 @@ setperms(uid_t uid, gid_t gid) {
#elif defined(HAVE_SETRESGID)
if (getresgid(&tmpg, &oldgid, &tmpg) == -1 || oldgid != gid) {
if (setresgid(-1, gid, -1) == -1) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlywarning("unable to set effective "
"gid to %d: %s", gid, strbuf);
}
......@@ -720,7 +719,7 @@ setperms(uid_t uid, gid_t gid) {
#if defined(HAVE_SETEUID)
if (geteuid() != uid && seteuid(uid) == -1) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlywarning("unable to set effective "
"uid to %ld: %s",
(long)uid, strbuf);
......@@ -728,7 +727,7 @@ setperms(uid_t uid, gid_t gid) {
#elif defined(HAVE_SETRESUID)
if (getresuid(&tmpu, &olduid, &tmpu) == -1 || olduid != uid) {
if (setresuid(-1, uid, -1) == -1) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlywarning("unable to set effective "
"uid to %d: %s", uid, strbuf);
}
......@@ -747,7 +746,7 @@ named_os_openfile(const char *filename, mode_t mode, bool switch_user) {
*/
f = strdup(filename);
if (f == NULL) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlywarning("couldn't strdup() '%s': %s",
filename, strbuf);
return (NULL);
......@@ -799,7 +798,7 @@ named_os_openfile(const char *filename, mode_t mode, bool switch_user) {
}
if (fd < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlywarning("could not open file '%s': %s",
filename, strbuf);
return (NULL);
......@@ -807,7 +806,7 @@ named_os_openfile(const char *filename, mode_t mode, bool switch_user) {
fp = fdopen(fd, "w");
if (fp == NULL) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlywarning("could not fdopen() file '%s': %s",
filename, strbuf);
}
......@@ -835,7 +834,7 @@ named_os_writepidfile(const char *filename, bool first_time) {
pidfile = strdup(filename);
if (pidfile == NULL) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
(*report)("couldn't strdup() '%s': %s", filename, strbuf);
return;
}
......@@ -882,7 +881,7 @@ named_os_issingleton(const char *filename) {
*/
lockfile = strdup(filename);
if (lockfile == NULL) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlyfatal("couldn't allocate memory for '%s': %s",
filename, strbuf);
} else {
......
......@@ -27,7 +27,6 @@
#include <isc/print.h>
#include <isc/result.h>
#include <isc/strerror.h>
#include <isc/string.h>
#include <isc/ntpaths.h>
#include <isc/util.h>
......@@ -231,7 +230,7 @@ named_os_openfile(const char *filename, int mode, bool switch_user) {
UNUSED(switch_user);
fd = safe_open(filename, mode, false);
if (fd < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_s(strbuf, sizeof(strbuf), errno);
named_main_earlywarning("could not open file '%s': %s",
filename, strbuf);
return (NULL);
......@@ -239,7 +238,7 @@ named_os_openfile(const char *filename, int mode, bool switch_user) {
fp = fdopen(fd, "w");
if (fp == NULL) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_s(strbuf, sizeof(strbuf), errno);
named_main_earlywarning("could not fdopen() file '%s': %s",
filename, strbuf);
close(fd);
......@@ -268,7 +267,7 @@ named_os_writepidfile(const char *filename, bool first_time) {
pidfile = strdup(filename);
if (pidfile == NULL) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_s(strbuf, sizeof(strbuf), errno);
(*report)("couldn't strdup() '%s': %s", filename, strbuf);
return;
}
......@@ -312,7 +311,7 @@ named_os_issingleton(const char *filename) {
lockfile = strdup(filename);
if (lockfile == NULL) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_s(strbuf, sizeof(strbuf), errno);
named_main_earlyfatal("couldn't allocate memory for '%s': %s",
filename, strbuf);
}
......
......@@ -2085,8 +2085,6 @@ then
AC_CHECK_HEADERS(readline/history.h)
fi
AC_CHECK_FUNC(strerror, AC_DEFINE(HAVE_STRERROR))
#
# Use our own SPNEGO implementation?
#
......
......@@ -35,7 +35,6 @@
#include <isc/result.h>
#include <isc/string.h>
#include <isc/util.h>
#include <isc/strerror.h>
#include <dns/fixedname.h>
#include <dns/name.h>
......@@ -82,7 +81,7 @@ ux_socket_connect(const char *path) {
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd == -1) {
char strbuf[ISC_STRERRORSIZE];
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
ssu_e_log(3, "ssu_external: unable to create socket - %s",
strbuf);
return (-1);
......@@ -90,7 +89,7 @@ ux_socket_connect(const char *path) {
if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
char strbuf[ISC_STRERRORSIZE];
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
ssu_e_log(3, "ssu_external: unable to connect to "
"socket '%s' - %s",
path, strbuf);
......@@ -224,7 +223,7 @@ dns_ssu_external_match(const dns_name_t *identity,
isc_mem_free(mctx, data);
if (ret != (ssize_t) req_len) {
char strbuf[ISC_STRERRORSIZE];
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
ssu_e_log(3, "ssu_external: unable to send request - %s",
strbuf);
close(fd);
......@@ -235,7 +234,7 @@ dns_ssu_external_match(const dns_name_t *identity,
ret = read(fd, &reply, sizeof(uint32_t));
if (ret != (ssize_t) sizeof(uint32_t)) {
char strbuf[ISC_STRERRORSIZE];
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
ssu_e_log(3, "ssu_external: unable to receive reply - %s",
strbuf);
close(fd);
......
......@@ -29,7 +29,6 @@
#include <isc/serial.h>
#include <isc/stats.h>
#include <isc/stdtime.h>
#include <isc/strerror.h>
#include <isc/string.h>
#include <isc/taskpool.h>
#include <isc/thread.h>
......@@ -4593,7 +4592,7 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
"removing journal file");
if (remove(zone->journal) < 0 && errno != ENOENT) {
char strbuf[ISC_STRERRORSIZE];
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
isc_log_write(dns_lctx,
DNS_LOGCATEGORY_GENERAL,
DNS_LOGMODULE_ZONE,
......@@ -15112,7 +15111,7 @@ zone_replacedb(dns_zone_t *zone, dns_db_t *db, bool dump) {
zone->journal);
if (result != ISC_R_SUCCESS) {
char strbuf[ISC_STRERRORSIZE];
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
dns_zone_log(zone, ISC_LOG_ERROR,
"ixfr-from-differences: failed: "
"%s", strbuf);
......@@ -15134,7 +15133,7 @@ zone_replacedb(dns_zone_t *zone, dns_db_t *db, bool dump) {
if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_FORCEXFER) &&
remove(zone->masterfile) < 0 && errno != ENOENT) {
char strbuf[ISC_STRERRORSIZE];
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
isc_log_write(dns_lctx,
DNS_LOGCATEGORY_GENERAL,
DNS_LOGMODULE_ZONE,
......@@ -15165,7 +15164,7 @@ zone_replacedb(dns_zone_t *zone, dns_db_t *db, bool dump) {
"removing journal file");
if (remove(zone->journal) < 0 && errno != ENOENT) {
char strbuf[ISC_STRERRORSIZE];
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
isc_log_write(dns_lctx,
DNS_LOGCATEGORY_GENERAL,
DNS_LOGMODULE_ZONE,
......
......@@ -31,7 +31,7 @@ UNIXOBJS = unix/pk11_api.@O@ \
unix/errno2result.@O@ unix/file.@O@ unix/fsaccess.@O@ \
unix/interfaceiter.@O@ unix/keyboard.@O@ unix/meminfo.@O@ \
unix/net.@O@ unix/os.@O@ unix/resource.@O@ unix/socket.@O@ \
unix/stdio.@O@ unix/stdtime.@O@ unix/strerror.@O@ \
unix/stdio.@O@ unix/stdtime.@O@ \
unix/syslog.@O@ unix/time.@O@
NLSOBJS = nls/msgcat.@O@
......
......@@ -26,6 +26,12 @@
#define thread_local __thread
#endif
/***
*** Default strerror_r buffer size
***/
#define ISC_STRERRORSIZE 128
/***
*** Network.
***/
......
......@@ -18,7 +18,6 @@
#include <isc/condition.h>
#include <isc/msgs.h>
#include <isc/strerror.h>
#include <isc/string.h>
#include <isc/time.h>
#include <isc/util.h>
......@@ -64,7 +63,7 @@ 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));
strerror_r(presult, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"pthread_cond_timedwait() %s %s",
isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
......
......@@ -16,6 +16,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include <errno.h>
......@@ -23,7 +24,6 @@
#include <isc/mutex.h>
#include <isc/util.h>
#include <isc/print.h>
#include <isc/strerror.h>
#include <isc/once.h>
#if ISC_MUTEX_PROFILE
......@@ -292,7 +292,7 @@ isc__mutex_init(isc_mutex_t *mp, const char *file, unsigned int line) {
if (err == ENOMEM)
return (ISC_R_NOMEMORY);
if (err != 0) {
isc__strerror(err, strbuf, sizeof(strbuf));
strerror_r(err, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(file, line, "isc_mutex_init() failed: %s",
strbuf);
result = ISC_R_UNEXPECTED;
......
......@@ -26,19 +26,18 @@ OBJS = pk11_api.@O@ \
file.@O@ fsaccess.@O@ interfaceiter.@O@ \
keyboard.@O@ meminfo.@O@ \
net.@O@ os.@O@ resource.@O@ socket.@O@ stdio.@O@ stdtime.@O@ \
strerror.@O@ syslog.@O@ time.@O@
syslog.@O@ time.@O@
# Alphabetically
SRCS = pk11_api.c \
app.c dir.c errno.c errno2result.c \
file.c fsaccess.c interfaceiter.c keyboard.c meminfo.c \
net.c os.c resource.c socket.c stdio.c stdtime.c \
strerror.c syslog.c time.c
syslog.c time.c
SUBDIRS = include
TARGETS = ${OBJS}
@BIND9_MAKE_RULES@
interfaceiter.@O@: interfaceiter.c ifiter_ioctl.c ifiter_sysctl.c ifiter_getifaddrs.c
interfaceiter.@O@: interfaceiter.c ifiter_getifaddrs.c
......@@ -28,6 +28,7 @@
#include <sys/epoll.h>
#endif
#include <isc/platform.h>
#include <isc/app.h>
#include <isc/condition.h>
#include <isc/mem.h>
......@@ -35,7 +36,6 @@
#include <isc/mutex.h>
#include <isc/event.h>
#include <isc/platform.h>
#include <isc/strerror.h>
#include <isc/string.h>
#include <isc/task.h>
#include <isc/time.h>
......@@ -181,7 +181,7 @@ handle_signal(int sig, void (*handler)(int)) {
if (sigfillset(&sa.sa_mask) != 0 ||
sigaction(sig, &sa, NULL) < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
isc_msgcat_get(isc_msgcat, ISC_MSGSET_APP,
ISC_MSG_SIGNALSETUP,
......@@ -213,7 +213,7 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
*/
presult = pthread_init();
if (presult != 0) {
isc__strerror(presult, strbuf, sizeof(strbuf));
strerror_r(presult, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_app_start() pthread_init: %s", strbuf);
return (ISC_R_UNEXPECTED);
......@@ -302,7 +302,7 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
sigaddset(&sset, SIGHUP) != 0 ||
sigaddset(&sset, SIGINT) != 0 ||
sigaddset(&sset, SIGTERM) != 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_app_start() sigsetops: %s", strbuf);
result = ISC_R_UNEXPECTED;
......@@ -310,7 +310,7 @@ isc__app_ctxstart(isc_appctx_t *ctx0) {
}
presult = pthread_sigmask(SIG_BLOCK, &sset, NULL);
if (presult != 0) {
isc__strerror(presult, strbuf, sizeof(strbuf));
strerror_r(presult, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_app_start() pthread_sigmask: %s",
strbuf);
......@@ -450,7 +450,7 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
sigaddset(&sset, SIGHUP) != 0 ||
sigaddset(&sset, SIGINT) != 0 ||
sigaddset(&sset, SIGTERM) != 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_app_run() sigsetops: %s",
strbuf);
......@@ -502,7 +502,7 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
return (ISC_R_SUCCESS);
if (sigemptyset(&sset) != 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_app_run() sigsetops: %s",
strbuf);
......@@ -510,7 +510,7 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
}
#ifdef HAVE_GPERFTOOLS_PROFILER
if (sigaddset(&sset, SIGALRM) != 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_app_run() sigsetops: %s",
strbuf);
......@@ -583,7 +583,7 @@ isc__app_ctxshutdown(isc_appctx_t *ctx0) {
result = pthread_kill(main_thread, SIGTERM);
if (result != 0) {
isc__strerror(result,
strerror_r(result,
strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_app_shutdown() "
......@@ -596,7 +596,7 @@ isc__app_ctxshutdown(isc_appctx_t *ctx0) {
if (isc_bind9) {
/* BIND9 internal, single context */
if (kill(getpid(), SIGTERM) < 0) {
isc__strerror(errno,
strerror_r(errno,
strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_app_shutdown() "
......@@ -656,7 +656,7 @@ isc__app_ctxsuspend(isc_appctx_t *ctx0) {
result = pthread_kill(main_thread, SIGHUP);
if (result != 0) {
isc__strerror(result,
strerror_r(result,
strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_app_reload() "
......@@ -669,7 +669,7 @@ isc__app_ctxsuspend(isc_appctx_t *ctx0) {
if (isc_bind9) {
/* BIND9 internal, single context */
if (kill(getpid(), SIGHUP) < 0) {
isc__strerror(errno,
strerror_r(errno,
strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_app_reload() "
......
......@@ -15,9 +15,10 @@
#include <config.h>
#include <stdbool.h>
#include <string.h>
#include <isc/platform.h>
#include <isc/result.h>
#include <isc/strerror.h>
#include <isc/util.h>
#include "errno2result.h"
......@@ -109,7 +110,7 @@ isc___errno2result(int posixerrno, bool dolog,
return (ISC_R_CONNREFUSED);
default:
if (dolog) {
isc__strerror(posixerrno, strbuf, sizeof(strbuf));
strerror_r(posixerrno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(file, line, "unable to convert errno "
"to isc_result: %d: %s",
posixerrno, strbuf);
......
......@@ -77,7 +77,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
#endif
if (getifaddrs(&iter->ifaddrs) < 0) {
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));
UNEXPECTED_ERROR(__FILE__, __LINE__,
isc_msgcat_get(isc_msgcat,
ISC_MSGSET_IFITERGETIFADDRS,
......
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#ifndef ISC_STRERROR_H
#define ISC_STRERROR_H
/*! \file */
#include <sys/types.h>
#include <isc/lang.h>
ISC_LANG_BEGINDECLS
/*% String Error Size */
#define ISC_STRERRORSIZE 128
/*%
* Provide a thread safe wrapper to strerror().
*
* Requires:
* 'buf' to be non NULL.
*/
void
isc__strerror(int num, char *buf, size_t bufsize);
ISC_LANG_ENDDECLS
#endif /* ISC_STRERROR_H */
......@@ -34,7 +34,6 @@
#include <isc/net.h>
#include <isc/print.h>
#include <isc/result.h>
#include <isc/strerror.h>
#include <isc/string.h>
#include <isc/types.h>
#include <isc/util.h>
......
......@@ -32,7 +32,6 @@
#include <isc/net.h>
#include <isc/netdb.h>
#include <isc/once.h>
#include <isc/strerror.h>
#include <isc/string.h>
#include <isc/util.h>
......@@ -137,7 +136,7 @@ try_proto(int domain) {
#endif
return (ISC_R_NOTFOUND);
default:
isc__strerror(errno, strbuf, sizeof(strbuf));
strerror_r(errno, strbuf, sizeof(strbuf));