diff options
author | Nathan Bossart | 2025-03-07 21:23:09 +0000 |
---|---|---|
committer | Nathan Bossart | 2025-03-07 21:23:09 +0000 |
commit | 088f8e2d568eaa963fe68a15287002081314fad8 (patch) | |
tree | 6daa6fd91acf8350e09f6ee8dfff5e4fc3260ede | |
parent | 34c3c5ce1c0b2a27de212076c2e5aaa8e82fac31 (diff) |
Assert that wrapper_handler()'s argument is within expected range.
pqsignal() already does a similar check, but strange Valgrind
reports have us wondering if wrapper_handler() is somehow getting
called with an invalid signal number.
Reported-by: Tomas Vondra <[email protected]>
Suggested-by: Andres Freund <[email protected]>
Discussion: https://postgr.es/m/ace01111-f9ac-4f61-b1b1-8e9379415444%40vondra.me
Backpatch-through: 17
-rw-r--r-- | src/port/pqsignal.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/port/pqsignal.c b/src/port/pqsignal.c index 5dd8b76bae8..26943845e21 100644 --- a/src/port/pqsignal.c +++ b/src/port/pqsignal.c @@ -87,6 +87,9 @@ wrapper_handler(SIGNAL_ARGS) { int save_errno = errno; + Assert(postgres_signal_arg > 0); + Assert(postgres_signal_arg < PG_NSIG); + #ifndef FRONTEND /* @@ -123,6 +126,7 @@ pqsignal(int signo, pqsigfunc func) struct sigaction act; #endif + Assert(signo > 0); Assert(signo < PG_NSIG); if (func != SIG_IGN && func != SIG_DFL) |