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
This commit is contained in:
parent
1b609861c8
commit
d717d950fa
@ -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;
|
||||
|
||||
|
@ -919,6 +919,7 @@ write_entry_backend(struct bsdtar *bsdtar, struct archive *a,
|
||||
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, struct archive *a,
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user