1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
From d611486eb337e97b15886059a1b55319bd02d3e1 Mon Sep 17 00:00:00 2001
From: Michael Forney <mforney@mforney.org>
Date: Thu, 30 Jan 2020 21:57:34 -0800
Subject: [PATCH] Use alloca when VLAs aren't available
---
evdev.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/evdev.c b/evdev.c
index 573f18f4..27eb8a38 100644
--- a/evdev.c
+++ b/evdev.c
@@ -198,9 +198,13 @@ decode_bitset(struct tcb *const tcp, const kernel_ulong_t arg,
return RVAL_IOCTL_DECODED;
}
+#ifndef __STDC_NO_VLA__
char decoded_arg[size];
+#else
+ char *decoded_arg = alloca(size);
+#endif
- if (umove_or_printaddr(tcp, arg, &decoded_arg))
+ if (umoven_or_printaddr(tcp, arg, size, decoded_arg))
return RVAL_IOCTL_DECODED;
if (xlat_verbose(xlat_verbosity) != XLAT_STYLE_RAW) {
@@ -255,9 +259,13 @@ mtslots_ioctl(struct tcb *const tcp, const unsigned int code,
return RVAL_IOCTL_DECODED;
}
+#ifndef __STDC_NO_VLA__
int buffer[size];
+#else
+ int *buffer = alloca(size * sizeof(int));
+#endif
- if (umove_or_printaddr(tcp, arg, &buffer))
+ if (umoven_or_printaddr(tcp, arg, size * sizeof(int), &buffer))
return RVAL_IOCTL_DECODED;
tprints("{code=");
@@ -266,7 +274,7 @@ mtslots_ioctl(struct tcb *const tcp, const unsigned int code,
tprints(", values=[");
unsigned int i;
- for (i = 1; i < ARRAY_SIZE(buffer); i++)
+ for (i = 1; i < size; i++)
tprintf("%s%d", i > 1 ? ", " : "", buffer[i]);
tprints("]}");
--
2.25.0
|