summaryrefslogtreecommitdiff
path: root/modules/c-stack
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-09-20 11:48:17 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2020-09-20 15:48:44 -0700
commit8ba9126d00bfe1ab77a5c820c58c68933d4df85c (patch)
tree84ebf8918a3ba65aba4229ec55f5670733adcae5 /modules/c-stack
parent17a6bcd48f271a42880eb9657002de2a497a6a7e (diff)
downloadgnulib-8ba9126d00bfe1ab77a5c820c58c68933d4df85c.tar.gz
c-stack: improve checking if !libsigsegv
If SIGINFO_WORKS, do not treat a null pointer dereference as if it were a stack overflow. Use uintptr_t and INT_ADD_WRAPV to avoid unlikely pointer overflow. Also, fix some obsolete code and typos. I found these problems while looking into this bug report: https://lists.gnu.org/r/grep-devel/2020-09/msg00053.html * lib/c-stack.c: Include c-stack.h first, to test interface. Include inttypes.h for UINTPTR_MAX, stdbool.h, stddef.h for max_align_t, intprops.h for INT_ADD_WRAPV. (USE_LIBSIGSEGV): New macro; use it to simplify later code. (SIGSTKSZ): Simplify setup. Work around libsigsegv bug only for libsigsegv 2.8 and earlier since the bug should be fixed after that. (alternate_signal_stack): Use max_align_t instead of doing it by hand. (segv_handler, overflow_handler, segv_handler) [DEBUG]: Assume sprintf returns byte count; this assumption is safe now. (page_size): New static volatile variable, since sysconf isn’t documented to be async-signal-safe on Solaris. This variable is present and used if (!USE_LIBSIGSEGV && HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK && HAVE_STACK_OVERFLOW_HANDLING && SIGINFO_WORKS). (segv_handler): Use it if present. Never report null pointer dereference as a stack overflow. Check for (unlikely) unsigned and/or pointer overflow. * m4/c-stack.m4 (AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC): Rename cache variables to gl_cv_sys_stack_overflow_works and gl_cv_sys_xsi_stack_overflow_heuristic. All uses changed. (gl_PREREQ_C_STACK): Do not require AC_FUNC_ALLOCA, since c-stack no longer uses STACK_DIRECTION. Do not check for unistd.h, since we depend on unistd. Fix shell typo ‘$"ac_cv_sys_xsi_stack_overflow_heuristic"’. * modules/c-stack (Depends-on): Sort. Add intprops, inttypes, stdbool, stddef.
Diffstat (limited to 'modules/c-stack')
-rw-r--r--modules/c-stack12
1 files changed, 8 insertions, 4 deletions
diff --git a/modules/c-stack b/modules/c-stack
index ca2c208e1a..8c898eb9e9 100644
--- a/modules/c-stack
+++ b/modules/c-stack
@@ -7,15 +7,19 @@ lib/c-stack.c
m4/c-stack.m4
Depends-on:
-gettext-h
errno
exitfail
+getprogname
+gettext-h
ignore-value
-unistd
+intprops
+inttypes
+libsigsegv
raise
sigaction
-libsigsegv
-getprogname
+stdbool
+stddef
+unistd
configure.ac:
gl_C_STACK