Created
December 24, 2021 15:39
-
-
Save Azkali/4e43d38b53b228f6917ed8f34549acb8 to your computer and use it in GitHub Desktop.
m4-1.4.18-glibc-sigstksz.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/lib/c-stack.c b/lib/c-stack.c | |
| index 5353c08..863f764 100644 | |
| --- a/lib/c-stack.c | |
| +++ b/lib/c-stack.c | |
| @@ -51,13 +51,14 @@ | |
| typedef struct sigaltstack stack_t; | |
| #endif | |
| #ifndef SIGSTKSZ | |
| -# define SIGSTKSZ 16384 | |
| -#elif HAVE_LIBSIGSEGV && SIGSTKSZ < 16384 | |
| +#define get_sigstksz() (16384) | |
| +#elif HAVE_LIBSIGSEGV | |
| /* libsigsegv 2.6 through 2.8 have a bug where some architectures use | |
| more than the Linux default of an 8k alternate stack when deciding | |
| if a fault was caused by stack overflow. */ | |
| -# undef SIGSTKSZ | |
| -# define SIGSTKSZ 16384 | |
| +#define get_sigstksz() ((SIGSTKSZ) < 16384 ? 16384 : (SIGSTKSZ)) | |
| +#else | |
| +#define get_sigstksz() ((SIGSTKSZ)) | |
| #endif | |
| #include <stdlib.h> | |
| @@ -131,7 +132,8 @@ die (int signo) | |
| /* Storage for the alternate signal stack. */ | |
| static union | |
| { | |
| - char buffer[SIGSTKSZ]; | |
| + /* allocate buffer with size from get_sigstksz() */ | |
| + char *buffer; | |
| /* These other members are for proper alignment. There's no | |
| standard way to guarantee stack alignment, but this seems enough | |
| @@ -203,10 +205,11 @@ c_stack_action (void (*action) (int)) | |
| program_error_message = _("program error"); | |
| stack_overflow_message = _("stack overflow"); | |
| + alternate_signal_stack.buffer = malloc(get_sigstksz()); | |
| /* Always install the overflow handler. */ | |
| if (stackoverflow_install_handler (overflow_handler, | |
| alternate_signal_stack.buffer, | |
| - sizeof alternate_signal_stack.buffer)) | |
| + get_sigstksz())) | |
| { | |
| errno = ENOTSUP; | |
| return -1; | |
| @@ -279,14 +282,15 @@ c_stack_action (void (*action) (int)) | |
| stack_t st; | |
| struct sigaction act; | |
| st.ss_flags = 0; | |
| + alternate_signal_stack.buffer = malloc(get_sigstksz()); | |
| # if SIGALTSTACK_SS_REVERSED | |
| /* Irix mistakenly treats ss_sp as the upper bound, rather than | |
| lower bound, of the alternate stack. */ | |
| - st.ss_sp = alternate_signal_stack.buffer + SIGSTKSZ - sizeof (void *); | |
| - st.ss_size = sizeof alternate_signal_stack.buffer - sizeof (void *); | |
| + st.ss_sp = alternate_signal_stack.buffer + get_sigstksz() - sizeof (void *); | |
| + st.ss_size = get_sigstksz() - sizeof (void *); | |
| # else | |
| st.ss_sp = alternate_signal_stack.buffer; | |
| - st.ss_size = sizeof alternate_signal_stack.buffer; | |
| + st.ss_size = get_sigstksz(); | |
| # endif | |
| r = sigaltstack (&st, NULL); | |
| if (r != 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment