diff options
author | François Degros <fdegros@chromium.org> | 2022-02-09 23:22:18 +0000 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-02-09 15:32:33 -0800 |
commit | 6e2ac2abe8769429111570802caf0a470794f980 (patch) | |
tree | 0896b061036b0746d8c317e3fcc8c9d1ba488343 | |
parent | 9973d8bc57b59a3ce4cec5494d2153b2c8f85974 (diff) | |
download | zlib-6e2ac2abe8769429111570802caf0a470794f980.tar.gz |
[zip] Add ERROR logs
BUG=chromium:1295127
TEST=autoninja -C out/Default zlib_unittests && out/Default/zlib_unittests
Change-Id: I2b72366fe33a2446fbed0a55c48422741379ff53
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3450253
Reviewed-by: Noel Gordon <noel@chromium.org>
Commit-Queue: François Degros <fdegros@chromium.org>
Cr-Commit-Position: refs/heads/main@{#969171}
NOKEYCHECK=True
GitOrigin-RevId: 415ce793d5dafc2678fe7f034a8cb03a6673dc70
-rw-r--r-- | google/zip_reader.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/google/zip_reader.cc b/google/zip_reader.cc index 1457b45..bc2e01b 100644 --- a/google/zip_reader.cc +++ b/google/zip_reader.cc @@ -10,6 +10,7 @@ #include "base/files/file.h" #include "base/i18n/icu_string_conversions.h" #include "base/logging.h" +#include "base/strings/strcat.h" #include "base/strings/string_piece.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" @@ -149,6 +150,10 @@ bool ZipReader::Open(const base::FilePath& zip_path) { // this safely on Linux. See file_util.h for details. zip_file_ = internal::OpenForUnzipping(zip_path.AsUTF8Unsafe()); if (!zip_file_) { + LOG(ERROR) << "Cannot open ZIP archive " + << (LOG_IS_ON(INFO) + ? base::StrCat({"'", zip_path.AsUTF8Unsafe(), "'"}) + : "(redacted)"); return false; } @@ -164,6 +169,7 @@ bool ZipReader::OpenFromPlatformFile(base::PlatformFile zip_fd) { zip_file_ = internal::OpenHandleForUnzipping(zip_fd); #endif if (!zip_file_) { + LOG(ERROR) << "Cannot open ZIP from file handle " << zip_fd; return false; } @@ -224,9 +230,11 @@ bool ZipReader::OpenCurrentEntryInZip() { // Get entry info. unz_file_info info = {}; char path_in_zip[internal::kZipMaxPath] = {}; - if (unzGetCurrentFileInfo(zip_file_, &info, path_in_zip, - sizeof(path_in_zip) - 1, nullptr, 0, nullptr, - 0) != UNZ_OK) { + if (const int err = unzGetCurrentFileInfo(zip_file_, &info, path_in_zip, + sizeof(path_in_zip) - 1, nullptr, 0, + nullptr, 0); + err != UNZ_OK) { + LOG(ERROR) << "Cannot get entry from ZIP: " << UnzipError(err); return false; } |