From owner-freebsd-bugs Sat Sep 14 15:20:22 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E38AC37B405 for ; Sat, 14 Sep 2002 15:20:12 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 45CEF43E3B for ; Sat, 14 Sep 2002 15:20:12 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g8EMK3JU093651 for ; Sat, 14 Sep 2002 15:20:03 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g8EMK3eY093650; Sat, 14 Sep 2002 15:20:03 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EBF4537B401 for ; Sat, 14 Sep 2002 15:10:05 -0700 (PDT) Received: from mailoutvl21.berlin.de (mail.berlin.de [195.243.105.33]) by mx1.FreeBSD.org (Postfix) with ESMTP id CC1AB43E6E for ; Sat, 14 Sep 2002 15:10:04 -0700 (PDT) (envelope-from slaven.rezic@berlin.de) Received: from herceg.de ([213.7.181.35]) by mailoutvl21.berlin.de (InterMail vK.4.03.05.00 201-232-132 license c0e4b842f1eddc5308d584e55543c802) with ESMTP id <20020914221312.QGQT27460.mailoutvl21@herceg.de> for ; Sun, 15 Sep 2002 00:13:12 +0200 Received: (from eserte@localhost) by vran.herceg.de (8.12.4/8.12.4/Submit) id g8EM7tXK020830; Sun, 15 Sep 2002 00:07:55 +0200 (CEST) (envelope-from eserte) Message-Id: <200209142207.g8EM7tXK020830@vran.herceg.de> Date: Sun, 15 Sep 2002 00:07:55 +0200 (CEST) From: Slaven Rezic Reply-To: slaven.rezic@berlin.de To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/42789: cp -p may report wrong exit status Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 42789 >Category: bin >Synopsis: cp -p may report wrong exit status >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Sep 14 15:20:02 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Slaven Rezic >Release: FreeBSD 4.6-STABLE i386 >Organization: www.rezic.de >Environment: System: FreeBSD vran.herceg.de 4.6-STABLE FreeBSD 4.6-STABLE #15: Sat Jul 27 09:32:28 CEST 2002 root@vran.herceg.de:/usr/local/src/FreeBSD-4/src/sys/compile/VRAN i386 >Description: cp -p may report success when a copy fails but setting the mode bits (via setfile()) succeeds. This may be fatal for mv, which relies on the exit code of cp. >How-To-Repeat: Use mv on a directory with a big file between different filesystems. The big file should be too large for the target filesystem. Hence the mv fails, but the source directory is nevertheless deleted. >Fix: --- bin/cp/cp.c.orig Sat Sep 14 23:52:30 2002 +++ bin/cp/cp.c Sat Sep 14 23:57:35 2002 @@ -250,7 +250,7 @@ copy(argv, type, fts_options) struct stat to_stat; FTS *ftsp; FTSENT *curr; - int base = 0, dne, badcp, nlen, rval; + int base = 0, dne, badcp, nlen, rval, newrval; char *p, *target_mid; mode_t mask, mode; @@ -350,9 +350,11 @@ copy(argv, type, fts_options) * honour setuid, setgid and sticky bits, but we * normally want to preserve them on directories. */ - if (pflag) - rval = setfile(curr->fts_statp, 0); - else { + if (pflag) { + newrval = setfile(curr->fts_statp, 0); + if (newrval) + rval = newrval; + } else { mode = curr->fts_statp->st_mode; if ((mode & (S_ISUID | S_ISGID | S_ISTXT)) || ((mode | S_IRWXU) & mask) != (mode & mask)) >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message