Skip to contentSkip to conversation

package/gcc: Initialize st in elf_is_symlink

PATCH New james.hilliard1 at gmail.com 2 participants 2 messages Mar 18, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/gcc: Initialize st in elf_is_symlink

From: James Hilliard <[email protected]>

Fixes:
../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c: In function ?elf_is_symlink?:
../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21: error: ?st.st_mode? may be used uninitialized in this function [-Werror=maybe-uninitialized]

   return S_ISLNK (st.st_mode);
                     ^
---
 ...race-Initialize-st-in-elf_is_symlink.patch | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 package/gcc/8.3.0/0001-libbacktrace-Initialize-st-in-elf_is_symlink.patch
package/gcc/8.3.0/0001-libbacktrace-Initialize-st-in-elf_is_symlink.patch new file +32 -0
new file mode 100644
index 0000000000..22a6c38209
@@ -0,0 +1,32 @@
+From a6c384f38421ed62d5acac30a90dc92de5cf4055 Mon Sep 17 00:00:00 2001
+From: James Hilliard <[email protected]>
+Date: Mon, 18 Mar 2019 09:17:39 +0800
+Subject: [PATCH] [libbacktrace] Initialize st in elf_is_symlink
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Fixes error: ?st.st_mode? may be used uninitialized in this function
+
+Signed-off-by: James Hilliard <[email protected]>
+[Upstream status: https://patchwork.ozlabs.org/patch/1057631/]
+---
+ libbacktrace/elf.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
+index f4863f0bea5..6cc2a7dec22 100644
+--- a/libbacktrace/elf.c
++++ b/libbacktrace/elf.c
+@@ -765,7 +765,7 @@ elf_syminfo (struct backtrace_state *state, uintptr_t addr,
+ static int
+ elf_is_symlink (const char *filename)
+ {
+-  struct stat st;
++  struct stat st={0};
+ 
+   if (lstat (filename, &st) < 0)
+     return 0;
+-- 
+2.17.1
+
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 package/gcc: Initialize st in elf_is_symlink

Hello James,

Quoted 5 lines · On Mon, 18 Mar 2019 09:59:33 +0800 james.hilliard1 at gmail.com wrote:

From: James Hilliard <[email protected]>

Fixes:
../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c: In function ?elf_is_symlink?:
../../../../libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21: error: ?st.st_mode? may be used uninitialized in this function [-Werror=maybe-uninitialized]

Quoted 8 lines
   return S_ISLNK (st.st_mode);
                     ^
---
 ...race-Initialize-st-in-elf_is_symlink.patch | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 package/gcc/8.3.0/0001-libbacktrace-Initialize-st-in-elf_is_symlink.patch

The patch has been rejected upstream, so I'm not really keen on merging this. In addition, you're not giving enough details on the conditions under which this issue was found. Which configuration ? Which host gcc version ? etc.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com