]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_getpass: restore UWP `getpass_r()`, fixup CI builds, fix UWP `-Wnull-dereference`
authorViktor Szakats <commit@vsz.me>
Tue, 26 Nov 2024 02:17:53 +0000 (03:17 +0100)
committerViktor Szakats <commit@vsz.me>
Tue, 26 Nov 2024 12:01:57 +0000 (13:01 +0100)
- GHA/windows: switch mingw-w64 UWP CI job to use UCRT.
  `msvcr120_app` was missing `getch()` for example.
  Follow-up to f988842d85a06d7ad03764433b6dfee9febf0118 #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 f988842d85a06d7ad03764433b6dfee9febf0118 #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 9640a8ef6f0db21da2ee7864423aa28cc3cecce2 #15421

- GHA/windows: fix `find` command in MSVC job step.
  Follow-up to 5f9411f953f35ca84645b5a6824fb9fef20887ed #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

.github/workflows/windows.yml
lib/vtls/schannel_verify.c
src/tool_getpass.c

index 5b572e09bdad632c21e1938ace4a0aafaaf22f5e..8c7c09c4e67bcfe4d7839053116307f44a61346f 100644 (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
index 4b52b8e8a499cd38e2e8758dd8b0a551902956cd..fede3908feba5920c7b4fc43454718c7ca2e0488 100644 (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,
index 84d089b6e76fc3e5ef8678d37f9943d5cdc36caa..412c50a114aa7db13d232c3de7aae43eeb7f9872 100644 (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);
-    }
-    /* 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';
+
+  for(i = 0; i < buflen; i++) {
+    buffer[i] = (char)getch();
+    if(buffer[i] == '\r' || buffer[i] == '\n') {
+      buffer[i] = '\0';
+      break;
     }
-#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