[PATCH] libdwfl: Fix memory leak in dwfl_module_getsrc_file on invalid DWARF.
by Mark Wielaard
If we allocated the match results array ourselves, then free it when
we detect invalid DWARF and return an error.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
libdwfl/ChangeLog | 5 +++++
libdwfl/dwfl_module_getsrc_file.c | 2 ++
2 files changed, 7 insertions(+)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 60ed700..bdfc92f 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,5 +1,10 @@
2016-04-14 Mark Wielaard <mjw(a)redhat.com>
+ * dwfl_module_getsrc_file.c (dwfl_module_getsrc_file): Free match
+ on invalid DWARF if we allocated it.
+
+2016-04-14 Mark Wielaard <mjw(a)redhat.com>
+
* linux-proc-maps.c (proc_maps_report): Free last_file on bad file
mapping.
diff --git a/libdwfl/dwfl_module_getsrc_file.c b/libdwfl/dwfl_module_getsrc_file.c
index 21a5915..4eaaeaf 100644
--- a/libdwfl/dwfl_module_getsrc_file.c
+++ b/libdwfl/dwfl_module_getsrc_file.c
@@ -87,6 +87,8 @@ dwfl_module_getsrc_file (Dwfl_Module *mod,
if (unlikely (line->file >= line->files->nfiles))
{
+ if (*nsrcs == 0)
+ free (match);
__libdwfl_seterrno (DWFL_E (LIBDW, DWARF_E_INVALID_DWARF));
return -1;
}
--
2.5.5
7 years, 10 months
[PATCH] libdwfl: Fix memory leak in proc_maps_report on bad file mapping.
by Mark Wielaard
Normally last_file is freed inside report(), but in the case of a bad
file mapping we don't call report.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
libdwfl/ChangeLog | 5 +++++
libdwfl/linux-proc-maps.c | 5 ++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 5d400bb..60ed700 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2016-04-14 Mark Wielaard <mjw(a)redhat.com>
+
+ * linux-proc-maps.c (proc_maps_report): Free last_file on bad file
+ mapping.
+
2016-03-01 Steven Chamberlain <steven(a)pyro.eu.org>
* linux-pid-attach.c: Removed unused pid_thread_callbacks,
diff --git a/libdwfl/linux-proc-maps.c b/libdwfl/linux-proc-maps.c
index 94b26d5..4ae1e74 100644
--- a/libdwfl/linux-proc-maps.c
+++ b/libdwfl/linux-proc-maps.c
@@ -250,7 +250,10 @@ proc_maps_report (Dwfl *dwfl, FILE *f, GElf_Addr sysinfo_ehdr, pid_t pid)
{
/* This is another portion of the same file's mapping. */
if (strcmp (last_file, file) != 0)
- goto bad_report;
+ {
+ free (last_file);
+ goto bad_report;
+ }
high = end;
}
else
--
2.5.5
7 years, 10 months
[PATCH] libelf: Fix memory leak when zlib deflateInit fails in elf_compress.
by Mark Wielaard
On error we return NULL, not out_buf. So make sure to not leak it.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
libelf/ChangeLog | 5 +++++
libelf/elf_compress.c | 1 +
2 files changed, 6 insertions(+)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 350e4eb..668687d 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,8 @@
+2016-04-14 Mark Wielaard <mjw(a)redhat.com>
+
+ * elf_compress.c (__libelf_compress): Free out_buf if deflateInit
+ fails.
+
2016-02-13 Mark Wielaard <mjw(a)redhat.com>
* elf32_updatefile.c (updatemmap): Free scns when out of memory.
diff --git a/libelf/elf_compress.c b/libelf/elf_compress.c
index 4c7c35e..10574ea 100644
--- a/libelf/elf_compress.c
+++ b/libelf/elf_compress.c
@@ -117,6 +117,7 @@ __libelf_compress (Elf_Scn *scn, size_t hsize, int ei_data,
int zrc = deflateInit (&z, Z_BEST_COMPRESSION);
if (zrc != Z_OK)
{
+ free (out_buf);
__libelf_seterrno (ELF_E_COMPRESS_ERROR);
return NULL;
}
--
2.5.5
7 years, 10 months
[PATCH] elfcmp: fix self-comparison error with GCC 6
by david.abdurachmanov@cern.ch
From: David Abdurachmanov <davidlt(a)cern.ch>
Noticed with Fedora 24 Alpha, gcc (GCC) 6.0.0 20160406
(Red Hat 6.0.0-0.20).
elfcmp.c: In function ‘main’:
elfcmp.c:364:199: error: self-comparison always evaluates
to false [-Werror=tautological-compare]
if (unlikely (name1 == NULL || name2 == NULL
Signed-off-by: David Abdurachmanov <davidlt(a)cern.ch>
---
src/ChangeLog | 4 ++++
src/elfcmp.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index f74b5dc..bdc9d13 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2016-04-11 David Abdurachmanov <davidlt(a)cern.ch>
+
+ * elfcmp.c (main): Fix self-comparison error with GCC 6.
+
2016-03-21 Mark Wielaard <mjw(a)redhat.com>
* nm.c (show_symbols): Check for malloc size argument overflow.
diff --git a/src/elfcmp.c b/src/elfcmp.c
index 852b92f..7b5d39c 100644
--- a/src/elfcmp.c
+++ b/src/elfcmp.c
@@ -368,7 +368,7 @@ main (int argc, char *argv[])
&& sym1->st_shndx != SHN_UNDEF)
|| sym1->st_info != sym2->st_info
|| sym1->st_other != sym2->st_other
- || sym1->st_shndx != sym1->st_shndx))
+ || sym1->st_shndx != sym2->st_shndx))
{
// XXX Do we want to allow reordered symbol tables?
symtab_mismatch:
--
2.7.3
7 years, 11 months
[PATCH] elfcmp: fix self-comparison error with GCC 6
by david.abdurachmanov@gmail.com
From: David Abdurachmanov <davidlt(a)cern.ch>
Noticed with Fedora 24 Alpha, gcc (GCC) 6.0.0 20160406
(Red Hat 6.0.0-0.20).
elfcmp.c: In function ‘main’:
elfcmp.c:364:199: error: self-comparison always evaluates
to false [-Werror=tautological-compare]
if (unlikely (name1 == NULL || name2 == NULL
Signed-off-by: David Abdurachmanov <davidlt(a)cern.ch>
---
src/ChangeLog | 4 ++++
src/elfcmp.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index f74b5dc..bdc9d13 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2016-04-11 David Abdurachmanov <davidlt(a)cern.ch>
+
+ * elfcmp.c (main): Fix self-comparison error with GCC 6.
+
2016-03-21 Mark Wielaard <mjw(a)redhat.com>
* nm.c (show_symbols): Check for malloc size argument overflow.
diff --git a/src/elfcmp.c b/src/elfcmp.c
index 852b92f..7b5d39c 100644
--- a/src/elfcmp.c
+++ b/src/elfcmp.c
@@ -368,7 +368,7 @@ main (int argc, char *argv[])
&& sym1->st_shndx != SHN_UNDEF)
|| sym1->st_info != sym2->st_info
|| sym1->st_other != sym2->st_other
- || sym1->st_shndx != sym1->st_shndx))
+ || sym1->st_shndx != sym2->st_shndx))
{
// XXX Do we want to allow reordered symbol tables?
symtab_mismatch:
--
2.7.3
7 years, 11 months
Using libdw to get symbol names inside signal handler
by marko@kevac.org
Hello.
I would like to user libunwind and libdw to get backtrace and symbol names
for backtrace from inside SIGSEGV signal handler.
I understand that libdw does not have documentation at all, so I am looking
for help here.
Is it good decision to use libunwind and libdw for getting backtrace from
inside signal handler?
Is libdw async signal safe?
Can you give me an example, please?
Thanks!
7 years, 11 months