bin/175491: [libelf] elf_getdata may return NULL without setting error-message
Mark Johnston
markj at freebsd.org
Sun Feb 17 05:40:02 UTC 2013
The following reply was made to PR bin/175491; it has been noted by GNATS.
From: Mark Johnston <markj at freebsd.org>
To: bug-followup at FreeBSD.org, mi at aldan.algebra.com
Cc:
Subject: Re: bin/175491: [libelf] elf_getdata may return NULL without setting
error-message
Date: Sun, 17 Feb 2013 00:31:03 -0500
--jousvV0MzM2p6OtC
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Looks like this was fixed in upstream libelf with r1765 and r1766. The
same bug exists in elf_rawdata(), and this han't been fixed upstream
either. I'll try to get this fixed both upstream and in FreeBSD's
libelf; in the meantime, the attached patch should fix the problem.
-Mark
--jousvV0MzM2p6OtC
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="libelf_nullscn.diff"
diff --git a/lib/libelf/elf_data.c b/lib/libelf/elf_data.c
index c34c4ad..d3bd390 100644
--- a/lib/libelf/elf_data.c
+++ b/lib/libelf/elf_data.c
@@ -78,8 +78,10 @@ elf_getdata(Elf_Scn *s, Elf_Data *d)
sh_align = s->s_shdr.s_shdr64.sh_addralign;
}
- if (sh_type == SHT_NULL)
+ if (sh_type == SHT_NULL) {
+ LIBELF_SET_ERROR(SECTION, 0);
return (NULL);
+ }
if ((elftype = _libelf_xlate_shtype(sh_type)) < ELF_T_FIRST ||
elftype > ELF_T_LAST || (sh_type != SHT_NOBITS &&
@@ -219,8 +221,10 @@ elf_rawdata(Elf_Scn *s, Elf_Data *d)
sh_align = s->s_shdr.s_shdr64.sh_addralign;
}
- if (sh_type == SHT_NULL)
+ if (sh_type == SHT_NULL) {
+ LIBELF_SET_ERROR(SECTION, 0);
return (NULL);
+ }
if ((d = _libelf_allocate_data(s)) == NULL)
return (NULL);
--jousvV0MzM2p6OtC--
More information about the freebsd-bugs
mailing list