Blob Blame History Raw
Index: strace-5.1/evdev.c
===================================================================
--- strace-5.1.orig/evdev.c	2018-12-30 16:35:21.000000000 +0100
+++ strace-5.1/evdev.c	2019-06-13 23:40:59.136316390 +0200
@@ -151,25 +151,36 @@
 	tprints(", ");
 
 	unsigned int size;
-	if ((kernel_ulong_t) tcp->u_rval > max_nr / 8)
-		size = max_nr;
+	unsigned int size_bits;
+
+	if ((kernel_ulong_t) tcp->u_rval > max_nr / CHAR_BIT)
+		size_bits = max_nr;
 	else
-		size = tcp->u_rval * 8;
+		size_bits = tcp->u_rval * CHAR_BIT;
+
+	size = ROUNDUP(ROUNDUP_DIV(size_bits, CHAR_BIT), current_wordsize);
+
+	if (syserror(tcp) || !size) {
+		printaddr(arg);
+
+		return RVAL_IOCTL_DECODED;
+	}
+
 	char decoded_arg[size];
 
-	if (umove_or_printaddr(tcp, arg, &decoded_arg))
+	if (umoven_or_printaddr(tcp, arg, size, decoded_arg))
 		return RVAL_IOCTL_DECODED;
 
 	tprints("[");
 
 	int bit_displayed = 0;
-	int i = next_set_bit(decoded_arg, 0, size);
+	int i = next_set_bit(decoded_arg, 0, size_bits);
 	if (i < 0) {
 		tprints(" 0 ");
 	} else {
 		printxval_dispatch(decode_nr, decode_nr_size, i, dflt, xt);
 
-		while ((i = next_set_bit(decoded_arg, i + 1, size)) > 0) {
+		while ((i = next_set_bit(decoded_arg, i + 1, size_bits)) > 0) {
 			if (abbrev(tcp) && bit_displayed >= 3) {
 				tprints(", ...");
 				break;
Index: strace-5.1/tests-m32/ioctl_evdev-success.c
===================================================================
--- strace-5.1.orig/tests-m32/ioctl_evdev-success.c	2018-12-25 00:46:43.000000000 +0100
+++ strace-5.1/tests-m32/ioctl_evdev-success.c	2019-06-13 22:24:38.738650209 +0200
@@ -191,17 +191,17 @@
 # endif
 
 	/* set more than 4 bits */
-	unsigned long ev_more[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED | 1 << EV_SND | 1 << EV_PWR };
+	unsigned long ev_more[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED | 1 << EV_SND | 1 << EV_PWR, 0 };
 	/* we use the first element to indicate the number of set bits */
 	/* ev_more_str[0] is "5" so the number of set bits is 5 */
 	const char *ev_more_str[] = { "5", "EV_ABS", "EV_MSC", "EV_LED", "EV_SND", "EV_PWR" };
 
 	/* set less than 4 bits */
-	unsigned long ev_less[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED };
+	unsigned long ev_less[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED, 0 };
 	const char *ev_less_str[] = { "3", "EV_ABS", "EV_MSC", "EV_LED" };
 
 	/* set zero bit */
-	unsigned long ev_zero[] = { 0x0 };
+	unsigned long ev_zero[] = { 0x0, 0 };
 	const char *ev_zero_str[] = { "0", " 0 " };
 
 	/* KEY_MAX is 0x2ff which is greater than retval * 8 */
Index: strace-5.1/tests-mx32/ioctl_evdev-success.c
===================================================================
--- strace-5.1.orig/tests-mx32/ioctl_evdev-success.c	2018-12-25 00:46:43.000000000 +0100
+++ strace-5.1/tests-mx32/ioctl_evdev-success.c	2019-06-13 22:24:58.239273608 +0200
@@ -191,17 +191,17 @@
 # endif
 
 	/* set more than 4 bits */
-	unsigned long ev_more[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED | 1 << EV_SND | 1 << EV_PWR };
+	unsigned long ev_more[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED | 1 << EV_SND | 1 << EV_PWR, 0 };
 	/* we use the first element to indicate the number of set bits */
 	/* ev_more_str[0] is "5" so the number of set bits is 5 */
 	const char *ev_more_str[] = { "5", "EV_ABS", "EV_MSC", "EV_LED", "EV_SND", "EV_PWR" };
 
 	/* set less than 4 bits */
-	unsigned long ev_less[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED };
+	unsigned long ev_less[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED, 0 };
 	const char *ev_less_str[] = { "3", "EV_ABS", "EV_MSC", "EV_LED" };
 
 	/* set zero bit */
-	unsigned long ev_zero[] = { 0x0 };
+	unsigned long ev_zero[] = { 0x0, 0 };
 	const char *ev_zero_str[] = { "0", " 0 " };
 
 	/* KEY_MAX is 0x2ff which is greater than retval * 8 */
Index: strace-5.1/tests/ioctl_evdev-success.c
===================================================================
--- strace-5.1.orig/tests/ioctl_evdev-success.c	2019-06-13 22:23:53.864516831 +0200
+++ strace-5.1/tests/ioctl_evdev-success.c	2019-06-13 22:24:19.210027351 +0200
@@ -191,17 +191,17 @@
 # endif
 
 	/* set more than 4 bits */
-	unsigned long ev_more[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED | 1 << EV_SND | 1 << EV_PWR };
+	unsigned long ev_more[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED | 1 << EV_SND | 1 << EV_PWR, 0 };
 	/* we use the first element to indicate the number of set bits */
 	/* ev_more_str[0] is "5" so the number of set bits is 5 */
 	const char *ev_more_str[] = { "5", "EV_ABS", "EV_MSC", "EV_LED", "EV_SND", "EV_PWR" };
 
 	/* set less than 4 bits */
-	unsigned long ev_less[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED };
+	unsigned long ev_less[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED, 0 };
 	const char *ev_less_str[] = { "3", "EV_ABS", "EV_MSC", "EV_LED" };
 
 	/* set zero bit */
-	unsigned long ev_zero[] = { 0x0 };
+	unsigned long ev_zero[] = { 0x0, 0 };
 	const char *ev_zero_str[] = { "0", " 0 " };
 
 	/* KEY_MAX is 0x2ff which is greater than retval * 8 */