|
|
35b686 |
From 96194ed74158f0b9976fae43a910ad14eaea141e Mon Sep 17 00:00:00 2001
|
|
|
35b686 |
From: Eugene Syromyatnikov <evgsyr@gmail.com>
|
|
|
35b686 |
Date: Fri, 12 Jul 2019 14:57:28 +0200
|
|
|
35b686 |
Subject: [PATCH 2/3] evdev: fix array size calculation in decode_bitset_
|
|
|
35b686 |
|
|
|
35b686 |
max_nr is in bits (as it is a number of flags), result is in bytes, and
|
|
|
35b686 |
the array allocation has to be in personality words.
|
|
|
35b686 |
|
|
|
35b686 |
There's still an open question, however, what to do on big-endian
|
|
|
35b686 |
architectures when a non-divisible-by-4 value is returned.
|
|
|
35b686 |
|
|
|
35b686 |
* evdev.c (decode_bitset_): Declare size_bits, initialise it and use it
|
|
|
35b686 |
later instead of size; round up size by personality's word boundary.
|
|
|
35b686 |
---
|
|
|
35b686 |
evdev.c | 12 ++++++++----
|
|
|
35b686 |
1 file changed, 8 insertions(+), 4 deletions(-)
|
|
|
35b686 |
|
|
|
35b686 |
diff --git a/evdev.c b/evdev.c
|
|
|
35b686 |
index 4b811cf8..a3d9cb55 100644
|
|
|
35b686 |
--- a/evdev.c
|
|
|
35b686 |
+++ b/evdev.c
|
|
|
35b686 |
@@ -151,10 +151,14 @@ decode_bitset_(struct tcb *const tcp, const kernel_ulong_t arg,
|
|
|
35b686 |
tprints(", ");
|
|
|
35b686 |
|
|
|
35b686 |
unsigned int size;
|
|
|
35b686 |
+ unsigned int size_bits;
|
|
|
35b686 |
+
|
|
|
35b686 |
if ((kernel_ulong_t) tcp->u_rval > max_nr / 8)
|
|
|
35b686 |
- size = max_nr;
|
|
|
35b686 |
+ size_bits = max_nr;
|
|
|
35b686 |
else
|
|
|
35b686 |
- size = tcp->u_rval * 8;
|
|
|
35b686 |
+ size_bits = tcp->u_rval * 8;
|
|
|
35b686 |
+
|
|
|
35b686 |
+ size = ROUNDUP(ROUNDUP_DIV(size_bits, 8), current_wordsize);
|
|
|
35b686 |
|
|
|
35b686 |
if (syserror(tcp) || !size) {
|
|
|
35b686 |
printaddr(arg);
|
|
|
35b686 |
@@ -170,13 +174,13 @@ decode_bitset_(struct tcb *const tcp, const kernel_ulong_t arg,
|
|
|
35b686 |
tprints("[");
|
|
|
35b686 |
|
|
|
35b686 |
int bit_displayed = 0;
|
|
|
35b686 |
- int i = next_set_bit(decoded_arg, 0, size);
|
|
|
35b686 |
+ int i = next_set_bit(decoded_arg, 0, size_bits);
|
|
|
35b686 |
if (i < 0) {
|
|
|
35b686 |
tprints(" 0 ");
|
|
|
35b686 |
} else {
|
|
|
35b686 |
printxval_dispatch(decode_nr, decode_nr_size, i, dflt, xt);
|
|
|
35b686 |
|
|
|
35b686 |
- while ((i = next_set_bit(decoded_arg, i + 1, size)) > 0) {
|
|
|
35b686 |
+ while ((i = next_set_bit(decoded_arg, i + 1, size_bits)) > 0) {
|
|
|
35b686 |
if (abbrev(tcp) && bit_displayed >= 3) {
|
|
|
35b686 |
tprints(", ...");
|
|
|
35b686 |
break;
|
|
|
35b686 |
--
|
|
|
35b686 |
2.13.6
|
|
|
35b686 |
|