diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2023-01-16 14:15:27 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2023-02-12 23:42:24 +0100 |
commit | 7a8ed9459dfe803c529d61d3741d8d4f8f67ea92 (patch) | |
tree | 53b322cc77a651623e9498aecd516993743619a6 /inany.h | |
parent | cc6d8286d1043d04eb8518e39cebcb9e086dca17 (diff) | |
download | passt-7a8ed9459dfe803c529d61d3741d8d4f8f67ea92.tar passt-7a8ed9459dfe803c529d61d3741d8d4f8f67ea92.tar.gz passt-7a8ed9459dfe803c529d61d3741d8d4f8f67ea92.tar.bz2 passt-7a8ed9459dfe803c529d61d3741d8d4f8f67ea92.tar.lz passt-7a8ed9459dfe803c529d61d3741d8d4f8f67ea92.tar.xz passt-7a8ed9459dfe803c529d61d3741d8d4f8f67ea92.tar.zst passt-7a8ed9459dfe803c529d61d3741d8d4f8f67ea92.zip |
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>
Diffstat (limited to 'inany.h')
-rw-r--r-- | inany.h | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -6,8 +6,6 @@ * IPv6 or IPv4 (encoded as IPv4-mapped IPv6 addresses) */ -#include <assert.h> - /** union inany_addr - Represents either an IPv4 or IPv6 address * @a6: Address as an IPv6 address, may be IPv4-mapped * @v4mapped.zero: All zero-bits for an IPv4 address @@ -63,7 +61,7 @@ static inline void inany_from_af(union inany_addr *aa, int af, const void *addr) aa->v4mapped.a4 = *((struct in_addr *)addr); } else { /* Not valid to call with other address families */ - assert(0); + ASSERT(0); } } @@ -89,6 +87,6 @@ static inline void inany_from_sockaddr(union inany_addr *aa, in_port_t *port, *port = ntohs(sa4->sin_port); } else { /* Not valid to call with other address families */ - assert(0); + ASSERT(0); } } |