[krbdev.mit.edu #6399] rcp needs to check the result of close() when writing files

The RT System itself via RT rt-comment at krbdev.mit.edu
Thu Feb 19 18:10:11 EST 2009


>From krb5-bugs-incoming-bounces at PCH.mit.edu  Thu Feb 19 23:10:11 2009
Return-Path: <krb5-bugs-incoming-bounces at PCH.mit.edu>
X-Original-To: krb5-send-pr-nospam1 at krbdev.mit.edu
Received: from pch.mit.edu (PCH.MIT.EDU [18.7.21.90])
	by krbdev.mit.edu (Postfix) with ESMTP id 7ABBC5C0EA;
	Thu, 19 Feb 2009 23:10:11 +0000 (UTC)
Received: from pch.mit.edu (pch.mit.edu [127.0.0.1])
	by pch.mit.edu (8.13.6/8.12.8) with ESMTP id n1JNABJ8016130;
	Thu, 19 Feb 2009 18:10:11 -0500
Received: from pacific-carrier-annex.mit.edu (PACIFIC-CARRIER-ANNEX.MIT.EDU
	[18.7.21.83])
	by pch.mit.edu (8.13.6/8.12.8) with ESMTP id n1JMMpQU010032
	for <krb5-bugs-incoming at PCH.mit.edu>; Thu, 19 Feb 2009 17:22:51 -0500
Received: from mit.edu (M24-004-BARRACUDA-3.MIT.EDU [18.7.7.114])
	by pacific-carrier-annex.mit.edu (8.13.6/8.9.2) with ESMTP id
	n1JMMiLH008803
	for <krb5-bugs at mit.edu>; Thu, 19 Feb 2009 17:22:45 -0500 (EST)
Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31])
	by mit.edu (Spam Firewall) with ESMTP id 263CD12BA5E0
	for <krb5-bugs at mit.edu>; Thu, 19 Feb 2009 17:22:03 -0500 (EST)
Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com
	[172.16.52.254])
	by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n1JMM34t020839
	for <krb5-bugs at mit.edu>; Thu, 19 Feb 2009 17:22:03 -0500
Received: from blade.bos.redhat.com (blade.bos.redhat.com [10.16.0.23])
	by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n1JMLw9h010774
	for <krb5-bugs at mit.edu>; Thu, 19 Feb 2009 17:21:58 -0500
Received: from blade.bos.redhat.com (localhost.localdomain [127.0.0.1])
	by blade.bos.redhat.com (8.14.3/8.14.2) with ESMTP id n1JMM3SV002141
	for <krb5-bugs at mit.edu>; Thu, 19 Feb 2009 17:22:03 -0500
Received: (from nalin at localhost)
	by blade.bos.redhat.com (8.14.3/8.14.3/Submit) id n1JMM3DC002140;
	Thu, 19 Feb 2009 17:22:03 -0500
Date: Thu, 19 Feb 2009 17:22:03 -0500
Message-Id: <200902192222.n1JMM3DC002140 at blade.bos.redhat.com>
To: krb5-bugs at mit.edu
Subject: rcp needs to check the result of close() when writing files
From: nalin at redhat.com
X-send-pr-version: 3.99
X-Scanned-By: MIMEDefang 2.42
X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254
X-Spam-Score: 0.55
X-Spam-Flag: NO
X-Mailman-Approved-At: Thu, 19 Feb 2009 18:10:10 -0500
X-BeenThere: krb5-bugs-incoming at mailman.mit.edu
X-Mailman-Version: 2.1.6
Precedence: list
Reply-To: nalin at redhat.com
Sender: krb5-bugs-incoming-bounces at PCH.mit.edu
Errors-To: krb5-bugs-incoming-bounces at PCH.mit.edu


>Submitter-Id:	net
>Originator:	
>Organization:
>Confidential:	no
>Synopsis:	rcp needs to check the result of close() when writing files
>Severity:	non-critical
>Priority:	medium
>Category:	krb5-appl
>Class:		sw-bug
>Release:	1.6.3
>Environment:
	
System: Linux blade.bos.redhat.com 2.6.27.15-170.2.24.fc10.x86_64 #1 SMP Wed Feb 11 23:14:31 EST 2009 x86_64 x86_64 x86_64 GNU/Linux
Architecture: x86_64

>Description:
	Tomas Smetana noted that rcp wasn't reporting out-of-space errors
	when copying files to an NFS filesystem, and traced it down to
	an unchecked call to close(), which is when the error would have
	been reported to the receiving rcp.
>How-To-Repeat:
	Mount an NFS filesystem read-write from a remote host.  Use rcp
	to attempt to copy a file which is larger than the filesystem
	to the NFS client.  The copy will fail due to insufficient space,
	but write() won't fail.  The close() call will fail but it's
	not checked, so rcp will indicate success for an incomplete copy.
>Fix:
	Tomas's patch:

Index: src/appl/bsd/krcp.c
===================================================================
--- src/appl/bsd/krcp.c	(revision 22038)
+++ src/appl/bsd/krcp.c	(working copy)
@@ -1115,7 +1115,10 @@
 	  wrerr++;
 	if (ftruncate(of, size))
 	  error("rcp: can't truncate %s: %s\n", nambuf, error_message(errno));
-	(void) close(of);
+	if (close(of) != 0)
+	{
+		error("rcp: error closing %s: %s\n", nambuf, error_message(errno));
+	}
 	(void) response();
 	if (setimes) {
 	    setimes = 0;




More information about the krb5-bugs mailing list