Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Jan 2013 16:09:38 -0500 (EST)
From:      "Mikhail T." <mi@aldan.algebra.com>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/175491: elf_getdata may return NULL without setting error-message
Message-ID:  <201301212109.r0LL9cRI022068@narawntapu.narawntapu>
Resent-Message-ID: <201301212120.r0LLK0s8077328@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         175491
>Category:       bin
>Synopsis:       elf_getdata may return NULL without setting error-message
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 21 21:20:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Mikhail T.
>Release:        FreeBSD 9.1-PRERELEASE amd64
>Organization:
Virtual Estates, Inc.	http://sybpipe.com/
>Environment:
System: 9.1-PRERELEASE r244476: Wed Dec 19 23:40:59 EST 2012

>Description:
	The manual page for elf_getdata(3) assures, that a valid pointer
	will be returned unless there is an error. In case of an error,
	elf_errno(3) will return the error-code.

	Unfortunately, that is not always the case -- for a section 0 
	elf_getdata will return NULL without also setting the
	error-code:

		scn = elf_getscn(elf, 0);
		data = elf_getdata(scn, NULL);

	The traditional implementation, also known as libelf.so.0, sets
	the error to ERROR_NULLSCN, with a textual description of
		"Request error: can't manipulate null section"

>How-To-Repeat:
	I'm including a test-program that opens the argument (or its own
	executable) and reproduces the problem, when compiled and linked
	against FreeBSD's libelf:

	./libelftest
	elfversion returned 1
	libelftest: ./libelftest: elf_getscn: (null)
	...

	When compiled and linked against libelf.so.0 installed by the
	devel/libelf port, the result follows the expectation:

	./libelftest
	elfversion returned 1
	libelftest: ./libelftest: elf_getscn: Request error: can't manipulate null section

>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:



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