1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-21 15:54:08 +03:00

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 <tomas@vondra.me>
Suggested-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/ace01111-f9ac-4f61-b1b1-8e9379415444%40vondra.me
Backpatch-through: 17
This commit is contained in:
Nathan Bossart 2025-03-07 15:23:09 -06:00
parent 5c8dcf9483
commit c3510cfc8b

View File

@ -87,6 +87,9 @@ wrapper_handler(SIGNAL_ARGS)
{ {
int save_errno = errno; int save_errno = errno;
Assert(postgres_signal_arg > 0);
Assert(postgres_signal_arg < PG_NSIG);
#ifndef FRONTEND #ifndef FRONTEND
/* /*
@ -139,6 +142,7 @@ pqsignal(int signo, pqsigfunc func)
pqsigfunc ret; pqsigfunc ret;
#endif #endif
Assert(signo > 0);
Assert(signo < PG_NSIG); Assert(signo < PG_NSIG);
if (func != SIG_IGN && func != SIG_DFL) if (func != SIG_IGN && func != SIG_DFL)