mirror of
https://github.com/curl/curl.git
synced 2026-08-09 09:34:16 +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
10
lib/http.c
10
lib/http.c
|
|
@ -297,7 +297,6 @@ char *Curl_copy_header_value(const char *header)
|
|||
{
|
||||
const char *start;
|
||||
const char *end;
|
||||
char *value;
|
||||
size_t len;
|
||||
|
||||
/* Find the end of the header name */
|
||||
|
|
@ -330,14 +329,7 @@ char *Curl_copy_header_value(const char *header)
|
|||
/* get length of the type */
|
||||
len = end - start + 1;
|
||||
|
||||
value = malloc(len + 1);
|
||||
if(!value)
|
||||
return NULL;
|
||||
|
||||
memcpy(value, start, len);
|
||||
value[len] = 0; /* null-terminate */
|
||||
|
||||
return value;
|
||||
return Curl_strndup(start, len);
|
||||
}
|
||||
|
||||
#ifndef CURL_DISABLE_HTTP_AUTH
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue