aboutsummaryrefslogtreecommitdiff
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
parent05781eabd0e71261959aabe27ab5ff2d3d859ca2 (diff)
downloadwix-94f9303dabb5d28884ac05b179b004f37eae89eb.tar.gz
wix-94f9303dabb5d28884ac05b179b004f37eae89eb.tar.bz2
wix-94f9303dabb5d28884ac05b179b004f37eae89eb.zip
Add StrAllocConcatFormattedSecure.
-rw-r--r--src/dutil/inc/strutil.h5
-rw-r--r--src/dutil/strutil.cpp36
2 files changed, 40 insertions, 1 deletions
diff --git a/src/dutil/inc/strutil.h b/src/dutil/inc/strutil.h
index 1a2ed1d8..c73615aa 100644
--- a/src/dutil/inc/strutil.h
+++ b/src/dutil/inc/strutil.h
@@ -100,6 +100,11 @@ HRESULT __cdecl StrAllocConcatFormatted(
100 __in __format_string LPCWSTR wzFormat, 100 __in __format_string LPCWSTR wzFormat,
101 ... 101 ...
102 ); 102 );
103HRESULT __cdecl StrAllocConcatFormattedSecure(
104 __deref_out_z LPWSTR* ppwz,
105 __in __format_string LPCWSTR wzFormat,
106 ...
107 );
103HRESULT __cdecl StrAllocFormattedSecure( 108HRESULT __cdecl StrAllocFormattedSecure(
104 __deref_out_z LPWSTR* ppwz, 109 __deref_out_z LPWSTR* ppwz,
105 __in __format_string LPCWSTR wzFormat, 110 __in __format_string LPCWSTR wzFormat,
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