Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | From bb4df273041ba206008bdb0ada75ccd97c29f623 Mon Sep 17 00:00:00 2001 |
| 2 | From: Xiao Ni <xni@redhat.com> |
| 3 | Date: Fri, 17 Mar 2017 19:55:43 +0800 |
| 4 | Subject: [PATCH 2/5] mdadm: Specify enough length when write to buffer |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
| 9 | In Detail.c the buffer path in function Detail is defined as path[200], |
| 10 | in fact the max lenth of content which needs to write to the buffer is |
| 11 | 287. Because the length of dname of struct dirent is 255. |
| 12 | During building it reports error: |
| 13 | error: ‘%s’ directive writing up to 255 bytes into a region of size 189 |
| 14 | [-Werror=format-overflow=] |
| 15 | |
| 16 | In function examine_super0 there is a buffer nb with length 5. |
| 17 | But it need to show a int type argument. The lenght of max |
| 18 | number of int is 10. So the buffer length should be 11. |
| 19 | |
| 20 | In human_size function the length of buf is 30. During building |
| 21 | there is a error: |
| 22 | output between 20 and 47 bytes into a destination of size 30. |
| 23 | Change the length to 47. |
| 24 | |
| 25 | Signed-off-by: Xiao Ni <xni@redhat.com> |
| 26 | Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com> |
| 27 | --- |
| 28 | Upstream-Status: Backport |
| 29 | Detail.c | 2 +- |
| 30 | super0.c | 2 +- |
| 31 | util.c | 2 +- |
| 32 | 3 files changed, 3 insertions(+), 3 deletions(-) |
| 33 | |
| 34 | diff --git a/Detail.c b/Detail.c |
| 35 | index 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; |
| 47 | diff --git a/super0.c b/super0.c |
| 48 | index 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; |
| 60 | diff --git a/util.c b/util.c |
| 61 | index 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 | -- |
| 74 | 2.12.2 |
| 75 | |