tool_getpass: restore UWP getpass_r(), fixup CI builds, fix UWP -Wnull-dereference

- GHA/windows: switch mingw-w64 UWP CI job to use UCRT.
  `msvcr120_app` was missing `getch()` for example.
  Follow-up to f988842d85 #15637
  This job tests compiling for UWP correctly, but the the resulting
  `curl.exe` still doesn't look like a correct UWP app, now exiting
  on startup with: `curl: error initializing curl library`.

- tool_getpass: restore `getch()` for UWP builds.
  Follow-up to f988842d85 #15637

- schannel: silence `-Werror=null-dereference` warning in mingw-w64 UWP:
  ```
  lib/vtls/schannel_verify.c: In function 'Curl_verify_host':
  lib/vtls/schannel_verify.c:558:33: error: null pointer dereference [-Werror=null-dereference]
    558 |     for(i = 0; i < alt_name_info->cAltEntry; ++i) {
        |                    ~~~~~~~~~~~~~^~~~~~~~~~~
  lib/vtls/schannel_verify.c:559:50: error: null pointer dereference [-Werror=null-dereference]
    559 |       PCERT_ALT_NAME_ENTRY entry = &alt_name_info->rgAltEntry[i];
        |                                     ~~~~~~~~~~~~~^~~~~~~~~~~~
  ```
  Ref: https://github.com/curl/curl/actions/runs/12022656065/job/33515255397?pr=15638#step:19:27
  Follow-up to 9640a8ef6f #15421

- GHA/windows: fix `find` command in MSVC job step.
  Follow-up to 5f9411f953 #15380

- GHA/windows: drop unnecessary `windowsappcompat` lib from mingw-w64
  UWP job. Also drop related MSYS2 package.

- GHA/windows: cmake 3.31.0 still invokes `windres` with wrong options
  with mingw-w64 UPW. Update curl version in comment accordingly.

- GHA/windows: tidy up mingw-w64 UWP spec logic, limit it to gcc.

- GHA/windows: update comments on `curl.exe` UWP startup errors.

Closes #15638
This commit is contained in:
Viktor Szakats 2024-11-26 03:17:53 +01:00
parent f988842d85
commit 72edb22b8a
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
3 changed files with 30 additions and 36 deletions

View File

