← Commit list

eaa7651374

Viktor Szakats
Viktor Szakats
2025-11-21
SUCCESS Duration: 218s

Subject

lib: replace `_tcsncpy`/`wcsncpy`/`wcscpy` with `_s` counterparts (Windows)

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/curl_setup.h+1 -1
@@ -98,7 +98,7 @@
#define _CRT_SECURE_NO_WARNINGS /* for __sys_errlist, __sys_nerr, _open(),
_wfopen(), _wopen(), fopen(), freopen(),
getenv(), gmtime(), mbstowcs(), sprintf(),
- strcpy(), wcscpy(), wcsncpy(), wcstombs(),
+ strcpy(), wcstombs(),
in tests: localtime(), open(), sscanf() */
#endif
#endif /* _MSC_VER */
lib/curl_sspi.c+5 -2
@@ -149,8 +149,11 @@ CURLcode Curl_create_sspi_identity(const char *userp, const char *passwdp,
curlx_unicodefree(useranddomain.tchar_ptr);
return CURLE_OUT_OF_MEMORY;
}
- _tcsncpy(dup_domain.tchar_ptr, domain.tchar_ptr, domlen);
- *(dup_domain.tchar_ptr + domlen) = TEXT('\0');
+ if(_tcsncpy_s(dup_domain.tchar_ptr, domlen + 1, domain.tchar_ptr, domlen)) {
+ curlx_unicodefree(dup_domain.tchar_ptr);
+ curlx_unicodefree(useranddomain.tchar_ptr);
+ return CURLE_OUT_OF_MEMORY;
+ }
identity->Domain = dup_domain.tbyte_ptr;
identity->DomainLength = curlx_uztoul(domlen);
dup_domain.tchar_ptr = NULL;
lib/curlx/fopen.c+16 -4
@@ -158,8 +158,14 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out)
if(!temp)
goto cleanup;
- wcsncpy(temp, L"\\\\?\\UNC\\", 8);
- wcscpy(temp + 8, fbuf + 2);
+ if(wcsncpy_s(temp, needed, L"\\\\?\\UNC\\", 8)) {
+ (free)(temp);
+ goto cleanup;
+ }
+ if(wcscpy_s(temp + 8, needed, fbuf + 2)) {
+ (free)(temp);
+ goto cleanup;
+ }
}
else {
/* "\\?\" + full path + null */
@@ -171,8 +177,14 @@ static bool fix_excessive_path(const TCHAR *in, TCHAR **out)
if(!temp)
goto cleanup;
- wcsncpy(temp, L"\\\\?\\", 4);
- wcscpy(temp + 4, fbuf);
+ if(wcsncpy_s(temp, needed, L"\\\\?\\", 4)) {
+ (free)(temp);
+ goto cleanup;
+ }
+ if(wcscpy_s(temp + 4, needed, fbuf)) {
+ (free)(temp);
+ goto cleanup;
+ }
}
(free)(fbuf);