Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5165)

Unified Diff: chrome/common/safe_browsing/zip_analyzer.cc

Issue 1028243002: Validate that zip entry filenames are UTF8. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: simple validation Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/safe_browsing/zip_analyzer.cc
diff --git a/chrome/common/safe_browsing/zip_analyzer.cc b/chrome/common/safe_browsing/zip_analyzer.cc
index 6f1d5e261fc663c387f8e7f229efd6ef3bc107ad..718cc28d13e632eb3699f3657cd06896293f3b86 100644
--- a/chrome/common/safe_browsing/zip_analyzer.cc
+++ b/chrome/common/safe_browsing/zip_analyzer.cc
@@ -4,6 +4,7 @@
#include "chrome/common/safe_browsing/zip_analyzer.h"
+#include "base/i18n/streaming_utf8_validator.h"
#include "base/logging.h"
#include "base/macros.h"
#include "chrome/common/safe_browsing/binary_feature_extractor.h"
@@ -58,7 +59,9 @@ void AnalyzeContainedFile(
zip::ZipReader* reader,
base::File* temp_file,
ClientDownloadRequest_ArchivedBinary* archived_binary) {
- archived_binary->set_file_basename(file_path.BaseName().AsUTF8Unsafe());
+ std::string file_basename(file_path.BaseName().AsUTF8Unsafe());
+ if (base::StreamingUtf8Validator::Validate(file_basename))
+ archived_binary->set_file_basename(file_basename);
archived_binary->set_download_type(
download_protection_util::GetDownloadType(file_path));
archived_binary->set_length(reader->current_entry_info()->original_size());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698