mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
remove unnecessary typecasting of malloc()
This commit is contained in:
parent
a622fd90b4
commit
59e378f48f
@ -675,7 +675,7 @@ DhcpNameServer
|
|||||||
{
|
{
|
||||||
if (bytes)
|
if (bytes)
|
||||||
{
|
{
|
||||||
line = (char *)malloc(bytes+1);
|
line = malloc(bytes+1);
|
||||||
if (RegQueryValueEx(mykey, NAMESERVER, NULL, &data_type,
|
if (RegQueryValueEx(mykey, NAMESERVER, NULL, &data_type,
|
||||||
(unsigned char *)line, &bytes) ==
|
(unsigned char *)line, &bytes) ==
|
||||||
ERROR_SUCCESS)
|
ERROR_SUCCESS)
|
||||||
@ -952,7 +952,7 @@ static int init_by_defaults(ares_channel channel)
|
|||||||
size_t len = 64;
|
size_t len = 64;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
hostname = (char *)malloc(len);
|
hostname = malloc(len);
|
||||||
if(!hostname) {
|
if(!hostname) {
|
||||||
rc = ARES_ENOMEM;
|
rc = ARES_ENOMEM;
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -77,7 +77,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
|||||||
|
|
||||||
/* Examine each answer resource record (RR) in turn. */
|
/* Examine each answer resource record (RR) in turn. */
|
||||||
hostname = NULL;
|
hostname = NULL;
|
||||||
aliases = (char **) malloc(8 * sizeof(char *));
|
aliases = malloc(8 * sizeof(char *));
|
||||||
if (!aliases)
|
if (!aliases)
|
||||||
{
|
{
|
||||||
free(ptrname);
|
free(ptrname);
|
||||||
|
@ -281,7 +281,7 @@ int main(int argc, char **argv) {
|
|||||||
struct curl_slist * headers=NULL;
|
struct curl_slist * headers=NULL;
|
||||||
int badarg=0;
|
int badarg=0;
|
||||||
|
|
||||||
binaryptr=(char*)malloc(tabLength);
|
binaryptr = malloc(tabLength);
|
||||||
|
|
||||||
p.verbose = 0;
|
p.verbose = 0;
|
||||||
p.errorbio = BIO_new_fp (stderr, BIO_NOCLOSE);
|
p.errorbio = BIO_new_fp (stderr, BIO_NOCLOSE);
|
||||||
@ -404,7 +404,7 @@ int main(int argc, char **argv) {
|
|||||||
/* determine URL to go */
|
/* determine URL to go */
|
||||||
|
|
||||||
if (hostporturl) {
|
if (hostporturl) {
|
||||||
serverurl=(char*) malloc(9+strlen(hostporturl));
|
serverurl = malloc(9+strlen(hostporturl));
|
||||||
sprintf(serverurl,"https://%s",hostporturl);
|
sprintf(serverurl,"https://%s",hostporturl);
|
||||||
}
|
}
|
||||||
else if (p.accesstype != 0) { /* see whether we can find an AIA or SIA for a given access type */
|
else if (p.accesstype != 0) { /* see whether we can find an AIA or SIA for a given access type */
|
||||||
@ -442,7 +442,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
/* pass our list of custom made headers */
|
/* pass our list of custom made headers */
|
||||||
|
|
||||||
contenttype=(char*) malloc(15+strlen(mimetype));
|
contenttype = malloc(15+strlen(mimetype));
|
||||||
sprintf(contenttype,"Content-type: %s",mimetype);
|
sprintf(contenttype,"Content-type: %s",mimetype);
|
||||||
headers = curl_slist_append(headers,contenttype);
|
headers = curl_slist_append(headers,contenttype);
|
||||||
curl_easy_setopt(p.curl, CURLOPT_HTTPHEADER, headers);
|
curl_easy_setopt(p.curl, CURLOPT_HTTPHEADER, headers);
|
||||||
|
@ -221,7 +221,7 @@ url_fopen(const char *url,const char *operation)
|
|||||||
URL_FILE *file;
|
URL_FILE *file;
|
||||||
(void)operation;
|
(void)operation;
|
||||||
|
|
||||||
file = (URL_FILE *)malloc(sizeof(URL_FILE));
|
file = malloc(sizeof(URL_FILE));
|
||||||
if(!file)
|
if(!file)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ int thread_setup(void)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
mutex_buf = (MUTEX_TYPE *)malloc(CRYPTO_num_locks( ) * sizeof(MUTEX_TYPE));
|
mutex_buf = malloc(CRYPTO_num_locks( ) * sizeof(MUTEX_TYPE));
|
||||||
if (!mutex_buf)
|
if (!mutex_buf)
|
||||||
return 0;
|
return 0;
|
||||||
for (i = 0; i < CRYPTO_num_locks( ); i++)
|
for (i = 0; i < CRYPTO_num_locks( ); i++)
|
||||||
|
@ -160,7 +160,7 @@ size_t Curl_base64_encode(struct SessionHandle *data,
|
|||||||
if(0 == insize)
|
if(0 == insize)
|
||||||
insize = strlen(indata);
|
insize = strlen(indata);
|
||||||
|
|
||||||
base64data = output = (char*)malloc(insize*4/3+4);
|
base64data = output = malloc(insize*4/3+4);
|
||||||
if(NULL == output)
|
if(NULL == output)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ size_t Curl_base64_encode(struct SessionHandle *data,
|
|||||||
* so we copy it to a buffer, translate it, and use that instead.
|
* so we copy it to a buffer, translate it, and use that instead.
|
||||||
*/
|
*/
|
||||||
if(data) {
|
if(data) {
|
||||||
convbuf = (char*)malloc(insize);
|
convbuf = malloc(insize);
|
||||||
if(!convbuf) {
|
if(!convbuf) {
|
||||||
free(output);
|
free(output);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -89,7 +89,7 @@ inflate_stream(struct connectdata *conn,
|
|||||||
|
|
||||||
/* Dynamically allocate a buffer for decompression because it's uncommonly
|
/* Dynamically allocate a buffer for decompression because it's uncommonly
|
||||||
large to hold on the stack */
|
large to hold on the stack */
|
||||||
decomp = (char*)malloc(DSIZ);
|
decomp = malloc(DSIZ);
|
||||||
if(decomp == NULL) {
|
if(decomp == NULL) {
|
||||||
return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
|
return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
@ -711,7 +711,7 @@ struct CookieInfo *Curl_cookie_init(struct SessionHandle *data,
|
|||||||
char *lineptr;
|
char *lineptr;
|
||||||
bool headerline;
|
bool headerline;
|
||||||
|
|
||||||
char *line = (char *)malloc(MAX_COOKIE_LINE);
|
char *line = malloc(MAX_COOKIE_LINE);
|
||||||
if(line) {
|
if(line) {
|
||||||
while(fgets(line, MAX_COOKIE_LINE, fp)) {
|
while(fgets(line, MAX_COOKIE_LINE, fp)) {
|
||||||
if(checkprefix("Set-Cookie:", line)) {
|
if(checkprefix("Set-Cookie:", line)) {
|
||||||
@ -789,7 +789,7 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
|
|||||||
/* and now, we know this is a match and we should create an
|
/* and now, we know this is a match and we should create an
|
||||||
entry for the return-linked-list */
|
entry for the return-linked-list */
|
||||||
|
|
||||||
newco = (struct Cookie *)malloc(sizeof(struct Cookie));
|
newco = malloc(sizeof(struct Cookie));
|
||||||
if(newco) {
|
if(newco) {
|
||||||
/* first, copy the whole source cookie: */
|
/* first, copy the whole source cookie: */
|
||||||
memcpy(newco, co, sizeof(struct Cookie));
|
memcpy(newco, co, sizeof(struct Cookie));
|
||||||
|
@ -612,7 +612,7 @@ CURL *curl_easy_duphandle(CURL *incurl)
|
|||||||
* get setup on-demand in the code, as that would probably decrease
|
* get setup on-demand in the code, as that would probably decrease
|
||||||
* the likeliness of us forgetting to init a buffer here in the future.
|
* the likeliness of us forgetting to init a buffer here in the future.
|
||||||
*/
|
*/
|
||||||
outcurl->state.headerbuff=(char*)malloc(HEADERSIZE);
|
outcurl->state.headerbuff = malloc(HEADERSIZE);
|
||||||
if(!outcurl->state.headerbuff) {
|
if(!outcurl->state.headerbuff) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ static FormInfo * AddFormInfo(char *value,
|
|||||||
FormInfo *parent_form_info)
|
FormInfo *parent_form_info)
|
||||||
{
|
{
|
||||||
FormInfo *form_info;
|
FormInfo *form_info;
|
||||||
form_info = (FormInfo *)malloc(sizeof(FormInfo));
|
form_info = malloc(sizeof(FormInfo));
|
||||||
if(form_info) {
|
if(form_info) {
|
||||||
memset(form_info, 0, sizeof(FormInfo));
|
memset(form_info, 0, sizeof(FormInfo));
|
||||||
if(value)
|
if(value)
|
||||||
@ -327,7 +327,7 @@ static char *memdup(const char *src, size_t buffer_length)
|
|||||||
/* no length and a NULL src pointer! */
|
/* no length and a NULL src pointer! */
|
||||||
return strdup("");
|
return strdup("");
|
||||||
|
|
||||||
buffer = (char*)malloc(length+add);
|
buffer = malloc(length+add);
|
||||||
if(!buffer)
|
if(!buffer)
|
||||||
return NULL; /* fail */
|
return NULL; /* fail */
|
||||||
|
|
||||||
@ -838,8 +838,7 @@ static CURLcode AddFormData(struct FormData **formp,
|
|||||||
size_t length,
|
size_t length,
|
||||||
curl_off_t *size)
|
curl_off_t *size)
|
||||||
{
|
{
|
||||||
struct FormData *newform = (struct FormData *)
|
struct FormData *newform = malloc(sizeof(struct FormData));
|
||||||
malloc(sizeof(struct FormData));
|
|
||||||
if(!newform)
|
if(!newform)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
newform->next = NULL;
|
newform->next = NULL;
|
||||||
@ -849,7 +848,7 @@ static CURLcode AddFormData(struct FormData **formp,
|
|||||||
if(!length)
|
if(!length)
|
||||||
length = strlen((char *)line);
|
length = strlen((char *)line);
|
||||||
|
|
||||||
newform->line = (char *)malloc(length+1);
|
newform->line = malloc(length+1);
|
||||||
if(!newform->line) {
|
if(!newform->line) {
|
||||||
free(newform);
|
free(newform);
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
@ -1729,7 +1728,7 @@ char *Curl_FormBoundary(void)
|
|||||||
|
|
||||||
static const char table16[]="abcdef0123456789";
|
static const char table16[]="abcdef0123456789";
|
||||||
|
|
||||||
retstring = (char *)malloc(BOUNDARY_LENGTH+1);
|
retstring = malloc(BOUNDARY_LENGTH+1);
|
||||||
|
|
||||||
if(!retstring)
|
if(!retstring)
|
||||||
return NULL; /* failed */
|
return NULL; /* failed */
|
||||||
|
@ -550,7 +550,7 @@ static CURLcode ftp_readresp(curl_socket_t sockfd,
|
|||||||
|
|
||||||
if(clipamount) {
|
if(clipamount) {
|
||||||
ftpc->cache_size = clipamount;
|
ftpc->cache_size = clipamount;
|
||||||
ftpc->cache = (char *)malloc((int)ftpc->cache_size);
|
ftpc->cache = malloc((int)ftpc->cache_size);
|
||||||
if(ftpc->cache)
|
if(ftpc->cache)
|
||||||
memcpy(ftpc->cache, ftpc->linestart_resp, (int)ftpc->cache_size);
|
memcpy(ftpc->cache, ftpc->linestart_resp, (int)ftpc->cache_size);
|
||||||
else
|
else
|
||||||
@ -2751,7 +2751,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
|
|||||||
|
|
||||||
case FTP_PWD:
|
case FTP_PWD:
|
||||||
if(ftpcode == 257) {
|
if(ftpcode == 257) {
|
||||||
char *dir = (char *)malloc(nread+1);
|
char *dir = malloc(nread+1);
|
||||||
char *store=dir;
|
char *store=dir;
|
||||||
char *ptr=&data->state.buffer[4]; /* start on the first letter */
|
char *ptr=&data->state.buffer[4]; /* start on the first letter */
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ Curl_hash_init(struct curl_hash *h,
|
|||||||
h->size = 0;
|
h->size = 0;
|
||||||
h->slots = slots;
|
h->slots = slots;
|
||||||
|
|
||||||
h->table = (struct curl_llist **) malloc(slots * sizeof(struct curl_llist *));
|
h->table = malloc(slots * sizeof(struct curl_llist *));
|
||||||
if(h->table) {
|
if(h->table) {
|
||||||
for (i = 0; i < slots; ++i) {
|
for (i = 0; i < slots; ++i) {
|
||||||
h->table[i] = Curl_llist_alloc((curl_llist_dtor) hash_element_dtor);
|
h->table[i] = Curl_llist_alloc((curl_llist_dtor) hash_element_dtor);
|
||||||
@ -96,7 +96,7 @@ Curl_hash_alloc(int slots,
|
|||||||
return NULL; /* failure */
|
return NULL; /* failure */
|
||||||
}
|
}
|
||||||
|
|
||||||
h = (struct curl_hash *) malloc(sizeof(struct curl_hash));
|
h = malloc(sizeof(struct curl_hash));
|
||||||
if(h) {
|
if(h) {
|
||||||
if(Curl_hash_init(h, slots, hfunc, comparator, dtor)) {
|
if(Curl_hash_init(h, slots, hfunc, comparator, dtor)) {
|
||||||
/* failure */
|
/* failure */
|
||||||
@ -113,8 +113,7 @@ Curl_hash_alloc(int slots,
|
|||||||
static struct curl_hash_element *
|
static struct curl_hash_element *
|
||||||
mk_hash_element(const void *key, size_t key_len, const void *p)
|
mk_hash_element(const void *key, size_t key_len, const void *p)
|
||||||
{
|
{
|
||||||
struct curl_hash_element *he =
|
struct curl_hash_element *he = malloc(sizeof(struct curl_hash_element));
|
||||||
(struct curl_hash_element *) malloc(sizeof(struct curl_hash_element));
|
|
||||||
|
|
||||||
if(he) {
|
if(he) {
|
||||||
void *dupkey = malloc(key_len);
|
void *dupkey = malloc(key_len);
|
||||||
|
@ -971,7 +971,7 @@ static
|
|||||||
send_buffer *add_buffer_init(void)
|
send_buffer *add_buffer_init(void)
|
||||||
{
|
{
|
||||||
send_buffer *blonk;
|
send_buffer *blonk;
|
||||||
blonk=(send_buffer *)malloc(sizeof(send_buffer));
|
blonk = malloc(sizeof(send_buffer));
|
||||||
if(blonk) {
|
if(blonk) {
|
||||||
memset(blonk, 0, sizeof(send_buffer));
|
memset(blonk, 0, sizeof(send_buffer));
|
||||||
return blonk;
|
return blonk;
|
||||||
@ -1193,7 +1193,7 @@ CURLcode add_buffer(send_buffer *in, const void *inptr, size_t size)
|
|||||||
new_rb = realloc(in->buffer, new_size);
|
new_rb = realloc(in->buffer, new_size);
|
||||||
else
|
else
|
||||||
/* create a new buffer */
|
/* create a new buffer */
|
||||||
new_rb = (char *)malloc(new_size);
|
new_rb = malloc(new_size);
|
||||||
|
|
||||||
if(!new_rb) {
|
if(!new_rb) {
|
||||||
/* If we failed, we cleanup the whole buffer and return error */
|
/* If we failed, we cleanup the whole buffer and return error */
|
||||||
|
@ -309,7 +309,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
conn->trlMax=128;
|
conn->trlMax=128;
|
||||||
ptr = (char*)malloc(conn->trlMax);
|
ptr = malloc(conn->trlMax);
|
||||||
}
|
}
|
||||||
if(!ptr)
|
if(!ptr)
|
||||||
return CHUNKE_OUT_OF_MEMORY;
|
return CHUNKE_OUT_OF_MEMORY;
|
||||||
|
@ -320,7 +320,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
|
|||||||
Curl_md5it(md5buf, md5this);
|
Curl_md5it(md5buf, md5this);
|
||||||
free(md5this); /* free this again */
|
free(md5this); /* free this again */
|
||||||
|
|
||||||
ha1 = (unsigned char *)malloc(33); /* 32 digits and 1 zero byte */
|
ha1 = malloc(33); /* 32 digits and 1 zero byte */
|
||||||
if(!ha1)
|
if(!ha1)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ Curl_llist_alloc(curl_llist_dtor dtor)
|
|||||||
{
|
{
|
||||||
struct curl_llist *list;
|
struct curl_llist *list;
|
||||||
|
|
||||||
list = (struct curl_llist *)malloc(sizeof(struct curl_llist));
|
list = malloc(sizeof(struct curl_llist));
|
||||||
if(NULL == list)
|
if(NULL == list)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -62,8 +62,7 @@ int
|
|||||||
Curl_llist_insert_next(struct curl_llist *list, struct curl_llist_element *e,
|
Curl_llist_insert_next(struct curl_llist *list, struct curl_llist_element *e,
|
||||||
const void *p)
|
const void *p)
|
||||||
{
|
{
|
||||||
struct curl_llist_element *ne =
|
struct curl_llist_element *ne = malloc(sizeof(struct curl_llist_element));
|
||||||
(struct curl_llist_element *) malloc(sizeof(struct curl_llist_element));
|
|
||||||
if(!ne)
|
if(!ne)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -1068,7 +1068,7 @@ static int alloc_addbyter(int output, FILE *data)
|
|||||||
unsigned char outc = (unsigned char)output;
|
unsigned char outc = (unsigned char)output;
|
||||||
|
|
||||||
if(!infop->buffer) {
|
if(!infop->buffer) {
|
||||||
infop->buffer=(char *)malloc(32);
|
infop->buffer = malloc(32);
|
||||||
if(!infop->buffer) {
|
if(!infop->buffer) {
|
||||||
infop->fail = 1;
|
infop->fail = 1;
|
||||||
return -1; /* fail */
|
return -1; /* fail */
|
||||||
|
@ -1427,7 +1427,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* now add a node to the Curl_message linked list with this info */
|
/* now add a node to the Curl_message linked list with this info */
|
||||||
msg = (struct Curl_message *)malloc(sizeof(struct Curl_message));
|
msg = malloc(sizeof(struct Curl_message));
|
||||||
|
|
||||||
if(!msg)
|
if(!msg)
|
||||||
return CURLM_OUT_OF_MEMORY;
|
return CURLM_OUT_OF_MEMORY;
|
||||||
|
18
lib/nss.c
18
lib/nss.c
@ -298,8 +298,8 @@ nss_load_cert(const char *filename, PRBool cacert)
|
|||||||
else
|
else
|
||||||
slotID = 1;
|
slotID = 1;
|
||||||
|
|
||||||
slotname = (char *)malloc(SLOTSIZE);
|
slotname = malloc(SLOTSIZE);
|
||||||
nickname = (char *)malloc(PATH_MAX);
|
nickname = malloc(PATH_MAX);
|
||||||
snprintf(slotname, SLOTSIZE, "PEM Token #%ld", slotID);
|
snprintf(slotname, SLOTSIZE, "PEM Token #%ld", slotID);
|
||||||
snprintf(nickname, PATH_MAX, "PEM Token #%ld:%s", slotID, n);
|
snprintf(nickname, PATH_MAX, "PEM Token #%ld:%s", slotID, n);
|
||||||
|
|
||||||
@ -460,7 +460,7 @@ static int nss_load_key(struct connectdata *conn, char *key_file)
|
|||||||
|
|
||||||
slotID = 1; /* hardcoded for now */
|
slotID = 1; /* hardcoded for now */
|
||||||
|
|
||||||
slotname = (char *)malloc(SLOTSIZE);
|
slotname = malloc(SLOTSIZE);
|
||||||
snprintf(slotname, SLOTSIZE, "PEM Token #%ld", slotID);
|
snprintf(slotname, SLOTSIZE, "PEM Token #%ld", slotID);
|
||||||
|
|
||||||
slot = PK11_FindSlotByName(slotname);
|
slot = PK11_FindSlotByName(slotname);
|
||||||
@ -485,7 +485,7 @@ static int nss_load_key(struct connectdata *conn, char *key_file)
|
|||||||
SECMOD_WaitForAnyTokenEvent(mod, 0, 0);
|
SECMOD_WaitForAnyTokenEvent(mod, 0, 0);
|
||||||
PK11_IsPresent(slot);
|
PK11_IsPresent(slot);
|
||||||
|
|
||||||
parg = (pphrase_arg_t *) malloc(sizeof(*parg));
|
parg = malloc(sizeof(pphrase_arg_t));
|
||||||
parg->retryCount = 0;
|
parg->retryCount = 0;
|
||||||
parg->data = conn->data;
|
parg->data = conn->data;
|
||||||
/* parg is initialized in nss_Init_Tokens() */
|
/* parg is initialized in nss_Init_Tokens() */
|
||||||
@ -581,7 +581,7 @@ static SECStatus nss_Init_Tokens(struct connectdata * conn)
|
|||||||
SECStatus ret, status = SECSuccess;
|
SECStatus ret, status = SECSuccess;
|
||||||
pphrase_arg_t *parg = NULL;
|
pphrase_arg_t *parg = NULL;
|
||||||
|
|
||||||
parg = (pphrase_arg_t *) malloc(sizeof(*parg));
|
parg = malloc(sizeof(pphrase_arg_t));
|
||||||
parg->retryCount = 0;
|
parg->retryCount = 0;
|
||||||
parg->data = conn->data;
|
parg->data = conn->data;
|
||||||
|
|
||||||
@ -800,7 +800,7 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
|
|||||||
|
|
||||||
if(!strncmp(nickname, "PEM Token", 9)) {
|
if(!strncmp(nickname, "PEM Token", 9)) {
|
||||||
CK_SLOT_ID slotID = 1; /* hardcoded for now */
|
CK_SLOT_ID slotID = 1; /* hardcoded for now */
|
||||||
char * slotname = (char *)malloc(SLOTSIZE);
|
char * slotname = malloc(SLOTSIZE);
|
||||||
snprintf(slotname, SLOTSIZE, "PEM Token #%ld", slotID);
|
snprintf(slotname, SLOTSIZE, "PEM Token #%ld", slotID);
|
||||||
slot = PK11_FindSlotByName(slotname);
|
slot = PK11_FindSlotByName(slotname);
|
||||||
privKey = PK11_FindPrivateKeyFromCert(slot, cert, NULL);
|
privKey = PK11_FindPrivateKeyFromCert(slot, cert, NULL);
|
||||||
@ -956,7 +956,7 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
|
|||||||
NSS_SetDomesticPolicy();
|
NSS_SetDomesticPolicy();
|
||||||
|
|
||||||
#ifdef HAVE_PK11_CREATEGENERICOBJECT
|
#ifdef HAVE_PK11_CREATEGENERICOBJECT
|
||||||
configstring = (char *)malloc(PATH_MAX);
|
configstring = malloc(PATH_MAX);
|
||||||
|
|
||||||
PR_snprintf(configstring, PATH_MAX, "library=%s name=PEM", pem_library);
|
PR_snprintf(configstring, PATH_MAX, "library=%s name=PEM", pem_library);
|
||||||
|
|
||||||
@ -1091,7 +1091,7 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
|
|||||||
char *n;
|
char *n;
|
||||||
char *nickname;
|
char *nickname;
|
||||||
|
|
||||||
nickname = (char *)malloc(PATH_MAX);
|
nickname = malloc(PATH_MAX);
|
||||||
if(is_file(data->set.str[STRING_CERT])) {
|
if(is_file(data->set.str[STRING_CERT])) {
|
||||||
n = strrchr(data->set.str[STRING_CERT], '/');
|
n = strrchr(data->set.str[STRING_CERT], '/');
|
||||||
if(n) {
|
if(n) {
|
||||||
@ -1159,7 +1159,7 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
|
|||||||
if (data->set.str[STRING_SSL_ISSUERCERT]) {
|
if (data->set.str[STRING_SSL_ISSUERCERT]) {
|
||||||
char *n;
|
char *n;
|
||||||
char *nickname;
|
char *nickname;
|
||||||
nickname = (char *)malloc(PATH_MAX);
|
nickname = malloc(PATH_MAX);
|
||||||
if(is_file(data->set.str[STRING_SSL_ISSUERCERT])) {
|
if(is_file(data->set.str[STRING_SSL_ISSUERCERT])) {
|
||||||
n = strrchr(data->set.str[STRING_SSL_ISSUERCERT], '/');
|
n = strrchr(data->set.str[STRING_SSL_ISSUERCERT], '/');
|
||||||
if (n) {
|
if (n) {
|
||||||
|
@ -185,7 +185,7 @@ int GetOrSetUpData(int id, libdata_t **appData,
|
|||||||
NXLock(gLibLock);
|
NXLock(gLibLock);
|
||||||
|
|
||||||
if(!(app_data = (libdata_t *) get_app_data(id))) {
|
if(!(app_data = (libdata_t *) get_app_data(id))) {
|
||||||
app_data = (libdata_t *) malloc(sizeof(libdata_t));
|
app_data = malloc(sizeof(libdata_t));
|
||||||
|
|
||||||
if(app_data) {
|
if(app_data) {
|
||||||
memset(app_data, 0, sizeof(libdata_t));
|
memset(app_data, 0, sizeof(libdata_t));
|
||||||
@ -246,7 +246,7 @@ int GetOrSetUpData(int id, libdata_t **appData,
|
|||||||
** important, this just helps to demonstrate that we can have arbitrarily
|
** important, this just helps to demonstrate that we can have arbitrarily
|
||||||
** complex per-thread data.
|
** complex per-thread data.
|
||||||
*/
|
*/
|
||||||
thread_data = (libthreaddata_t *) malloc(sizeof(libthreaddata_t));
|
thread_data = malloc(sizeof(libthreaddata_t));
|
||||||
|
|
||||||
if(thread_data) {
|
if(thread_data) {
|
||||||
thread_data->_errno = 0;
|
thread_data->_errno = 0;
|
||||||
|
@ -91,7 +91,7 @@ struct curl_slist *curl_slist_append(struct curl_slist *list,
|
|||||||
struct curl_slist *last;
|
struct curl_slist *last;
|
||||||
struct curl_slist *new_item;
|
struct curl_slist *new_item;
|
||||||
|
|
||||||
new_item = (struct curl_slist *) malloc(sizeof(struct curl_slist));
|
new_item = malloc(sizeof(struct curl_slist));
|
||||||
if(new_item) {
|
if(new_item) {
|
||||||
char *dupdata = strdup(data);
|
char *dupdata = strdup(data);
|
||||||
if(dupdata) {
|
if(dupdata) {
|
||||||
|
@ -36,8 +36,7 @@
|
|||||||
CURLSH *
|
CURLSH *
|
||||||
curl_share_init(void)
|
curl_share_init(void)
|
||||||
{
|
{
|
||||||
struct Curl_share *share =
|
struct Curl_share *share = malloc(sizeof(struct Curl_share));
|
||||||
(struct Curl_share *)malloc(sizeof(struct Curl_share));
|
|
||||||
if(share) {
|
if(share) {
|
||||||
memset (share, 0, sizeof(struct Curl_share));
|
memset (share, 0, sizeof(struct Curl_share));
|
||||||
share->specifier |= (1<<CURL_LOCK_DATA_SHARE);
|
share->specifier |= (1<<CURL_LOCK_DATA_SHARE);
|
||||||
|
@ -394,7 +394,7 @@ int main(int argc, argv_item_t argv[])
|
|||||||
|
|
||||||
for (i = 0; i < MAX; i++) {
|
for (i = 0; i < MAX; i++) {
|
||||||
struct timeval key;
|
struct timeval key;
|
||||||
ptrs[i] = t = (struct Curl_tree *)malloc(sizeof(struct Curl_tree));
|
ptrs[i] = t = malloc(sizeof(struct Curl_tree));
|
||||||
|
|
||||||
key.tv_sec = 0;
|
key.tv_sec = 0;
|
||||||
#ifdef TEST2
|
#ifdef TEST2
|
||||||
|
12
lib/ssh.c
12
lib/ssh.c
@ -379,7 +379,7 @@ static CURLcode ssh_getworkingpath(struct connectdata *conn,
|
|||||||
|
|
||||||
/* Check for /~/ , indicating relative to the user's home directory */
|
/* Check for /~/ , indicating relative to the user's home directory */
|
||||||
if(conn->protocol & PROT_SCP) {
|
if(conn->protocol & PROT_SCP) {
|
||||||
real_path = (char *)malloc(working_path_len+1);
|
real_path = malloc(working_path_len+1);
|
||||||
if(real_path == NULL) {
|
if(real_path == NULL) {
|
||||||
free(working_path);
|
free(working_path);
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
@ -393,7 +393,7 @@ static CURLcode ssh_getworkingpath(struct connectdata *conn,
|
|||||||
else if(conn->protocol & PROT_SFTP) {
|
else if(conn->protocol & PROT_SFTP) {
|
||||||
if((working_path_len > 1) && (working_path[1] == '~')) {
|
if((working_path_len > 1) && (working_path[1] == '~')) {
|
||||||
size_t homelen = strlen(homedir);
|
size_t homelen = strlen(homedir);
|
||||||
real_path = (char *)malloc(homelen + working_path_len + 1);
|
real_path = malloc(homelen + working_path_len + 1);
|
||||||
if(real_path == NULL) {
|
if(real_path == NULL) {
|
||||||
free(working_path);
|
free(working_path);
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
@ -409,7 +409,7 @@ static CURLcode ssh_getworkingpath(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
real_path = (char *)malloc(working_path_len+1);
|
real_path = malloc(working_path_len+1);
|
||||||
if(real_path == NULL) {
|
if(real_path == NULL) {
|
||||||
free(working_path);
|
free(working_path);
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
@ -1403,12 +1403,12 @@ static CURLcode ssh_statemach_act(struct connectdata *conn)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((sshc->readdir_filename = (char *)malloc(PATH_MAX+1)) == NULL) {
|
if((sshc->readdir_filename = malloc(PATH_MAX+1)) == NULL) {
|
||||||
state(conn, SSH_SFTP_CLOSE);
|
state(conn, SSH_SFTP_CLOSE);
|
||||||
sshc->actualcode = CURLE_OUT_OF_MEMORY;
|
sshc->actualcode = CURLE_OUT_OF_MEMORY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if((sshc->readdir_longentry = (char *)malloc(PATH_MAX+1)) == NULL) {
|
if((sshc->readdir_longentry = malloc(PATH_MAX+1)) == NULL) {
|
||||||
Curl_safefree(sshc->readdir_filename);
|
Curl_safefree(sshc->readdir_filename);
|
||||||
sshc->readdir_filename = NULL;
|
sshc->readdir_filename = NULL;
|
||||||
state(conn, SSH_SFTP_CLOSE);
|
state(conn, SSH_SFTP_CLOSE);
|
||||||
@ -1477,7 +1477,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn)
|
|||||||
if((sshc->readdir_attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) &&
|
if((sshc->readdir_attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) &&
|
||||||
((sshc->readdir_attrs.permissions & LIBSSH2_SFTP_S_IFMT) ==
|
((sshc->readdir_attrs.permissions & LIBSSH2_SFTP_S_IFMT) ==
|
||||||
LIBSSH2_SFTP_S_IFLNK)) {
|
LIBSSH2_SFTP_S_IFLNK)) {
|
||||||
sshc->readdir_linkPath = (char *)malloc(PATH_MAX + 1);
|
sshc->readdir_linkPath = malloc(PATH_MAX + 1);
|
||||||
if(sshc->readdir_linkPath == NULL) {
|
if(sshc->readdir_linkPath == NULL) {
|
||||||
Curl_safefree(sshc->readdir_filename);
|
Curl_safefree(sshc->readdir_filename);
|
||||||
sshc->readdir_filename = NULL;
|
sshc->readdir_filename = NULL;
|
||||||
|
@ -38,7 +38,7 @@ char *curlx_strdup(const char *str)
|
|||||||
if(len >= ((size_t)-1) / sizeof(char))
|
if(len >= ((size_t)-1) / sizeof(char))
|
||||||
return (char *)NULL;
|
return (char *)NULL;
|
||||||
|
|
||||||
newstr = (char *) malloc((len+1)*sizeof(char));
|
newstr = malloc((len+1)*sizeof(char));
|
||||||
if(!newstr)
|
if(!newstr)
|
||||||
return (char *)NULL;
|
return (char *)NULL;
|
||||||
|
|
||||||
|
@ -2136,7 +2136,7 @@ static char *concat_url(const char *base, const char *relurl)
|
|||||||
|
|
||||||
urllen = strlen(url_clone);
|
urllen = strlen(url_clone);
|
||||||
|
|
||||||
newest=(char *)malloc( urllen + 1 + /* possible slash */
|
newest = malloc( urllen + 1 + /* possible slash */
|
||||||
newlen + 1 /* zero byte */);
|
newlen + 1 /* zero byte */);
|
||||||
|
|
||||||
if(!newest) {
|
if(!newest) {
|
||||||
|
@ -675,7 +675,7 @@ CURLcode Curl_open(struct SessionHandle **curl)
|
|||||||
|
|
||||||
/* We do some initial setup here, all those fields that can't be just 0 */
|
/* We do some initial setup here, all those fields that can't be just 0 */
|
||||||
|
|
||||||
data->state.headerbuff=(char*)malloc(HEADERSIZE);
|
data->state.headerbuff = malloc(HEADERSIZE);
|
||||||
if(!data->state.headerbuff) {
|
if(!data->state.headerbuff) {
|
||||||
DEBUGF(fprintf(stderr, "Error: malloc of headerbuff failed\n"));
|
DEBUGF(fprintf(stderr, "Error: malloc of headerbuff failed\n"));
|
||||||
res = CURLE_OUT_OF_MEMORY;
|
res = CURLE_OUT_OF_MEMORY;
|
||||||
@ -4154,12 +4154,12 @@ static CURLcode create_conn(struct SessionHandle *data,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Curl_safefree(data->state.pathbuffer);
|
Curl_safefree(data->state.pathbuffer);
|
||||||
data->state.pathbuffer=(char *)malloc(urllen+2);
|
data->state.pathbuffer = malloc(urllen+2);
|
||||||
if(NULL == data->state.pathbuffer)
|
if(NULL == data->state.pathbuffer)
|
||||||
return CURLE_OUT_OF_MEMORY; /* really bad error */
|
return CURLE_OUT_OF_MEMORY; /* really bad error */
|
||||||
data->state.path = data->state.pathbuffer;
|
data->state.path = data->state.pathbuffer;
|
||||||
|
|
||||||
conn->host.rawalloc=(char *)malloc(urllen+2);
|
conn->host.rawalloc = malloc(urllen+2);
|
||||||
if(NULL == conn->host.rawalloc)
|
if(NULL == conn->host.rawalloc)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
@ -727,7 +727,7 @@ curl_formadd_ccsid(struct curl_httppost * * httppost,
|
|||||||
/* Allocate the local curl_forms array. */
|
/* Allocate the local curl_forms array. */
|
||||||
|
|
||||||
lformlen = ALLOC_GRANULE;
|
lformlen = ALLOC_GRANULE;
|
||||||
lforms = (struct curl_forms *) malloc(lformlen * sizeof * lforms);
|
lforms = malloc(lformlen * sizeof(struct curl_forms));
|
||||||
|
|
||||||
if (!lforms)
|
if (!lforms)
|
||||||
return CURL_FORMADD_MEMORY;
|
return CURL_FORMADD_MEMORY;
|
||||||
|
15
src/main.c
15
src/main.c
@ -932,7 +932,7 @@ AddMultiFiles (const char *file_name,
|
|||||||
struct multi_files *multi;
|
struct multi_files *multi;
|
||||||
struct multi_files *multi_type = NULL;
|
struct multi_files *multi_type = NULL;
|
||||||
struct multi_files *multi_name = NULL;
|
struct multi_files *multi_name = NULL;
|
||||||
multi = (struct multi_files *)malloc(sizeof(struct multi_files));
|
multi = malloc(sizeof(struct multi_files));
|
||||||
if (multi) {
|
if (multi) {
|
||||||
memset(multi, 0, sizeof(struct multi_files));
|
memset(multi, 0, sizeof(struct multi_files));
|
||||||
multi->form.option = CURLFORM_FILE;
|
multi->form.option = CURLFORM_FILE;
|
||||||
@ -945,7 +945,7 @@ AddMultiFiles (const char *file_name,
|
|||||||
*multi_start = multi;
|
*multi_start = multi;
|
||||||
|
|
||||||
if (type_name) {
|
if (type_name) {
|
||||||
multi_type = (struct multi_files *)malloc(sizeof(struct multi_files));
|
multi_type = malloc(sizeof(struct multi_files));
|
||||||
if (multi_type) {
|
if (multi_type) {
|
||||||
memset(multi_type, 0, sizeof(struct multi_files));
|
memset(multi_type, 0, sizeof(struct multi_files));
|
||||||
multi_type->form.option = CURLFORM_CONTENTTYPE;
|
multi_type->form.option = CURLFORM_CONTENTTYPE;
|
||||||
@ -960,7 +960,7 @@ AddMultiFiles (const char *file_name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (show_filename) {
|
if (show_filename) {
|
||||||
multi_name = (struct multi_files *)malloc(sizeof(struct multi_files));
|
multi_name = malloc(sizeof(struct multi_files));
|
||||||
if (multi_name) {
|
if (multi_name) {
|
||||||
memset(multi_name, 0, sizeof(struct multi_files));
|
memset(multi_name, 0, sizeof(struct multi_files));
|
||||||
multi_name->form.option = CURLFORM_FILENAME;
|
multi_name->form.option = CURLFORM_FILENAME;
|
||||||
@ -1192,8 +1192,7 @@ static int formparse(struct Configurable *config,
|
|||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
forms =
|
forms = malloc((count+1)*sizeof(struct curl_forms));
|
||||||
(struct curl_forms *)malloc((count+1)*sizeof(struct curl_forms));
|
|
||||||
if (!forms)
|
if (!forms)
|
||||||
{
|
{
|
||||||
fprintf(config->errors, "Error building form post!\n");
|
fprintf(config->errors, "Error building form post!\n");
|
||||||
@ -3726,7 +3725,7 @@ static void FindWin32CACert(struct Configurable *config,
|
|||||||
if(curlinfo->features & CURL_VERSION_SSL) {
|
if(curlinfo->features & CURL_VERSION_SSL) {
|
||||||
DWORD buflen;
|
DWORD buflen;
|
||||||
char *ptr = NULL;
|
char *ptr = NULL;
|
||||||
char *retval = (char *) malloc(sizeof (TCHAR) * (MAX_PATH + 1));
|
char *retval = malloc(sizeof (TCHAR) * (MAX_PATH + 1));
|
||||||
if (!retval)
|
if (!retval)
|
||||||
return;
|
return;
|
||||||
retval[0] = '\0';
|
retval[0] = '\0';
|
||||||
@ -4370,7 +4369,7 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
filep = curl_easy_escape(curl, filep, 0 /* use strlen */);
|
filep = curl_easy_escape(curl, filep, 0 /* use strlen */);
|
||||||
|
|
||||||
if(filep) {
|
if(filep) {
|
||||||
char *urlbuffer=(char *)malloc(strlen(url) + strlen(filep) + 3);
|
char *urlbuffer = malloc(strlen(url) + strlen(filep) + 3);
|
||||||
if(!urlbuffer) {
|
if(!urlbuffer) {
|
||||||
helpf(config->errors, "out of memory\n");
|
helpf(config->errors, "out of memory\n");
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
@ -4471,7 +4470,7 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
/*
|
/*
|
||||||
* Then append ? followed by the get fields to the url.
|
* Then append ? followed by the get fields to the url.
|
||||||
*/
|
*/
|
||||||
urlbuffer=(char *)malloc(strlen(url) + strlen(httpgetfields) + 3);
|
urlbuffer = malloc(strlen(url) + strlen(httpgetfields) + 3);
|
||||||
if(!urlbuffer) {
|
if(!urlbuffer) {
|
||||||
helpf(config->errors, "out of memory\n");
|
helpf(config->errors, "out of memory\n");
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
@ -70,6 +70,7 @@ static GlobCode glob_set(URLGlob *glob, char *pattern,
|
|||||||
pat->type = UPTSet;
|
pat->type = UPTSet;
|
||||||
pat->content.Set.size = 0;
|
pat->content.Set.size = 0;
|
||||||
pat->content.Set.ptr_s = 0;
|
pat->content.Set.ptr_s = 0;
|
||||||
|
/* FIXME: Here's a nasty zero size malloc */
|
||||||
pat->content.Set.elements = (char**)malloc(0);
|
pat->content.Set.elements = (char**)malloc(0);
|
||||||
++glob->size;
|
++glob->size;
|
||||||
|
|
||||||
@ -335,7 +336,7 @@ int glob_url(URLGlob** glob, char* url, int *urlnum, FILE *error)
|
|||||||
*/
|
*/
|
||||||
URLGlob *glob_expand;
|
URLGlob *glob_expand;
|
||||||
int amount;
|
int amount;
|
||||||
char *glob_buffer=(char *)malloc(strlen(url)+1);
|
char *glob_buffer = malloc(strlen(url)+1);
|
||||||
|
|
||||||
*glob = NULL;
|
*glob = NULL;
|
||||||
if(NULL == glob_buffer)
|
if(NULL == glob_buffer)
|
||||||
|
@ -122,7 +122,7 @@ const char *spitout(FILE *stream,
|
|||||||
STATE_ILLEGAL
|
STATE_ILLEGAL
|
||||||
} state = STATE_OUTSIDE;
|
} state = STATE_OUTSIDE;
|
||||||
|
|
||||||
string = (char *)malloc(stralloc);
|
string = malloc(stralloc);
|
||||||
if(!string)
|
if(!string)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user