Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Feb 2013 05:40:02 GMT
From:      Mark Johnston <markj@freebsd.org>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/175491: [libelf] elf_getdata may return NULL without setting error-message
Message-ID:  <201302170540.r1H5e2cF006925@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/175491; it has been noted by GNATS.

From: Mark Johnston <markj@freebsd.org>
To: bug-followup@FreeBSD.org, mi@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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201302170540.r1H5e2cF006925>