From owner-freebsd-bugs@FreeBSD.ORG Mon Jan 21 21:20:01 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 1D3CF533 for ; Mon, 21 Jan 2013 21:20:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id EEA9AE27 for ; Mon, 21 Jan 2013 21:20:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.6/8.14.6) with ESMTP id r0LLK0Sa077333 for ; Mon, 21 Jan 2013 21:20:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.6/8.14.6/Submit) id r0LLK0s8077328; Mon, 21 Jan 2013 21:20:00 GMT (envelope-from gnats) Resent-Date: Mon, 21 Jan 2013 21:20:00 GMT Resent-Message-Id: <201301212120.r0LLK0s8077328@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, "Mikhail T." Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 791872A8 for ; Mon, 21 Jan 2013 21:09:54 +0000 (UTC) (envelope-from mi@aldan.algebra.com) Received: from smtp02.lnh.mail.rcn.net (smtp02.lnh.mail.rcn.net [207.172.157.102]) by mx1.freebsd.org (Postfix) with ESMTP id 1E921DC4 for ; Mon, 21 Jan 2013 21:09:53 +0000 (UTC) Received: from mr16.lnh.mail.rcn.net ([207.172.157.36]) by smtp02.lnh.mail.rcn.net with ESMTP; 21 Jan 2013 16:09:48 -0500 Received: from smtp01.lnh.mail.rcn.net (smtp01.lnh.mail.rcn.net [207.172.4.11]) by mr16.lnh.mail.rcn.net (MOS 4.3.4-GA) with ESMTP id CEW29024; Mon, 21 Jan 2013 16:09:46 -0500 Received: from pool-173-70-92-11.nwrknj.fios.verizon.net (HELO narawntapu.narawntapu) ([173.70.92.11]) by smtp01.lnh.mail.rcn.net with ESMTP; 21 Jan 2013 16:09:47 -0500 Received: from narawntapu.narawntapu (localhost [127.0.0.1]) by narawntapu.narawntapu (8.14.6/8.14.5) with ESMTP id r0LL9cj3022069 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 21 Jan 2013 16:09:40 -0500 (EST) (envelope-from mi@narawntapu.narawntapu) Received: (from mi@localhost) by narawntapu.narawntapu (8.14.6/8.14.5/Submit) id r0LL9cRI022068; Mon, 21 Jan 2013 16:09:38 -0500 (EST) (envelope-from mi) Message-Id: <201301212109.r0LL9cRI022068@narawntapu.narawntapu> Date: Mon, 21 Jan 2013 16:09:38 -0500 (EST) From: "Mikhail T." To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.114 Subject: bin/175491: elf_getdata may return NULL without setting error-message X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: "Mikhail T." List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jan 2013 21:20:01 -0000 >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: