mirror of
https://github.com/curl/curl.git
synced 2026-08-02 16:20:28 +03:00
lib: strndup/memdup instead of malloc, memcpy and null-terminate
- bufref: use strndup - cookie: use strndup - formdata: use strndup - ftp: use strndup - gtls: use aprintf instead of malloc + strcpy * 2 - http: use strndup - mbedtls: use strndup - md4: use memdup - ntlm: use memdup - ntlm_sspi: use strndup - pingpong: use memdup - rtsp: use strndup instead of malloc, memcpy and null-terminate - sectransp: use strndup - socks_gssapi.c: use memdup - vtls: use dynbuf instead of malloc, snprintf and memcpy - vtls: use strdup instead of malloc + memcpy - wolfssh: use strndup Closes #12453
This commit is contained in:
parent
63cdaefbc3
commit
7309b9cbbf
16 changed files with 48 additions and 91 deletions
|
|
@ -25,6 +25,7 @@
|
|||
#include "curl_setup.h"
|
||||
#include "urldata.h"
|
||||
#include "bufref.h"
|
||||
#include "strdup.h"
|
||||
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
|
@ -116,12 +117,9 @@ CURLcode Curl_bufref_memdup(struct bufref *br, const void *ptr, size_t len)
|
|||
DEBUGASSERT(len <= CURL_MAX_INPUT_LENGTH);
|
||||
|
||||
if(ptr) {
|
||||
cpy = malloc(len + 1);
|
||||
cpy = Curl_strndup(ptr, len);
|
||||
if(!cpy)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
if(len)
|
||||
memcpy(cpy, ptr, len);
|
||||
cpy[len] = '\0';
|
||||
}
|
||||
|
||||
Curl_bufref_set(br, cpy, len, curl_free);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue