tool_getpass: make local getpass_r() a dummy for UWP
The CRT call `getch()` isn't supported on Windows UWP. This function is
used to implement `getpass_r()` for reading a password from the console,
for platforms not supporting it natively. This patch makes this function
a dummy, so password entry from the command-line is no longer supported
for UWP apps. Though it probably did not work before this patch, due to:
CRT headers do declare `getch()`, but it's missing from the CRT DLL.
MSDN documents it as unsupported for UWP:
https://learn.microsoft.com/cpp/c-runtime-library/reference/getch
https://learn.microsoft.com/cpp/c-runtime-library/reference/getch-getwch
Same is true for the non-deprecated `_getch()` function.
After mingw-w64 synced its implib with `msvcr120_app.dll`, the CI job
`mingw, CM x86_64 schannel R uwp` broke with:
```
[16/16] Linking C executable src\curl.exe
FAILED: src/curl.exe
[...]
D:/a/_temp/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
src/CMakeFiles/curl.dir/Unity/unity_0_c.c.obj:unity_0_c.c:(.text+0x4d05): undefined reference to `getch'
```
Ref: https://github.com/curl/curl/actions/runs/11873795410/job/33089008727?pr=15597#step:19:25
Also:
- GHA/windows: bump `msys2/setup-msys2` action to
https://github.com/msys2/setup-msys2/commit/c52d1fa
This triggered the build failure above.
Closes #15597
Ref: d408f51e5a/tree/mingw-w64-crt/def-include/crt-aliases.def.in
Closes #15637
This commit is contained in:
parent
4cded6deac
commit
f988842d85
4
.github/workflows/windows.yml
vendored
4
.github/workflows/windows.yml
vendored
@ -210,7 +210,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||||
|
|
||||||
- uses: msys2/setup-msys2@ddf331adaebd714795f1042345e6ca57bd66cea8 # v2
|
- uses: msys2/setup-msys2@c52d1fa9c7492275e60fe763540fb601f5f232a1 # v2
|
||||||
if: ${{ matrix.sys == 'msys' }}
|
if: ${{ matrix.sys == 'msys' }}
|
||||||
with:
|
with:
|
||||||
msystem: ${{ matrix.sys }}
|
msystem: ${{ matrix.sys }}
|
||||||
@ -226,7 +226,7 @@ jobs:
|
|||||||
libpsl-devel
|
libpsl-devel
|
||||||
libssh2-devel
|
libssh2-devel
|
||||||
|
|
||||||
- uses: msys2/setup-msys2@ddf331adaebd714795f1042345e6ca57bd66cea8 # v2
|
- uses: msys2/setup-msys2@c52d1fa9c7492275e60fe763540fb601f5f232a1 # v2
|
||||||
if: ${{ matrix.sys != 'msys' }}
|
if: ${{ matrix.sys != 'msys' }}
|
||||||
with:
|
with:
|
||||||
msystem: ${{ matrix.sys }}
|
msystem: ${{ matrix.sys }}
|
||||||
|
|||||||
@ -98,8 +98,14 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
|
|||||||
|
|
||||||
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);
|
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++) {
|
for(i = 0; i < buflen; i++) {
|
||||||
buffer[i] = (char)getch();
|
buffer[i] = (char)getch();
|
||||||
@ -118,7 +124,8 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
|
|||||||
/* if user did not hit ENTER, terminate buffer */
|
/* if user did not hit ENTER, terminate buffer */
|
||||||
if(i == buflen)
|
if(i == buflen)
|
||||||
buffer[buflen-1] = '\0';
|
buffer[buflen-1] = '\0';
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return buffer; /* we always return success */
|
return buffer; /* we always return success */
|
||||||
}
|
}
|
||||||
#define DONE
|
#define DONE
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user