From owner-freebsd-bugs Mon Apr 14 03:40:11 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id DAA02588 for bugs-outgoing; Mon, 14 Apr 1997 03:40:11 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id DAA02559; Mon, 14 Apr 1997 03:40:08 -0700 (PDT) Resent-Date: Mon, 14 Apr 1997 03:40:08 -0700 (PDT) Resent-Message-Id: <199704141040.DAA02559@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, dada@sbox.tu-graz.ac.at 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 ; 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 Reply-To: dada@sbox.tu-graz.ac.at To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/3283: brandelf fails on files without write permission Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >Number: 3283 >Category: bin >Synopsis: brandelf fails on files without write permission >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Apr 14 03:40:07 PDT 1997 >Last-Modified: >Originator: Martin Kammerhofer >Organization: Graz University of Technology >Release: FreeBSD 2.2.1-RELEASE i386 >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 doesn´t 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; >Audit-Trail: >Unformatted: