mirror of
https://passt.top/passt
synced 2025-06-18 21:15:34 +02:00
Make assertions actually useful
There are some places in passt/pasta which #include <assert.h> and make various assertions. If we hit these something has already gone wrong, but they're there so that we a useful message instead of cryptic misbehaviour if assumptions we thought were correct turn out not to be. Except.. the glibc implementation of assert() uses syscalls that aren't in our seccomp filter, so we'll get a SIGSYS before it actually prints the message. Work around this by adding our own ASSERT() implementation using our existing err() function to log the message, and an abort(). The abort() probably also won't work exactly right with seccomp, but once we've printed the message, dying with a SIGSYS works just as well as dying with a SIGABRT. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
cc6d8286d1
commit
7a8ed9459d
7 changed files with 32 additions and 20 deletions
3
udp.c
3
udp.c
|
@ -108,7 +108,6 @@
|
|||
#include <sys/uio.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "checksum.h"
|
||||
#include "util.h"
|
||||
|
@ -248,7 +247,7 @@ static void udp_invert_portmap(struct udp_port_fwd *fwd)
|
|||
{
|
||||
int i;
|
||||
|
||||
assert(ARRAY_SIZE(fwd->f.delta) == ARRAY_SIZE(fwd->rdelta));
|
||||
ASSERT(ARRAY_SIZE(fwd->f.delta) == ARRAY_SIZE(fwd->rdelta));
|
||||
for (i = 0; i < ARRAY_SIZE(fwd->f.delta); i++) {
|
||||
in_port_t delta = fwd->f.delta[i];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue