mirror of
https://github.com/curl/curl.git
synced 2026-08-25 04:53:31 +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
|
|
@ -72,6 +72,7 @@
|
|||
#include "warnless.h"
|
||||
#include "http_proxy.h"
|
||||
#include "socks.h"
|
||||
#include "strdup.h"
|
||||
/* The last 3 #include files should be in this order */
|
||||
#include "curl_printf.h"
|
||||
#include "curl_memory.h"
|
||||
|
|
@ -4169,13 +4170,12 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data)
|
|||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
ftpc->dirs[0] = calloc(1, dirlen + 1);
|
||||
ftpc->dirs[0] = Curl_strndup(rawPath, dirlen);
|
||||
if(!ftpc->dirs[0]) {
|
||||
free(rawPath);
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
strncpy(ftpc->dirs[0], rawPath, dirlen);
|
||||
ftpc->dirdepth = 1; /* we consider it to be a single dir */
|
||||
fileName = slashPos + 1; /* rest is file name */
|
||||
}
|
||||
|
|
@ -4214,12 +4214,11 @@ CURLcode ftp_parse_url_path(struct Curl_easy *data)
|
|||
CWD requires a parameter and a non-existent parameter a) doesn't
|
||||
work on many servers and b) has no effect on the others. */
|
||||
if(compLen > 0) {
|
||||
char *comp = calloc(1, compLen + 1);
|
||||
char *comp = Curl_strndup(curPos, compLen);
|
||||
if(!comp) {
|
||||
free(rawPath);
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
}
|
||||
strncpy(comp, curPos, compLen);
|
||||
ftpc->dirs[ftpc->dirdepth++] = comp;
|
||||
}
|
||||
curPos = slashPos + 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue