summaryrefslogtreecommitdiff
path: root/pkg/iproute2/patch/0010-Use-alloca-instead-of-VLA-when-VLA-is-not-available.patch
blob: 4f8b132f408240412b06d5e57f159db1c743bf57 (plain)
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
From e4114a995209c39d5a65aa2114d82b195ced17b2 Mon Sep 17 00:00:00 2001
From: Michael Forney <mforney@mforney.org>
Date: Mon, 24 Jun 2019 16:48:56 -0700
Subject: [PATCH] Use alloca instead of VLA when VLA is not available

---
 ip/ipaddress.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 9f062217..3c195bb8 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -245,7 +245,12 @@ static void print_linktype(FILE *fp, struct rtattr *tb)
 
 		lu = get_link_kind(kind);
 		if (lu && lu->print_opt) {
-			struct rtattr *attr[lu->maxattr+1], **data = NULL;
+#ifdef __STDC_NO_VLA__
+			struct rtattr **attr = alloca((lu->maxattr+1)*sizeof(attr[0]));
+#else
+			struct rtattr *attr[lu->maxattr+1];
+#endif
+			struct rtattr **data = NULL;
 
 			if (linkinfo[IFLA_INFO_DATA]) {
 				parse_rtattr_nested(attr, lu->maxattr,
@@ -279,7 +284,12 @@ static void print_linktype(FILE *fp, struct rtattr *tb)
 
 		slave_lu = get_link_kind(slave);
 		if (slave_lu && slave_lu->print_opt) {
-			struct rtattr *attr[slave_lu->maxattr+1], **data = NULL;
+#ifdef __STDC_NO_VLA__
+			struct rtattr **attr = alloca((slave_lu->maxattr+1)*sizeof(attr[0]));
+#else
+			struct rtattr *attr[slave_lu->maxattr+1];
+#endif
+			struct rtattr **data = NULL;
 
 			if (linkinfo[IFLA_INFO_SLAVE_DATA]) {
 				parse_rtattr_nested(attr, slave_lu->maxattr,
-- 
2.44.0