diff options
| author | Rob Mensching <rob@firegiant.com> | 2025-11-01 13:11:40 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2025-11-02 11:48:43 -0800 |
| commit | 20792b9388aba40e39e11df9e1d4a9f3dbff6fcd (patch) | |
| tree | 2f59ef912f7a698af61af62f5b3fcc3c5472277f /src | |
| parent | 8a24574018dc4ac39ec5988b87aff797e22b187b (diff) | |
| download | wix-20792b9388aba40e39e11df9e1d4a9f3dbff6fcd.tar.gz wix-20792b9388aba40e39e11df9e1d4a9f3dbff6fcd.tar.bz2 wix-20792b9388aba40e39e11df9e1d4a9f3dbff6fcd.zip | |
Always read the stdin preamble in wixnative
When the wixnative.exe exits before the C# code sends the preamble, we'll get
an exception that the stdin pipe is already closed. Turns out some commands
did not wait for the preamble, so make them all wait to remove the race
condition.
Diffstat (limited to 'src')
| -rw-r--r-- | src/wix/wixnative/certhashes.cpp | 3 | ||||
| -rw-r--r-- | src/wix/wixnative/precomp.h | 1 | ||||
| -rw-r--r-- | src/wix/wixnative/smartcab.cpp | 3 | ||||
| -rw-r--r-- | src/wix/wixnative/wixnative.cpp | 14 |
4 files changed, 12 insertions, 9 deletions
diff --git a/src/wix/wixnative/certhashes.cpp b/src/wix/wixnative/certhashes.cpp index cbb548ba..03ae4b5b 100644 --- a/src/wix/wixnative/certhashes.cpp +++ b/src/wix/wixnative/certhashes.cpp | |||
| @@ -27,9 +27,6 @@ HRESULT CertificateHashesCommand( | |||
| 27 | LPWSTR sczPublicKeyIdentifier = NULL; | 27 | LPWSTR sczPublicKeyIdentifier = NULL; |
| 28 | LPWSTR sczThumbprint = NULL; | 28 | LPWSTR sczThumbprint = NULL; |
| 29 | 29 | ||
| 30 | hr = WixNativeReadStdinPreamble(); | ||
| 31 | ExitOnFailure(hr, "Failed to read stdin preamble before reading paths to get certificate hashes"); | ||
| 32 | |||
| 33 | // Get the hash for each provided file. | 30 | // Get the hash for each provided file. |
| 34 | for (;;) | 31 | for (;;) |
| 35 | { | 32 | { |
diff --git a/src/wix/wixnative/precomp.h b/src/wix/wixnative/precomp.h index bc59d693..54af38e3 100644 --- a/src/wix/wixnative/precomp.h +++ b/src/wix/wixnative/precomp.h | |||
| @@ -17,7 +17,6 @@ | |||
| 17 | #include "cabcutil.h" | 17 | #include "cabcutil.h" |
| 18 | #include "cabutil.h" | 18 | #include "cabutil.h" |
| 19 | 19 | ||
| 20 | HRESULT WixNativeReadStdinPreamble(); | ||
| 21 | HRESULT CertificateHashesCommand(__in int argc, __in_ecount(argc) LPWSTR argv[]); | 20 | HRESULT CertificateHashesCommand(__in int argc, __in_ecount(argc) LPWSTR argv[]); |
| 22 | HRESULT SmartCabCommand(__in int argc, __in_ecount(argc) LPWSTR argv[]); | 21 | HRESULT SmartCabCommand(__in int argc, __in_ecount(argc) LPWSTR argv[]); |
| 23 | HRESULT EnumCabCommand(__in int argc, __in_ecount(argc) LPWSTR argv[]); | 22 | HRESULT EnumCabCommand(__in int argc, __in_ecount(argc) LPWSTR argv[]); |
diff --git a/src/wix/wixnative/smartcab.cpp b/src/wix/wixnative/smartcab.cpp index 1b925d42..ebe92c21 100644 --- a/src/wix/wixnative/smartcab.cpp +++ b/src/wix/wixnative/smartcab.cpp | |||
| @@ -69,9 +69,6 @@ HRESULT SmartCabCommand( | |||
| 69 | 69 | ||
| 70 | if (uiFileCount > 0) | 70 | if (uiFileCount > 0) |
| 71 | { | 71 | { |
| 72 | hr = WixNativeReadStdinPreamble(); | ||
| 73 | ExitOnFailure(hr, "failed to read stdin preamble before smartcabbing"); | ||
| 74 | |||
| 75 | hr = CompressFiles(hCab, &sczFirstFileToken); | 72 | hr = CompressFiles(hCab, &sczFirstFileToken); |
| 76 | ExitOnFailure(hr, "failed to compress files into cabinet: %ls", sczCabPath); | 73 | ExitOnFailure(hr, "failed to compress files into cabinet: %ls", sczCabPath); |
| 77 | 74 | ||
diff --git a/src/wix/wixnative/wixnative.cpp b/src/wix/wixnative/wixnative.cpp index 7a689fc3..d7db20f6 100644 --- a/src/wix/wixnative/wixnative.cpp +++ b/src/wix/wixnative/wixnative.cpp | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | 2 | ||
| 3 | #include "precomp.h" | 3 | #include "precomp.h" |
| 4 | 4 | ||
| 5 | static HRESULT WixNativeReadStdinPreamble(); | ||
| 6 | |||
| 7 | |||
| 5 | int __cdecl wmain(int argc, LPWSTR argv[]) | 8 | int __cdecl wmain(int argc, LPWSTR argv[]) |
| 6 | { | 9 | { |
| 7 | HRESULT hr = E_INVALIDARG; | 10 | HRESULT hr = E_INVALIDARG; |
| @@ -11,8 +14,14 @@ int __cdecl wmain(int argc, LPWSTR argv[]) | |||
| 11 | if (argc < 2) | 14 | if (argc < 2) |
| 12 | { | 15 | { |
| 13 | ConsoleWriteError(hr, CONSOLE_COLOR_RED, "Must specify a command"); | 16 | ConsoleWriteError(hr, CONSOLE_COLOR_RED, "Must specify a command"); |
| 17 | |||
| 18 | ExitFunction(); | ||
| 14 | } | 19 | } |
| 15 | else if (CSTR_EQUAL == ::CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, argv[1], -1, L"smartcab", -1)) | 20 | |
| 21 | hr = WixNativeReadStdinPreamble(); | ||
| 22 | ExitOnFailure(hr, "failed to read stdin preamble"); | ||
| 23 | |||
| 24 | if (CSTR_EQUAL == ::CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, argv[1], -1, L"smartcab", -1)) | ||
| 16 | { | 25 | { |
| 17 | hr = SmartCabCommand(argc - 2, argv + 2); | 26 | hr = SmartCabCommand(argc - 2, argv + 2); |
| 18 | } | 27 | } |
| @@ -33,11 +42,12 @@ int __cdecl wmain(int argc, LPWSTR argv[]) | |||
| 33 | ConsoleWriteError(hr, CONSOLE_COLOR_RED, "Unknown command: %ls", argv[1]); | 42 | ConsoleWriteError(hr, CONSOLE_COLOR_RED, "Unknown command: %ls", argv[1]); |
| 34 | } | 43 | } |
| 35 | 44 | ||
| 45 | LExit: | ||
| 36 | ConsoleUninitialize(); | 46 | ConsoleUninitialize(); |
| 37 | return HRESULT_CODE(hr); | 47 | return HRESULT_CODE(hr); |
| 38 | } | 48 | } |
| 39 | 49 | ||
| 40 | HRESULT WixNativeReadStdinPreamble() | 50 | static HRESULT WixNativeReadStdinPreamble() |
| 41 | { | 51 | { |
| 42 | HRESULT hr = S_OK; | 52 | HRESULT hr = S_OK; |
| 43 | LPWSTR sczLine = NULL; | 53 | LPWSTR sczLine = NULL; |
