aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/strutil.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-05-14 18:31:02 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-05-16 21:26:53 +1000
commit94f9303dabb5d28884ac05b179b004f37eae89eb (patch)
tree7ee90e3d3e1ce17a1efa77e695a67d1eb98f4bad /src/dutil/strutil.cpp
parent05781eabd0e71261959aabe27ab5ff2d3d859ca2 (diff)
downloadwix-94f9303dabb5d28884ac05b179b004f37eae89eb.tar.gz
wix-94f9303dabb5d28884ac05b179b004f37eae89eb.tar.bz2
wix-94f9303dabb5d28884ac05b179b004f37eae89eb.zip
Add StrAllocConcatFormattedSecure.
Diffstat (limited to 'src/dutil/strutil.cpp')
-rw-r--r--src/dutil/strutil.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/dutil/strutil.cpp b/src/dutil/strutil.cpp
index 2e5e2f96..4e184c34 100644
--- a/src/dutil/strutil.cpp
+++ b/src/dutil/strutil.cpp
@@ -920,8 +920,42 @@ LExit:
920 920
921 921
922/******************************************************************** 922/********************************************************************
923StrAllocConcatFormattedSecure - allocates or reuses dynamic string
924memory and adds a formatted string. If the memory needs to be
925reallocated, calls SecureZeroMemory on original block of memory after
926it is moved.
927
928NOTE: caller is responsible for freeing ppwz even if function fails
929********************************************************************/
930extern "C" HRESULT __cdecl StrAllocConcatFormattedSecure(
931 __deref_out_z LPWSTR* ppwz,
932 __in __format_string LPCWSTR wzFormat,
933 ...
934 )
935{
936 Assert(ppwz && wzFormat && *wzFormat);
937
938 HRESULT hr = S_OK;
939 LPWSTR sczFormatted = NULL;
940 va_list args;
941
942 va_start(args, wzFormat);
943 hr = StrAllocFormattedArgsSecure(&sczFormatted, wzFormat, args);
944 va_end(args);
945 ExitOnFailure(hr, "Failed to allocate formatted string");
946
947 hr = StrAllocConcatSecure(ppwz, sczFormatted, 0);
948
949LExit:
950 ReleaseStr(sczFormatted);
951
952 return hr;
953}
954
955
956/********************************************************************
923StrAllocFormattedSecure - allocates or reuses dynamic string memory 957StrAllocFormattedSecure - allocates or reuses dynamic string memory
924and formats it. If the memory needs to reallocated, 958and formats it. If the memory needs to be reallocated,
925calls SecureZeroMemory on original block of memory after it is moved. 959calls SecureZeroMemory on original block of memory after it is moved.
926 960
927NOTE: caller is responsible for freeing ppwz even if function fails 961NOTE: caller is responsible for freeing ppwz even if function fails