From 37400fa94ef4d2928ebf7206c4cd9fadd4e7e245 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sun, 29 Feb 2004 10:15:45 +0000 Subject: [PATCH] (flush_read): Bugfix: the condition at line 714 included || (status > 0 && !read_full_records_option) which is grossly wrong, since even if new_volume() below succeeds, the subsequent call to rmtread will overwrite the chunk of data already read in the buffer and thus spoil everything. --- src/buffer.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index a966032..7fd43f6 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -310,7 +310,7 @@ open_archive (enum access_mode wanted_access) } else if (strcmp (archive_name_array[0], "-") == 0) { - read_full_records_option = 1; /* could be a pipe, be safe */ + read_full_records_option = true; /* could be a pipe, be safe */ if (verify_option) FATAL_ERROR ((0, 0, _("Cannot verify stdin/stdout archive"))); @@ -408,8 +408,10 @@ open_archive (enum access_mode wanted_access) else strcpy (record_start->header.name, volume_label_option); - assign_string (¤t_stat_info.file_name, record_start->header.name); - current_stat_info.had_trailing_slash = strip_trailing_slashes (current_stat_info.file_name); + assign_string (¤t_stat_info.file_name, + record_start->header.name); + current_stat_info.had_trailing_slash = + strip_trailing_slashes (current_stat_info.file_name); record_start->header.typeflag = GNUTYPE_VOLHDR; TIME_TO_CHARS (start_time, record_start->header.mtime); @@ -703,9 +705,14 @@ flush_read (void) return; } + /* The condition below used to include + || (status > 0 && !read_full_records_option) + This is incorrect since even if new_volume() succeeds, the + subsequent call to rmtread will overwrite the chunk of data + already read in the buffer, so the processing will fail */ + if ((status == 0 - || (status < 0 && errno == ENOSPC) - || (status > 0 && !read_full_records_option)) + || (status < 0 && errno == ENOSPC)) && multi_volume_option) { union block *cursor; -- 2.45.2