curl/lib/curlx
Viktor Szakats eaa7651374
lib: replace _tcsncpy/wcsncpy/wcscpy with _s counterparts (Windows)
Replace:
- curl_sspi: macro `_tcsncpy()` with `_tcsncpy_s()`.
- curlx/fopen: `wcsncpy()` with `wcsncpy_s()`.
- curlx/fopen: `wcscpy()` with `wcscpy_s()`.

Use of the pre-existing functions were safe. This patch aims to use the
recommended Windows CRT functions. Handle errors returned by them. Also
to avoid the compiler warnings silenced via `_CRT_SECURE_NO_WARNINGS`:

```
lib/curl_sspi.c(152): warning C4996: 'wcsncpy': This function or variable may be unsafe. Consider using wcsncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
lib/curlx/fopen.c(161): warning C4996: 'wcsncpy': This function or variable may be unsafe. Consider using wcsncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
lib/curlx/fopen.c(162): warning C4996: 'wcscpy': This function or variable may be unsafe. Consider using wcscpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
lib/curlx/fopen.c(174): warning C4996: 'wcsncpy': This function or variable may be unsafe. Consider using wcsncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
lib/curlx/fopen.c(175): warning C4996: 'wcscpy': This function or variable may be unsafe. Consider using wcscpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
```

Refs:
https://learn.microsoft.com/cpp/c-runtime-library/reference/strncpy-strncpy-l-wcsncpy-wcsncpy-l-mbsncpy-mbsncpy-l
https://learn.microsoft.com/cpp/c-runtime-library/reference/strncpy-s-strncpy-s-l-wcsncpy-s-wcsncpy-s-l-mbsncpy-s-mbsncpy-s-l
https://learn.microsoft.com/cpp/c-runtime-library/security-features-in-the-crt

Cherry-picked from #19581 (in part)
Closes #19589
2025-11-21 13:48:35 +01:00
..
base64.c base64: make base64_encode() error on too long input 2025-10-30 15:41:28 +01:00
base64.h base64: make base64_encode() error on too long input 2025-10-30 15:41:28 +01:00
binmode.h lib: make CURLX_SET_BINMODE() and use it 2025-06-19 15:57:37 +02:00
curlx.h curlx: move Curl_strerror, use in src and tests, ban strerror globally 2025-10-06 09:44:23 +02:00
dynbuf.c dynbuf: assert on curlx_dyn_addf use with just "%s" 2025-08-06 08:32:07 +02:00
dynbuf.h curl_setup: use SIZE_MAX instead of SIZE_T_MAX 2025-08-29 09:45:06 +02:00
fopen.c lib: replace _tcsncpy/wcsncpy/wcscpy with _s counterparts (Windows) 2025-11-21 13:48:35 +01:00
fopen.h curlx: add and use curlx_freopen() 2025-11-19 22:04:53 +01:00
inet_ntop.c build: drop Windows CE / CeGCC support 2025-11-15 15:35:23 +01:00
inet_ntop.h inet_pton, inet_ntop: drop declarations when unused 2025-07-28 01:51:55 +02:00
inet_pton.c build: drop Windows CE / CeGCC support 2025-11-15 15:35:23 +01:00
inet_pton.h inet_pton, inet_ntop: drop declarations when unused 2025-07-28 01:51:55 +02:00
multibyte.c build: avoid overriding system symbols for fopen functions 2025-09-30 01:10:36 +02:00
multibyte.h tidy-up: move CURL_UNCONST() out from macro curl_unicodefree() 2025-11-19 15:48:21 +01:00
nonblock.c tidy-up: prefer ifdef/ifndef for single checks 2025-07-27 22:35:17 +02:00
nonblock.h curlx: move nonblock.[ch] into curlx/ 2025-05-08 13:22:02 +02:00
strerr.c build: drop Windows CE / CeGCC support 2025-11-15 15:35:23 +01:00
strerr.h curlx: move Curl_strerror, use in src and tests, ban strerror globally 2025-10-06 09:44:23 +02:00
strparse.c curl_setup: use SIZE_MAX instead of SIZE_T_MAX 2025-08-29 09:45:06 +02:00
strparse.h tidy-up: whitespace 2025-07-11 13:32:54 +02:00
timediff.c curlx: move into to curlx/ 2025-05-07 11:01:15 +02:00
timediff.h curlx: move into to curlx/ 2025-05-07 11:01:15 +02:00
timeval.c lib: rename curlx_timediff to curlx_timeleft_ms 2025-11-13 13:12:58 +01:00
timeval.h lib: rename curlx_timediff to curlx_timeleft_ms 2025-11-13 13:12:58 +01:00
version_win32.c build: drop Windows CE / CeGCC support 2025-11-15 15:35:23 +01:00
version_win32.h curlx: move version_win32.[ch] to curlx/ 2025-05-08 17:09:32 +02:00
wait.c tidy-up: prefer ifdef/ifndef for single checks 2025-07-27 22:35:17 +02:00
wait.h lib: make curlx_wait_ms() and use it 2025-06-19 15:57:37 +02:00
warnless.c mqtt: eliminate size_t cast 2025-11-20 17:39:39 +01:00
warnless.h mqtt: eliminate size_t cast 2025-11-20 17:39:39 +01:00
winapi.c build: drop Windows CE / CeGCC support 2025-11-15 15:35:23 +01:00
winapi.h windows: use native error code types more 2025-10-06 12:12:44 +02:00