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

Unified Diff: chrome_elf/nt_registry/nt_registry.cc

Issue 2885243002: [NtRegistry] Ensure REG_SZ and REG_MULTI_SZ are null terminated. (Closed)
Patch Set: Created 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_elf/nt_registry/nt_registry.cc
diff --git a/chrome_elf/nt_registry/nt_registry.cc b/chrome_elf/nt_registry/nt_registry.cc
index 4c65af8daff7c76ea5a9e4a0255da0225aeb58a4..354cc6478a7ad797c71322a6c309942505bff679 100644
--- a/chrome_elf/nt_registry/nt_registry.cc
+++ b/chrome_elf/nt_registry/nt_registry.cc
@@ -775,10 +775,15 @@ bool QueryRegKeyValue(HANDLE key,
if (NT_SUCCESS(ntstatus)) {
*out_type = value_info->Type;
*out_size = value_info->DataLength;
- *out_buffer = new BYTE[*out_size];
- ::memcpy(*out_buffer,
- (reinterpret_cast<BYTE*>(value_info) + value_info->DataOffset),
- *out_size);
+ *out_buffer = nullptr;
+ if (*out_size) {
+ *out_buffer = new BYTE[*out_size];
robertshield 2017/05/17 16:59:59 totally optional, as this looks right to me, but f
penny 2017/07/19 22:25:15 Done. For the query function, a vector of bytes i
+ ::memcpy(*out_buffer,
+ (reinterpret_cast<BYTE*>(value_info) + value_info->DataOffset),
+ *out_size);
+ if (*out_type == REG_SZ || *out_type == REG_MULTI_SZ)
robertshield 2017/05/17 16:59:59 how about REG_EXPAND_SZ?
penny 2017/07/19 22:25:15 Done. Thanks for noting this Robert. Mine as well
+ (*out_buffer)[(*out_size) - 1] = 0;
+ }
success = true;
}
« 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