@ -200,7 +200,7 @@ jobs:
- { build: 'cmake' , sys: 'mingw64', env: 'x86_64' , tflags: '~2301 ~2302' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_ARES=ON', type: 'Debug', name: 'schannel c-ares U' }
- { build: 'cmake' , sys: 'ucrt64' , env: 'ucrt-x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_CURLDEBUG=ON', type: 'Release', name: 'schannel R TrackMemory' }
- { build: 'cmake' , sys: 'clang64', env: 'clang-x86_64', tflags: 'skiprun' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_OPENSSL=ON -DENABLE_UNICODE=OFF', type: 'Release', name: 'openssl' }
- { build: 'cmake' , sys: 'mingw64', env: 'x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON', type: 'Release', test: 'uwp', name: 'schannel R' }
- { build: 'cmake' , sys: 'ucrt64' , env: 'ucrt-x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON', type: 'Release', test: 'uwp', name: 'schannel' }
- { build: 'cmake' , sys: 'mingw64', env: 'x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DCMAKE_VERBOSE_MAKEFILE=ON', type: 'Debug', cflags: '-DCURL_SCHANNEL_DEV_DEBUG', name: 'schannel dev debug' }
- { build: 'cmake' , sys: 'mingw32', env: 'i686' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON', type: 'Release', name: 'schannel R' }
fail-fast: false
@ -325,11 +325,13 @@ jobs:
fi
if [ '${{ matrix.test }}' = 'uwp' ]; then
options+=' -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0'
pacman --noconfirm --ask 20 --noprogressbar --sync --needed 'mingw-w64-${{ matrix.env }}-winstorecompat-git'
specs="$(realpath gcc-specs-uwp)"
gcc -dumpspecs | sed -e 's/-lmingwex/-lwindowsapp -lmingwex -lwindowsapp -lwindowsappcompat/' -e 's/-lmsvcrt/-lmsvcr120_app/' > "${specs}"
cflags="-specs=$(cygpath -w "${specs}") -DWINSTORECOMPAT -DWINAPI_FAMILY=WINAPI_FAMILY_APP"
# CMake (as of v3.26.4) gets confused and applies the MSVC rc.exe command-line
cflags='-DWINSTORECOMPAT -DWINAPI_FAMILY=WINAPI_FAMILY_APP'
if [[ '${{ matrix.env }}' != 'clang'* ]]; then
specs="$(realpath gcc-specs-uwp)"
gcc -dumpspecs | sed -e 's/-lmingwex/-lwindowsapp -lmingwex -lwindowsapp/' -e 's/-lmsvcrt/-lucrtapp/' > "${specs}"
cflags+=" -specs=$(cygpath -w "${specs}")"
fi
# CMake (as of v3.31.0) gets confused and applies the MSVC rc.exe command-line
# template to windres. Reset it to the windres template manually:
rcopts='<CMAKE_RC_COMPILER> -O coff <DEFINES> <INCLUDES> <FLAGS> <SOURCE> <OBJECT>'
else
@ -366,7 +368,7 @@ jobs:
timeout-minutes: 1
run: |
find . -name '*.exe' -o -name '*.dll'
if [ '${{ matrix.test }}' != 'uwp' ]; then # UWP missing 'msvcr120_app.dll', fails with exit code 0xc0000135
if [ '${{ matrix.test }}' != 'uwp' ]; then # curl: error initializing curl library
PATH="$PWD/bld/lib:$PATH"
bld/src/curl.exe --disable --version
fi
@ -774,8 +776,8 @@ jobs:
- name: 'curl version'
timeout-minutes: 1
run: |
find . -name '*.exe' -o -name '*.dll'
if [ '${{ matrix.plat }}' != 'uwp' ]; then
PATH=/usr/bin find . -name '*.exe' -o -name '*.dll'
if [ '${{ matrix.plat }}' != 'uwp' ]; then # Missing: ucrtbased.dll, VCRUNTIME140D.dll, VCRUNTIME140D_APP.dll
PATH="$PWD/bld/lib:$PATH"
bld/src/curl.exe --disable --version
fi

View File

@ -554,7 +554,7 @@ CURLcode Curl_verify_host(struct Curl_cfilter *cf,
}
}
if(p->size) {
if(p->size && alt_name_info) {
for(i = 0; i < alt_name_info->cAltEntry; ++i) {
PCERT_ALT_NAME_ENTRY entry = &alt_name_info->rgAltEntry[i];
if(entry->dwAltNameChoice == CERT_ALT_NAME_IP_ADDRESS) {
@ -571,7 +571,6 @@ CURLcode Curl_verify_host(struct Curl_cfilter *cf,
}
}
}
else {
/* Determine the size of the string needed for the cert hostname */
len = cert_get_name_string(data, pCertContextServer,

View File

@ -98,34 +98,27 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
char *getpass_r(const char *prompt, char *buffer, size_t buflen)
{
size_t i;
fputs(prompt, tool_stderr);
#ifdef CURL_WINDOWS_UWP
fputs("\n", tool_stderr);
if(buflen > 0)
buffer[0] = '\0';
#else
{
size_t i;
for(i = 0; i < buflen; i++) {
buffer[i] = (char)getch();
if(buffer[i] == '\r' || buffer[i] == '\n') {
buffer[i] = '\0';
break;
}
else
if(buffer[i] == '\b')
/* remove this letter and if this is not the first key, remove the
previous one as well */
i = i - (i >= 1 ? 2 : 1);
for(i = 0; i < buflen; i++) {
buffer[i] = (char)getch();
if(buffer[i] == '\r' || buffer[i] == '\n') {
buffer[i] = '\0';
break;
}
/* since echo is disabled, print a newline */
fputs("\n", tool_stderr);
/* if user did not hit ENTER, terminate buffer */
if(i == buflen)
buffer[buflen-1] = '\0';
}
#endif
else
if(buffer[i] == '\b')
/* remove this letter and if this is not the first key, remove the
previous one as well */
i = i - (i >= 1 ? 2 : 1);
}
/* since echo is disabled, print a newline */
fputs("\n", tool_stderr);
/* if user did not hit ENTER, terminate buffer */
if(i == buflen)
buffer[buflen-1] = '\0';
return buffer; /* we always return success */
}
#define DONE