]> granicus.if.org Git - strace/commitdiff
syscall.c: avoid infinite loop in subcalls parsing
authorEugene Syromyatnikov <evgsyr@gmail.com>
Tue, 4 Sep 2018 12:48:13 +0000 (14:48 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 8 Jul 2019 15:14:34 +0000 (15:14 +0000)
clang complains about it, so it might be a good reason to refactor it
into something more linear.

* syscall.c (syscall_entering_decode): Put syscall subcall decoding
before ipc/socket subcall decoding, remove the loop.

syscall.c

index bae7343c3b590ca07cd4b6070ae26c89465e6781..a67d7442dc4889398a2a8b424cf1dd303921f1f0 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -579,11 +579,13 @@ syscall_entering_decode(struct tcb *tcp)
                return res;
        }
 
+# ifdef SYS_syscall_subcall
+       if (tcp_sysent(tcp)->sen == SEN_syscall)
+               decode_syscall_subcall(tcp);
+# endif
 #if defined SYS_ipc_subcall    \
- || defined SYS_socket_subcall \
- || defined SYS_syscall_subcall
-       for (;;) {
-               switch (tcp_sysent(tcp)->sen) {
+ || defined SYS_socket_subcall
+       switch (tcp_sysent(tcp)->sen) {
 # ifdef SYS_ipc_subcall
                case SEN_ipc:
                        decode_ipc_subcall(tcp);
@@ -594,15 +596,6 @@ syscall_entering_decode(struct tcb *tcp)
                        decode_socket_subcall(tcp);
                        break;
 # endif
-# ifdef SYS_syscall_subcall
-               case SEN_syscall:
-                       decode_syscall_subcall(tcp);
-                       if (tcp_sysent(tcp)->sen != SEN_syscall)
-                               continue;
-                       break;
-# endif
-               }
-               break;
        }
 #endif