elfutils: Fix null pointer dereference with upstream patch.
PATCH 1/1 elfutils: Fix null pointer dereference with upstream patch.
Compilation with recent gcc flags a null pointer dereference warning which is promoted to an error and causes failure to build.
Fixed in upstream patch by Mark Wielaard:3d9f1288: [PATCH] elflint.c: Don't dereference databits if bad This patch is included in 0.186 release but not in 0.185.
Patchfile here has the Changelog blob removed to allow it to apply.
--- .../elfutils/elfutils_0.185.bb | 1 + ...001-dont-dereference-databits-if-bad.patch | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 meta/recipes-devtools/elfutils/files/0001-dont-dereference-databits-if-bad.patch
meta/recipes-devtools/elfutils/elfutils_0.185.bb +1 -0
@@ -23,6 +23,7 @@ SRC_URI = "https://sourceware.org/elfutils/ftp/${PV}/${BP}.tar.bz2 \ file://0001-tests-Makefile.am-compile-test_nlist-with-standard-C.patch \ file://0001-debuginfod-debuginfod-client.c-correct-string-format.patch \ file://glibc-2.34-fix.patch \ + file://0001-dont-dereference-databits-if-bad.patch \ " SRC_URI:append:libc-musl = " \ file://0002-musl-libs.patch \
meta/recipes-devtools/elfutils/files/0001-dont-dereference-databits-if-bad.patch new file +39 -0
@@ -0,0 +1,39 @@ +From 3d9f12883d0c131bd4ab6045e1f60d3fe6d150ea Mon Sep 17 00:00:00 2001 +From: Mark Wielaard <[email protected]> +Date: Wed, 6 Oct 2021 23:37:42 +0200 +Subject: [PATCH] elflint.c: Don't dereference databits if bad + +elflint.c: In function 'check_sections': +elflint.c:4105:48: error: null pointer dereference [-Werror=null-dereference] +4105 | idx < databits->d_size && ! bad; + | ~~~~~~~~^~~~~~~~ + +Fix this by testing for ! bad first. + +Reported-by: Jan-Benedict Glaw <[email protected]> +Signed-off-by: Mark Wielaard <[email protected]> +--- + +NB: Upstream patch with Changelog blob removed since it doesn't apply cleanly. + Diffstat below is the original. + + src/ChangeLog | 4 ++++ + src/elflint.c | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/elflint.c b/src/elflint.c +index 1ce756847..ef7725ce7 100644 +--- a/src/elflint.c ++++ b/src/elflint.c +@@ -4102,7 +4102,7 @@ section [%2zu] '%s' has type NOBITS but is read from the file in segment of prog + bad = (databits == NULL + || databits->d_size != shdr->sh_size); + for (size_t idx = 0; +- idx < databits->d_size && ! bad; ++ ! bad && idx < databits->d_size; + idx++) + bad = ((char *) databits->d_buf)[idx] != 0; + +-- +2.31.1 +
Signature · 1 line
2.36.1
Quoted 8 lines · Ian Jamison
Compilation with recent gcc flags a null pointer dereference warning which is promoted to an error and causes failure to build.
Fixed in upstream patch by Mark Wielaard:
3d9f1288: [PATCH]elflint.c: Don't dereference databits if bad This patch is included in 0.186 release but not in 0.185.Patchfile here has the Changelog blob removed to allow it to apply.
honister branch is no longer maintained. This page has more information on supported branches:
https://wiki.yoctoproject.org/wiki/Releases
Thanks,
Anuj
Quoted 86 lines
Signed-off-by Ian Jamison <[email protected]>---
.../elfutils/elfutils_0.185.bb | 1 + ...001-dont-dereference-databits-if-bad.patch | 39
+++++++++++++++++++2 files changed, 40 insertions(+)create mode 100644 meta/recipes-devtools/elfutils/files/0001-dont- dereference-databits-if-bad.patch
meta/recipes-devtools/elfutils/elfutils_0.185.bb +0
-0@@ -23,6 +23,7 @@ SRC_URI = "https://sourceware.org/elfutils/ftp/${PV}/${BP}.tar.bz2 \file://0001-tests-Makefile.am-compile-test_nlist-with-standard-C.patch \
file://0001-debuginfod-debuginfod-client.c-correct-string-format.patch \
file://glibc-2.34-fix.patch \
+ file://0001-dont-dereference-databits-if-bad.patch \
"
SRC_URI:append:libc-musl = " \
file://0002-musl-libs.patch \(quoted diff) +0
-0dereference-databits-if-bad.patch b/meta/recipes-
devtools/elfutils/files/0001-dont-dereference-databits-if-bad.patchnew file mode 100644
index 0000000000..d80c7acad8meta/recipes-devtools/elfutils/files/0001-dont-dereference- new file +0
-0databits-if-bad.patch
meta/recipes-devtools/elfutils/files/0001-dont-dereference- new file +1
-0@@ -0,0 +1,39 @@ +From 3d9f12883d0c131bd4ab6045e1f60d3fe6d150ea Mon Sep 17 00:00:002001
meta/recipes-devtools/elfutils/files/0001-dont-dereference- new file +6
-0+From: Mark Wielaard <[email protected]> +Date: Wed, 6 Oct 2021 23:37:42 +0200 +Subject: [PATCH] elflint.c: Don't dereference databits if bad + +elflint.c: In function 'check_sections': +elflint.c:4105:48: error: null pointer dereference [-Werror=null-dereference]
+4105 | idx <databits->d_size&& ! bad;
+ | ~~~~~~~~^~~~~~~~meta/recipes-devtools/elfutils/files/0001-dont-dereference- new file +8
-0+ +Fix this by testing for ! bad first. + +Reported-by: Jan-Benedict Glaw <[email protected]> +Signed-off-by: Mark Wielaard <[email protected]> +--- + +NB: Upstream patch with Changelog blob removed since it doesn'tapply cleanly.
+ Diffstat below is the original.meta/recipes-devtools/elfutils/files/0001-dont-dereference- new file +10
-0+ + src/ChangeLog | 4 ++++ + src/elflint.c | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/elflint.c b/src/elflint.c +index 1ce756847..ef7725ce7 100644 +--- a/src/elflint.c ++++ b/src/elflint.c +@@ -4102,7 +4102,7 @@ section [%2zu] '%s' has type NOBITS but isread from the file in segment of prog
+ bad = (databits == NULL
+ ||databits->d_size!= shdr-Quoted 1 line
sh_size);+ for (
size_tidx = 0;
+- idx <databits->d_size&& ! bad; ++ ! bad && idx <databits->d_size; + idx++)
+ bad = ((char *) databits->d_buf)[idx] != 0;
+
+--
+2.31.1
+
Quoted 8 lines · Anuj Mittal
Quoted 7 lines · Ian Jamison
Compilation with recent gcc flags a null pointer dereference warning which is promoted to an error and causes failure to build.
Fixed in upstream patch by Mark Wielaard:
3d9f1288: [PATCH]elflint.c: Don't dereference databits if bad This patch is included in 0.186 release but not in 0.185.
Quoted 5 lines
Quoted 1 line
Patchfile here has the Changelog blob removed to allow it to apply.
honister branch is no longer maintained. This page has more information on supported branches:
Thanks for the info Anuj. On IRC yesterday Ross suggested I submit the patch, but never mind. EOL is EOL.
Since IMX/Freescale latest release is based on honister I'll just have to keep this as a local patch then.
Regards,
Ian
Quoted 93 lines
Thanks,
Anuj
Quoted 85 lines
Signed-off-by Ian Jamison <[email protected]>--- .../elfutils/elfutils_0.185.bb | 1 + ...001-dont-dereference-databits-if-bad.patch | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+)create mode 100644 meta/recipes-devtools/elfutils/files/0001-dont-
dereference-databits-if-bad.patchmeta/recipes-devtools/elfutils/elfutils_0.185.bb +0
-0@@ -23,6 +23,7 @@ SRC_URI = "https://sourceware.org/elfutils/ftp/${PV}/${BP}.tar.bz2 \file://0001-tests-Makefile.am-compile-test_nlist-with-standard-C.patch
\file://0001-debuginfod-debuginfod-client.c-correct-string-format.patch
\
file://glibc-2.34-fix.patch \
+ file://0001-dont-dereference-databits-if-bad.patch \
"
SRC_URI:append:libc-musl = " \
file://0002-musl-libs.patch \(quoted diff) +0
-0dereference-databits-if-bad.patch b/meta/recipes-
devtools/elfutils/files/0001-dont-dereference-databits-if-bad.patchnew file mode 100644
index 0000000000..d80c7acad8meta/recipes-devtools/elfutils/files/0001-dont-dereference- new file +0
-0databits-if-bad.patch
meta/recipes-devtools/elfutils/files/0001-dont-dereference- new file +1
-0@@ -0,0 +1,39 @@ +From 3d9f12883d0c131bd4ab6045e1f60d3fe6d150ea Mon Sep 17 00:00:002001
meta/recipes-devtools/elfutils/files/0001-dont-dereference- new file +6
-0+From: Mark Wielaard <[email protected]> +Date: Wed, 6 Oct 2021 23:37:42 +0200 +Subject: [PATCH] elflint.c: Don't dereference databits if bad + +elflint.c: In function 'check_sections': +elflint.c:4105:48: error: null pointer dereference [-Werror=null-dereference]
+4105 | idx <databits->d_size&& ! bad;
+ | ~~~~~~~~^~~~~~~~meta/recipes-devtools/elfutils/files/0001-dont-dereference- new file +8
-0+ +Fix this by testing for ! bad first. + +Reported-by: Jan-Benedict Glaw <[email protected]> +Signed-off-by: Mark Wielaard <[email protected]> +--- + +NB: Upstream patch with Changelog blob removed since it doesn'tapply cleanly.
+ Diffstat below is the original.meta/recipes-devtools/elfutils/files/0001-dont-dereference- new file +10
-0+ + src/ChangeLog | 4 ++++ + src/elflint.c | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/elflint.c b/src/elflint.c +index 1ce756847..ef7725ce7 100644 +--- a/src/elflint.c ++++ b/src/elflint.c +@@ -4102,7 +4102,7 @@ section [%2zu] '%s' has type NOBITS but isread from the file in segment of prog
+ bad = (databits == NULL
+ ||databits->d_size!= shdr-Quoted 1 line
sh_size);+ for (
size_tidx = 0;
+- idx <databits->d_size&& ! bad; ++ ! bad && idx <databits->d_size; + idx++)
+ bad = ((char *) databits->d_buf)[idx] != 0;meta/recipes-devtools/elfutils/files/0001-dont-dereference- new file +4
-0+ +-- +2.31.1 +