From d699dac08778c597eefac1067a325059925e87e6 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Tue, 2 Jul 2024 13:46:48 +0200 Subject: util: Fix system call name resolution in syscall_name() debug function Fix the starting index, otherwise we miss the first call in sets (say, mknod in filesystem calls). And if we don't find a matching name for the system call, actually return it, instead of trying to fetch it from the current (invalid) call. Fixes: bdbec30a8498 ("seitan: Add netlink, sendto()/sendmsg(), iovec handling, demo with routes") Signed-off-by: Stefano Brivio --- common/util.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/util.c b/common/util.c index 3164126..f0a1df4 100644 --- a/common/util.c +++ b/common/util.c @@ -68,14 +68,16 @@ const char *syscall_name(long nr) { if (!call->name) { set++; call = set[0]; - continue; + + if (!*set) + return "unknown"; } if (nr == call->number) break; } - return call ? call->name : "unknown"; + return call->name; } const char *syscall_name_str[N_SYSCALL + 1] = { -- cgit v1.2.3