summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2020-10-18 17:58:49 +0200
committerDaiki Ueno <ueno@gnu.org>2020-10-18 19:22:35 +0200
commit38ef9af88193c42114548b0ad5776db0ac60e5d4 (patch)
treee486df99b1d12a5743ad3e06c71477cb378488a0
parentc4300904e80fb8f603938ebcc00b1a161df42726 (diff)
downloadgnutls-tmp-src-fixes.tar.gz
serv: use only async-signal-safe functions in signal handlerstmp-src-fixes
Signed-off-by: Daiki Ueno <ueno@gnu.org>
-rw-r--r--bootstrap.conf4
-rw-r--r--src/serv.c13
2 files changed, 14 insertions, 3 deletions
diff --git a/bootstrap.conf b/bootstrap.conf
index 387c4f8d51..8f7da96fd1 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -28,7 +28,7 @@ required_submodules="tests/suite/tls-fuzzer/python-ecdsa tests/suite/tls-fuzzer/
# Reproduce by: gnulib-tool --import --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --avoid=lock-tests --avoid=lseek-tests --lgpl=2 --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files alloca attribute byteswap c-ctype extensions fopen-gnu func gendocs getline gettext-h gettimeofday hash-pjw-bare havelib intprops ldd lib-msvc-compat lib-symbol-versions maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html read-file secure_getenv snprintf stdint strcase strndup strtok_r strverscmp sys_socket sys_stat threadlib time_r unistd vasprintf verify vsnprintf warnings
gnulib_modules="
-alloca attribute byteswap c-ctype c-strcase extensions fopen-gnu func gendocs getline gettext-h gettimeofday hash hash-pjw-bare havelib arpa_inet inet_ntop inet_pton intprops ldd lib-msvc-compat lib-symbol-versions maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html read-file secure_getenv setsockopt snprintf stdint strcase strdup-posix strndup strtok_r strverscmp sys_socket sys_stat sys_types threadlib time_r unistd valgrind-tests vasprintf verify vsnprintf warnings
+alloca attribute byteswap c-ctype c-strcase extensions fopen-gnu func gendocs getline gettext-h gettimeofday hash hash-pjw-bare havelib arpa_inet inet_ntop inet_pton intprops ldd lib-msvc-compat lib-symbol-versions maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html read-file secure_getenv setsockopt snprintf stdint stpcpy strcase strdup-posix strndup strtok_r strverscmp sys_socket sys_stat sys_types threadlib time_r unistd valgrind-tests vasprintf verify vsnprintf warnings
"
unistring_modules="
@@ -36,7 +36,7 @@ unictype/category-all unictype/property-default-ignorable-code-point unictype/pr
"
src_modules="
-accept bind close connect getaddrinfo getpass gettext-h arpa_inet inet_ntop inet_pton inttypes listen linked-list minmax parse-datetime progname read-file recv recvfrom select send sendto servent setsockopt shutdown socket sockets socklen xalloc xlist xsize
+accept bind close connect getaddrinfo getpass gettext-h arpa_inet inet_ntop inet_pton inttypes listen linked-list minmax parse-datetime progname read-file recv recvfrom select send sendto servent setsockopt shutdown socket sockets socklen stpcpy xalloc xlist xsize
"
# Build prerequisites
diff --git a/src/serv.c b/src/serv.c
index add0ee4065..258af18d81 100644
--- a/src/serv.c
+++ b/src/serv.c
@@ -1123,7 +1123,18 @@ static void terminate(int sig) __attribute__ ((__noreturn__));
static void terminate(int sig)
{
- fprintf(stderr, "Exiting via signal %d\n", sig);
+ char buf[64] = { 0 };
+ char *p;
+
+ /* This code must be async-signal-safe. */
+ p = stpcpy(buf, "Exiting via signal ");
+
+ if (sig > 10)
+ *p++ = '0' + sig / 10;
+ *p++ = '0' + sig % 10;
+ *p++ = '\n';
+
+ write(STDERR_FILENO, buf, p - buf);
exit(1);
}