Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Jun 2011 16:27:49 +0000 (UTC)
From:      Tim Kientzle <kientzle@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r223541 - head/usr.bin/tar
Message-ID:  <201106251627.p5PGRnpO014353@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kientzle
Date: Sat Jun 25 16:27:49 2011
New Revision: 223541
URL: http://svn.freebsd.org/changeset/base/223541

Log:
  If there is a read error reading Y/N confirmation from the keyboard,
  exit immediately with an error.
  
  If there is an error opening or reading a file to put into the archive,
  set the return value for a deferred error exit.
  
  PR:		bin/154407

Modified:
  head/usr.bin/tar/util.c
  head/usr.bin/tar/write.c

Modified: head/usr.bin/tar/util.c
==============================================================================
--- head/usr.bin/tar/util.c	Sat Jun 25 16:13:56 2011	(r223540)
+++ head/usr.bin/tar/util.c	Sat Jun 25 16:27:49 2011	(r223541)
@@ -226,7 +226,11 @@ yes(const char *fmt, ...)
 	fflush(stderr);
 
 	l = read(2, buff, sizeof(buff) - 1);
-	if (l <= 0)
+	if (l < 0) {
+	  fprintf(stderr, "Keyboard read failed\n");
+	  exit(1);
+	}
+	if (l == 0)
 		return (0);
 	buff[l] = 0;
 

Modified: head/usr.bin/tar/write.c
==============================================================================
--- head/usr.bin/tar/write.c	Sat Jun 25 16:13:56 2011	(r223540)
+++ head/usr.bin/tar/write.c	Sat Jun 25 16:27:49 2011	(r223541)
@@ -919,6 +919,7 @@ write_entry_backend(struct bsdtar *bsdta
 		const char *pathname = archive_entry_sourcepath(entry);
 		fd = open(pathname, O_RDONLY | O_BINARY);
 		if (fd == -1) {
+			bsdtar->return_value = 1;
 			if (!bsdtar->verbose)
 				bsdtar_warnc(errno,
 				    "%s: could not open file", pathname);
@@ -1020,6 +1021,12 @@ write_file_data(struct bsdtar *bsdtar, s
 		progress += bytes_written;
 		bytes_read = read(fd, bsdtar->buff, FILEDATABUFLEN);
 	}
+	if (bytes_read < 0) {
+		bsdtar_warnc(errno,
+			     "%s: Read error",
+			     archive_entry_pathname(entry));
+		bsdtar->return_value = 1;
+	}
 	return 0;
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201106251627.p5PGRnpO014353>