From dada@freepass.tu-graz.ac.at  Mon Apr 14 03:33:08 1997
Received: from freepass.tu-graz.ac.at (freepass.tu-graz.ac.at [129.27.193.133])
          by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id DAA02098
          for <FreeBSD-gnats-submit@freebsd.org>; Mon, 14 Apr 1997 03:32:47 -0700 (PDT)
Received: (from dada@localhost) by freepass.tu-graz.ac.at (8.6.11/8.6.9) id MAA13456; Mon, 14 Apr 1997 12:32:01 +0200
Message-Id: <199704141032.MAA13456@freepass.tu-graz.ac.at>
Date: Mon, 14 Apr 1997 12:32:01 +0200
From: Martin Kammerhofer <dada@freepass.tu-graz.ac.at>
Reply-To: dada@sbox.tu-graz.ac.at
To: FreeBSD-gnats-submit@freebsd.org
Subject: brandelf fails on files without write permission
X-Send-Pr-Version: 3.2

>Number:         3283
>Category:       bin
>Synopsis:       brandelf fails on files without write permission
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 14 03:40:07 PDT 1997
>Closed-Date:    Sat Aug 23 18:03:27 MEST 1997
>Last-Modified:  Sat Aug 23 18:04:01 MEST 1997
>Originator:     Martin Kammerhofer
>Release:        FreeBSD 2.2.1-RELEASE i386
>Organization:
Graz University of Technology
>Environment:
	any ELF file without write permission

>Description:
	brandelf(1) reports "No such file..." if it cannot open the
	file with mode O_RDWR.
	It therefore doesnt report on R/O files.

>How-To-Repeat:
	chmod -w elf-file
	brandelf -v elf-file

>Fix:

--- brandelf.c	1997/04/09 01:06:11	1.3
+++ brandelf.c	1997/04/09 01:12:31	1.4
@@ -68,7 +68,7 @@
 		char buffer[EI_NINDENT];
 		char string[(EI_NINDENT-EI_SPARE)+1];
 
-		if ((fd = open(argv[0], O_RDWR, 0)) < 0) {
+		if ((fd = open(argv[0], change ? O_RDWR : O_RDONLY, 0)) < 0) {
 			fprintf(stderr, "No such file %s.\n", argv[0]);
 			retval = 1;
 			goto fail;
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: joerg 
State-Changed-When: Sat Aug 23 18:03:27 MEST 1997 
State-Changed-Why:  

Similar fix applied in rev 1.8 of brandelf.c. 
>Unformatted:
