blob: cbce053a3aef88a338f12f83c1a25e6a7c3c8af2 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001From bb4df273041ba206008bdb0ada75ccd97c29f623 Mon Sep 17 00:00:00 2001
2From: Xiao Ni <xni@redhat.com>
3Date: Fri, 17 Mar 2017 19:55:43 +0800
4Subject: [PATCH 2/5] mdadm: Specify enough length when write to buffer
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9In Detail.c the buffer path in function Detail is defined as path[200],
10in fact the max lenth of content which needs to write to the buffer is
11287. Because the length of dname of struct dirent is 255.
12During building it reports error:
13error: ‘%s directive writing up to 255 bytes into a region of size 189
14[-Werror=format-overflow=]
15
16In function examine_super0 there is a buffer nb with length 5.
17But it need to show a int type argument. The lenght of max
18number of int is 10. So the buffer length should be 11.
19
20In human_size function the length of buf is 30. During building
21there is a error:
22output between 20 and 47 bytes into a destination of size 30.
23Change the length to 47.
24
25Signed-off-by: Xiao Ni <xni@redhat.com>
26Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
27---
28Upstream-Status: Backport
29 Detail.c | 2 +-
30 super0.c | 2 +-
31 util.c | 2 +-
32 3 files changed, 3 insertions(+), 3 deletions(-)
33
34diff --git a/Detail.c b/Detail.c
35index 509b0d4..cb33794 100644
36--- a/Detail.c
37+++ b/Detail.c
38@@ -575,7 +575,7 @@ This is pretty boring
39 printf(" Member Arrays :");
40
41 while (dir && (de = readdir(dir)) != NULL) {
42- char path[200];
43+ char path[287];
44 char vbuf[1024];
45 int nlen = strlen(sra->sys_name);
46 dev_t devid;
47diff --git a/super0.c b/super0.c
48index 938cfd9..f5b4507 100644
49--- a/super0.c
50+++ b/super0.c
51@@ -231,7 +231,7 @@ static void examine_super0(struct supertype *st, char *homehost)
52 d++) {
53 mdp_disk_t *dp;
54 char *dv;
55- char nb[5];
56+ char nb[11];
57 int wonly, failfast;
58 if (d>=0) dp = &sb->disks[d];
59 else dp = &sb->this_disk;
60diff --git a/util.c b/util.c
61index f100972..32bd909 100644
62--- a/util.c
63+++ b/util.c
64@@ -811,7 +811,7 @@ unsigned long calc_csum(void *super, int bytes)
65 #ifndef MDASSEMBLE
66 char *human_size(long long bytes)
67 {
68- static char buf[30];
69+ static char buf[47];
70
71 /* We convert bytes to either centi-M{ega,ibi}bytes or
72 * centi-G{igi,ibi}bytes, with appropriate rounding,
73--
742.12.2
75