mirror of
https://github.com/curl/curl.git
synced 2026-08-26 17:43:31 +03:00
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:
parent
f099c2ca55
commit
a535be4ea0
30 changed files with 195 additions and 97 deletions
|
|
@ -30,6 +30,7 @@
|
|||
#ifdef _WIN32
|
||||
#include "winapi.h"
|
||||
#include "snprintf.h"
|
||||
#include "strcopy.h"
|
||||
|
||||
/* This is a helper function for curlx_strerror that converts Windows API error
|
||||
* codes (GetLastError) to error messages.
|
||||
|
|
@ -93,8 +94,7 @@ const char *curlx_winapi_strerror(DWORD err, char *buf, size_t buflen)
|
|||
#else
|
||||
{
|
||||
const char *txt = (err == ERROR_SUCCESS) ? "No error" : "Error";
|
||||
if(strlen(txt) < buflen)
|
||||
strcpy(buf, txt);
|
||||
curlx_strcopy(buf, buflen, txt, strlen(txt));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue