Skip to content

Commit c3510cf

Browse files
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
1 parent 5c8dcf9 commit c3510cf

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/port/pqsignal.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ wrapper_handler(SIGNAL_ARGS)
8787
{
8888
int save_errno = errno;
8989

90+
Assert(postgres_signal_arg > 0);
91+
Assert(postgres_signal_arg < PG_NSIG);
92+
9093
#ifndef FRONTEND
9194

9295
/*
@@ -139,6 +142,7 @@ pqsignal(int signo, pqsigfunc func)
139142
pqsigfunc ret;
140143
#endif
141144

145+
Assert(signo > 0);
142146
Assert(signo < PG_NSIG);
143147

144148
if (func != SIG_IGN && func != SIG_DFL)

0 commit comments

Comments
 (0)