sd-event: do not assert on invalid signal
authorDavid Tardon <dtardon@redhat.com>
Thu, 25 Jul 2024 08:06:34 +0000 (10:06 +0200)
committerLuca Boccassi <bluca@debian.org>
Thu, 15 Aug 2024 10:07:56 +0000 (11:07 +0100)
The signalfd_siginfo struct is received from outside via a FD, hence
assert() is not appropriate way to check it. Just do a normal runtime
check.

(cherry picked from commit 7a64c5f23efbb51fe4f1229c1a8aed6dd858a0a9)

src/libsystemd/sd-event/sd-event.c

index a1305ef01493e76d63314e9abe8166757f83c1f4..ffea0ba082d86c56e5acc6f46cf121ef9374a9b3 100644 (file)
@@ -3866,7 +3866,8 @@ static int process_signal(sd_event *e, struct signal_data *d, uint32_t events, i
                 if (_unlikely_(n != sizeof(si)))
                         return -EIO;
 
-                assert(SIGNAL_VALID(si.ssi_signo));
+                if (_unlikely_(!SIGNAL_VALID(si.ssi_signo)))
+                        return -EINVAL;
 
                 if (e->signal_sources)
                         s = e->signal_sources[si.ssi_signo];