curlx: curlx_strcopy() instead of strcpy()

This function REQUIRES the size of the target buffer as well as the
length of the source string. Meant to make it harder to do a bad
strcpy().

Removes 23 calls to strcpy().

Closes #20067
This commit is contained in:
Daniel Stenberg 2025-12-21 23:40:24 +01:00
parent f099c2ca55
commit a535be4ea0
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
30 changed files with 195 additions and 97 deletions

View file

@ -30,6 +30,7 @@
#include "curlx/winapi.h"
#include "strerror.h"
#include "curlx/strcopy.h"
const char *curl_easy_strerror(CURLcode error)
{
@ -663,8 +664,7 @@ const char *Curl_sspi_strerror(SECURITY_STATUS err, char *buf, size_t buflen)
txt = "No error";
else
txt = "Error";
if(buflen > strlen(txt))
strcpy(buf, txt);
curlx_strcopy(buf, buflen, txt, strlen(txt));
#endif
if(errno != old_errno)