Date: Sun, 15 Sep 2002 00:07:55 +0200 (CEST) From: Slaven Rezic <eserte@vran.herceg.de> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/42789: cp -p may report wrong exit status Message-ID: <200209142207.g8EM7tXK020830@vran.herceg.de>
next in thread | raw e-mail | index | archive | help
>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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209142207.g8EM7tXK020830>