diff options
author | Christopher Clark <christopher.w.clark@gmail.com> | 2019-04-16 13:35:37 -0700 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2019-04-18 09:32:40 -0400 |
commit | 9168b0ce83104b2c10b74aacda09f0aeeafc6aa9 (patch) | |
tree | 226036786b0399e7fce60f29825ea5491b9da277 /recipes-extended/xen/files/xen-tools-xenpmd-snprintf.patch | |
parent | 15caed2f436afd6ab07a0865b161c54f51bab6a4 (diff) | |
download | meta-virtualization-9168b0ce83104b2c10b74aacda09f0aeeafc6aa9.tar.gz |
xen: upgrade to 4.12.0
Signed-off-by: Christopher Clark <christopher.clark6@baesystems.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'recipes-extended/xen/files/xen-tools-xenpmd-snprintf.patch')
-rw-r--r-- | recipes-extended/xen/files/xen-tools-xenpmd-snprintf.patch | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/recipes-extended/xen/files/xen-tools-xenpmd-snprintf.patch b/recipes-extended/xen/files/xen-tools-xenpmd-snprintf.patch deleted file mode 100644 index aac7282f..00000000 --- a/recipes-extended/xen/files/xen-tools-xenpmd-snprintf.patch +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | From e4d78a67ffbacf30b66464080898227f18f6bf49 Mon Sep 17 00:00:00 2001 | ||
2 | From: Christopher Clark <christopher.w.clark@gmail.com> | ||
3 | Date: Fri, 17 Aug 2018 17:46:10 -0700 | ||
4 | Subject: [PATCH] xenpmd: prevent format-truncation warning with gcc 8.2 + ARM | ||
5 | 32-bit | ||
6 | To: xen-devel@lists.xenproject.org | ||
7 | Cc: ian.jackson@eu.citrix.com, | ||
8 | wei.liu2@citrix.com | ||
9 | |||
10 | xenpmd writes battery information to xenstore, including a string with a | ||
11 | formatted hex value calculated from summing the lengths of four strings, | ||
12 | plus some constants. | ||
13 | |||
14 | Each of the four strings has a maximum length of 31 bytes, excluding the | ||
15 | terminating zero byte. The strings are stored in 32-byte arrays in a | ||
16 | struct that is zeroed before it is populated, and logic that writes to | ||
17 | the strings uses strncpy and explicit zero termination. | ||
18 | |||
19 | The maximum value to be supplied to the xenstore string is: | ||
20 | (9 * 4) + (31 * 4) + 4 , which is 164, ie. 0xa4. | ||
21 | |||
22 | When used with this value, '%02x' will always fit within 3 bytes, but | ||
23 | gcc 8.2 is apparently not able to deduce this (observed when building | ||
24 | for a 32-bit ARM platform). | ||
25 | |||
26 | This commit assists the compiler by applying a mask (0xff) to the value, | ||
27 | enabling it to observe a lower maximum value and so pass the truncation | ||
28 | length check. | ||
29 | |||
30 | Prior to this change, building fails with the compiler warning: | ||
31 | |||
32 | | xenpmd.c: In function 'write_battery_info_to_xenstore': | ||
33 | | xenpmd.c:354:23: error: '%02x' directive output may be truncated | ||
34 | writing between 2 and 8 bytes into a region of size 3 | ||
35 | [-Werror=format-truncation=] | ||
36 | | snprintf(val, 3, "%02x", | ||
37 | | ^~~~ | ||
38 | | xenpmd.c:354:22: note: directive argument in the range [40, 2147483778] | ||
39 | | snprintf(val, 3, "%02x", | ||
40 | | ^~~~~~ | ||
41 | | xenpmd.c:354:5: note: 'snprintf' output between 3 and 9 bytes into a | ||
42 | destination of size 3 | ||
43 | | snprintf(val, 3, "%02x", | ||
44 | | ^~~~~~~~~~~~~~~~~~~~~~~~ | ||
45 | | (unsigned int)(9*4 + | ||
46 | | ~~~~~~~~~~~~~~~~~~~~ | ||
47 | | strlen(info->model_number) + | ||
48 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
49 | | strlen(info->serial_number) + | ||
50 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
51 | | strlen(info->battery_type) + | ||
52 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
53 | | strlen(info->oem_info) + 4)); | ||
54 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
55 | | cc1: all warnings being treated as errors | ||
56 | |||
57 | Signed-off-by: Christopher Clark <christopher.clark6@baesystems.com> | ||
58 | --- | ||
59 | tools/xenpmd/xenpmd.c | 6 ++++-- | ||
60 | 1 file changed, 4 insertions(+), 2 deletions(-) | ||
61 | |||
62 | diff --git a/tools/xenpmd/xenpmd.c b/tools/xenpmd/xenpmd.c | ||
63 | index 56412a9..0c0787e 100644 | ||
64 | --- a/tools/xenpmd/xenpmd.c | ||
65 | +++ b/tools/xenpmd/xenpmd.c | ||
66 | @@ -350,8 +350,10 @@ void write_battery_info_to_xenstore(struct battery_info *info) | ||
67 | |||
68 | memset(val, 0, 1024); | ||
69 | memset(string_info, 0, 256); | ||
70 | - /* write 9 dwords (so 9*4) + length of 4 strings + 4 null terminators */ | ||
71 | - snprintf(val, 3, "%02x", | ||
72 | + /* write 9 dwords (so 9*4) + length of 4 strings + 4 null terminators. | ||
73 | + * mask informs the compiler that format truncation will not occur. | ||
74 | + */ | ||
75 | + snprintf(val, 3, "%02x", 0xff & | ||
76 | (unsigned int)(9*4 + | ||
77 | strlen(info->model_number) + | ||
78 | strlen(info->serial_number) + | ||