mirror of
https://github.com/curl/curl.git
synced 2026-08-24 12:13:33 +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().
This commit is contained in:
parent
6b9c75e219
commit
f249199426
30 changed files with 197 additions and 97 deletions
|
|
@ -60,6 +60,7 @@
|
|||
#include "select.h"
|
||||
#include "strcase.h"
|
||||
#include "easy_lock.h"
|
||||
#include "curlx/strcopy.h"
|
||||
#include "curlx/strparse.h"
|
||||
|
||||
#if defined(CURLRES_SYNCH) && \
|
||||
|
|
@ -622,7 +623,7 @@ static struct Curl_addrinfo *get_localhost6(int port, const char *name)
|
|||
ca->ai_addr = (void *)((char *)ca + sizeof(struct Curl_addrinfo));
|
||||
memcpy(ca->ai_addr, &sa6, ss_size);
|
||||
ca->ai_canonname = (char *)ca->ai_addr + ss_size;
|
||||
strcpy(ca->ai_canonname, name);
|
||||
curlx_strcopy(ca->ai_canonname, hostlen + 1, name, hostlen);
|
||||
return ca;
|
||||
}
|
||||
#else
|
||||
|
|
@ -659,7 +660,7 @@ static struct Curl_addrinfo *get_localhost(int port, const char *name)
|
|||
ca->ai_addr = (void *)((char *)ca + sizeof(struct Curl_addrinfo));
|
||||
memcpy(ca->ai_addr, &sa, ss_size);
|
||||
ca->ai_canonname = (char *)ca->ai_addr + ss_size;
|
||||
strcpy(ca->ai_canonname, name);
|
||||
curlx_strcopy(ca->ai_canonname, hostlen + 1, name, hostlen);
|
||||
|
||||
ca6 = get_localhost6(port, name);
|
||||
if(!ca6)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue