[PATCH] ioctl: fix conflicts command number decoding in case of conflicts

Gabriel Laskar gabriel at lse.epita.fr
Tue Sep 22 23:45:52 UTC 2015


When a command number was decoded through ioctl_decode_command_number(),
there was no check for conflicts with other potential ioctls numbers.

For example:
	ioctl(fd, MCE_GET_RECORD_LEN, &i);
output:
	ioctl(3, MIXER_READ(1), 0x7ffddce74a58) = 0
instead of:
	ioctl(3, MIXER_READ(1) or MCE_GET_RECORD_LEN, 0x7ffee435ce08) = 0

* ioctl.c (SYS_FUNC(ioctl)): fix ioctl command number decoding in case of conflicts

Signed-off-by: Gabriel Laskar <gabriel at lse.epita.fr>
---
 ioctl.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/ioctl.c b/ioctl.c
index 284828a..8741d70 100644
--- a/ioctl.c
+++ b/ioctl.c
@@ -277,15 +277,16 @@ SYS_FUNC(ioctl)
 	if (entering(tcp)) {
 		printfd(tcp, tcp->u_arg[0]);
 		tprints(", ");
-		if (!ioctl_decode_command_number(tcp)) {
-			iop = ioctl_lookup(tcp->u_arg[1]);
-			if (iop) {
-				tprints(iop->symbol);
-				while ((iop = ioctl_next_match(iop)))
-					tprintf(" or %s", iop->symbol);
-			} else {
+		ret = ioctl_decode_command_number(tcp);
+		iop = ioctl_lookup(tcp->u_arg[1]);
+		if (!iop && !ret) {
 				ioctl_print_code(tcp->u_arg[1]);
-			}
+		} else {
+			if (ret)
+				tprints(" or ");
+			tprints(iop->symbol);
+			while ((iop = ioctl_next_match(iop)))
+				tprintf(" or %s", iop->symbol);
 		}
 		ret = ioctl_decode(tcp);
 	} else {
-- 
2.5.0





More information about the Strace-devel mailing list