[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#606621: mklibs-readelf: segfaults on static objects



Source: mklibs
Version: 0.1.30
Severity: important
Tags: patch

This was originally found on armhf (a new port on debian-ports.org), when
doing d-i work,  but was also reproduced on amd64 and Ubuntu armel -which
I guess uses the same source.

You can easily check it by doing:

$ mklibs-readelf -n /sbin/ldconfig.real
Segmentation fault

I attach a simple patch that fixes this. It just checks to see if the
about-to-be-checked elf dynamic section is non-null. This should be
trivial to include, so please do so, I had d-i build image fail on me
because of this.

Thanks.

Konstantinos

-- System Information:
Debian Release: squeeze/sid
Architecture: armhf (armv7l)

Kernel: Linux 2.6.31.14-efikamx (PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
diff -ruN mklibs-0.1.30/src/mklibs-readelf/main.cpp mklibs-0.1.30.fixed//src/mklibs-readelf/main.cpp
--- mklibs-0.1.30/src/mklibs-readelf/main.cpp	2010-06-02 17:47:32.000000000 +0000
+++ mklibs-0.1.30.fixed//src/mklibs-readelf/main.cpp	2010-12-10 12:32:08.939766620 +0000
@@ -56,11 +56,14 @@
 static void process_dynamics (Elf::file *file, int64_t tag)
 {
   const Elf::section_type<Elf::section_type_DYNAMIC> *section = file->get_section_DYNAMIC ();
-  for (std::vector<Elf::dynamic *>::const_iterator it = section->get_dynamics ().begin (); it != section->get_dynamics ().end (); ++it)
-  {
-    Elf::dynamic *dynamic = *it;
-    if (dynamic->get_tag () == tag)
-      std::cout << dynamic->get_val_string () << '\n';
+  std::cout << "process_dynamics: section = " << std::hex << section << "\n";
+  if (section != NULL) {
+    for (std::vector<Elf::dynamic *>::const_iterator it = section->get_dynamics ().begin (); it != section->get_dynamics ().end (); ++it)
+    {
+      Elf::dynamic *dynamic = *it;
+      if (dynamic->get_tag () == tag)
+        std::cout << dynamic->get_val_string () << '\n';
+    }
   }
 }
 

Reply to: