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

Unified Diff: sandbox/win/src/sandbox_nt_util.cc

Issue 1296223005: Continuing changes for lpc proxy Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « sandbox/win/src/sandbox_nt_util.h ('k') | sandbox/win/src/sandbox_policy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/win/src/sandbox_nt_util.cc
diff --git a/sandbox/win/src/sandbox_nt_util.cc b/sandbox/win/src/sandbox_nt_util.cc
index 64fd1f1f6d7f2c173b39d476925b2c1e3a90da6a..d56a45a30d5c6c9d8b7e43a8e773bded72cfadc6 100644
--- a/sandbox/win/src/sandbox_nt_util.cc
+++ b/sandbox/win/src/sandbox_nt_util.cc
@@ -306,18 +306,10 @@ NTSTATUS AllocAndCopyName(const OBJECT_ATTRIBUTES* in_object,
if (NULL == in_object->ObjectName->Buffer)
break;
- size_t size = in_object->ObjectName->Length + sizeof(wchar_t);
- *out_name = new(NT_ALLOC) wchar_t[size/sizeof(wchar_t)];
- if (NULL == *out_name)
- break;
-
- ret = CopyData(*out_name, in_object->ObjectName->Buffer,
- size - sizeof(wchar_t));
+ ret = AllocAndCopyUnicodeString(in_object->ObjectName, out_name);
if (!NT_SUCCESS(ret))
break;
- (*out_name)[size / sizeof(wchar_t) - 1] = L'\0';
-
if (attributes)
*attributes = in_object->Attributes;
@@ -617,6 +609,25 @@ bool IsSupportedRenameCall(FILE_RENAME_INFORMATION* file_info, DWORD length,
return true;
}
+NTSTATUS AllocAndCopyUnicodeString(const UNICODE_STRING* in_string,
+ wchar_t** out_string) {
+ if (!in_string)
+ return STATUS_INVALID_PARAMETER;
+
+ size_t size = in_string->Length + sizeof(wchar_t);
+ *out_string = new(NT_ALLOC) wchar_t[size/sizeof(wchar_t)];
+ if (NULL == *out_string)
+ return STATUS_UNSUCCESSFUL;
+
+ NTSTATUS ret = CopyData(*out_string, in_string->Buffer,
+ size - sizeof(wchar_t));
+ if (!NT_SUCCESS(ret))
+ return ret;
+
+ (*out_string)[size / sizeof(wchar_t) - 1] = L'\0';
+ return STATUS_SUCCESS;
+}
+
} // namespace sandbox
void* operator new(size_t size, sandbox::AllocationType type,
« no previous file with comments | « sandbox/win/src/sandbox_nt_util.h ('k') | sandbox/win/src/sandbox_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698