From 701b411f5e239408f6e7f3cf075613c9965c5825 Mon Sep 17 00:00:00 2001 From: Max Krummenacher Date: Mon, 25 Jun 2018 23:15:43 +0200 Subject: mmc-utils-cos: backport patch fixing gcc8 compiling Signed-off-by: Max Krummenacher --- ...ce-strncpy-with-memmove-on-overlapping-me.patch | 36 ++++++++++++++++++++++ recipes-devtools/mmc/mmc-utils-cos_git.bb | 5 ++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 recipes-devtools/mmc/files/0001-lsmmc-replace-strncpy-with-memmove-on-overlapping-me.patch diff --git a/recipes-devtools/mmc/files/0001-lsmmc-replace-strncpy-with-memmove-on-overlapping-me.patch b/recipes-devtools/mmc/files/0001-lsmmc-replace-strncpy-with-memmove-on-overlapping-me.patch new file mode 100644 index 0000000..62e25fd --- /dev/null +++ b/recipes-devtools/mmc/files/0001-lsmmc-replace-strncpy-with-memmove-on-overlapping-me.patch @@ -0,0 +1,36 @@ +From 175ac0f362bf6121c3537e2f1760ad41c8f81367 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 29 Mar 2018 01:04:57 -0700 +Subject: [PATCH] lsmmc: replace strncpy with memmove on overlapping memory + copy + +here source and destination addresses are overlapping so using memmove is +going to be more efficient. + +Additionally, the bounded size for copy is overflowing for first copy + +In function 'strncpy', + inlined from 'read_file' at lsmmc.c:356:3: +/mnt/a/oe/build/tmp/work/cortexa7t2hf-neon-vfpv4-bec-linux-gnueabi/mmc-utils/0.1-r0/recipe-sysroot/usr/include/bits/string_fortified.h:106:10: error: '__builtin_strncpy' accessing 4096 bytes at offsets 0 and 1 overlaps 4095 bytes at offset 1 [-Werror=restrict] + return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Signed-off-by: Khem Raj +--- +Upstream-Status: Submitted [https://patchwork.kernel.org/patch/10314723/] + lsmmc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lsmmc.c b/lsmmc.c +index c4faa00..bcb854d 100644 +--- a/lsmmc.c ++++ b/lsmmc.c +@@ -353,7 +353,7 @@ char *read_file(char *name) + line[strlen(line) - 1] = '\0'; + + while (isspace(line[0])) +- strncpy(&line[0], &line[1], sizeof(line)); ++ memmove(&line[0], &line[1], sizeof(line)-1); + + return strdup(line); + } diff --git a/recipes-devtools/mmc/mmc-utils-cos_git.bb b/recipes-devtools/mmc/mmc-utils-cos_git.bb index f3148c7..0f07a07 100644 --- a/recipes-devtools/mmc/mmc-utils-cos_git.bb +++ b/recipes-devtools/mmc/mmc-utils-cos_git.bb @@ -13,7 +13,10 @@ SRCREV = "bcc3e2e4246431be511be3959a11cd9733bedd29" PV = "0.1" -SRC_URI = "git://chromium.googlesource.com/chromiumos/third_party/mmc-utils.git;protocol=https;branch=${SRCBRANCH}" +SRC_URI = " \ + git://chromium.googlesource.com/chromiumos/third_party/mmc-utils.git;protocol=https;branch=${SRCBRANCH} \ + file://0001-lsmmc-replace-strncpy-with-memmove-on-overlapping-me.patch \ +" S = "${WORKDIR}/git" -- cgit v1.2.3