CMake: Fix infinite loop untarring corrupt tar file

Suggested-by: Robert Maynard <robert.maynard@kitware.com>
This commit is contained in:
David Cole 2012-11-26 06:22:52 -05:00 committed by Brad King
parent a7742140ad
commit 37c34d7d7b
1 changed files with 5 additions and 2 deletions

View File

@ -1932,6 +1932,7 @@ bool extract_tar(const char* outFileName, bool verbose,
{ {
cmSystemTools::Error("Problem with archive_read_next_header(): ", cmSystemTools::Error("Problem with archive_read_next_header(): ",
archive_error_string(a)); archive_error_string(a));
break;
} }
if (verbose && extract) if (verbose && extract)
{ {
@ -1954,6 +1955,7 @@ bool extract_tar(const char* outFileName, bool verbose,
cmSystemTools::Error( cmSystemTools::Error(
"Problem with archive_write_disk_set_options(): ", "Problem with archive_write_disk_set_options(): ",
archive_error_string(ext)); archive_error_string(ext));
break;
} }
r = archive_write_header(ext, entry); r = archive_write_header(ext, entry);
@ -1963,6 +1965,7 @@ bool extract_tar(const char* outFileName, bool verbose,
archive_error_string(ext)); archive_error_string(ext));
cmSystemTools::Error("Current file:", cmSystemTools::Error("Current file:",
archive_entry_pathname(entry)); archive_entry_pathname(entry));
break;
} }
else else
{ {
@ -1972,6 +1975,7 @@ bool extract_tar(const char* outFileName, bool verbose,
{ {
cmSystemTools::Error("Problem with archive_write_finish_entry(): ", cmSystemTools::Error("Problem with archive_write_finish_entry(): ",
archive_error_string(ext)); archive_error_string(ext));
break;
} }
} }
} }
@ -1982,8 +1986,7 @@ bool extract_tar(const char* outFileName, bool verbose,
} }
archive_read_close(a); archive_read_close(a);
archive_read_finish(a); archive_read_finish(a);
return true; return r == ARCHIVE_EOF || r == ARCHIVE_OK;
} }
} }
#endif #endif