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

Unified Diff: ppapi/proxy/pdf_resource.cc

Issue 1147883002: Cleanup some PPAPI proxy code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix accidental memcpy removal Created 5 years, 7 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 | « ppapi/proxy/flash_font_file_resource.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/pdf_resource.cc
diff --git a/ppapi/proxy/pdf_resource.cc b/ppapi/proxy/pdf_resource.cc
index 384fdc90a35bd218251ee1356a79d50e081e87b9..c68280614fe9708ad00570c2015a22ba82725f8b 100644
--- a/ppapi/proxy/pdf_resource.cc
+++ b/ppapi/proxy/pdf_resource.cc
@@ -98,13 +98,17 @@ void PDFResource::SearchString(const unsigned short* input_string,
DCHECK(status == U_ZERO_ERROR);
}
- *count = static_cast<uint32_t>(pp_results.size());
- if (*count) {
- *results = reinterpret_cast<PP_PrivateFindResult*>(malloc(
- *count * sizeof(PP_PrivateFindResult)));
- memcpy(*results, &pp_results[0], *count * sizeof(PP_PrivateFindResult));
+ if (pp_results.empty() ||
+ pp_results.size() > std::numeric_limits<uint32_t>::max() ||
+ pp_results.size() >
+ std::numeric_limits<size_t>::max() / sizeof(PP_PrivateFindResult)) {
raymes 2015/05/20 00:26:48 Would it be simpler just to have some large consta
Lei Zhang 2015/05/20 00:30:48 I can replace std::numeric_limits<size_t>::max() w
Lei Zhang 2015/05/20 00:46:34 Done in patch set 3. But in general, the security
+ *count = 0;
+ *results = nullptr;
} else {
- *results = NULL;
+ *count = static_cast<uint32_t>(pp_results.size());
+ const size_t result_size = pp_results.size() * sizeof(PP_PrivateFindResult);
+ *results = reinterpret_cast<PP_PrivateFindResult*>(malloc(result_size));
+ memcpy(*results, &pp_results[0], result_size);
}
usearch_close(searcher);
« no previous file with comments | « ppapi/proxy/flash_font_file_resource.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698