Blame SOURCES/0001-avoid-zero-length-VLA-in-evdev_c.patch

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