mirror of
https://github.com/curl/curl.git
synced 2026-08-25 22:23:53 +03:00
cppcheck: fix warnings
- Get rid of variable that was generating false positive warning (unitialized) - Fix issues in tests - Reduce scope of several variables all over etc Closes #2631
This commit is contained in:
parent
38203f1585
commit
c45360d463
61 changed files with 213 additions and 273 deletions
|
|
@ -49,13 +49,12 @@ static size_t decodeQuantum(unsigned char *dest, const char *src)
|
|||
unsigned long i, x = 0;
|
||||
|
||||
for(i = 0, s = src; i < 4; i++, s++) {
|
||||
unsigned long v = 0;
|
||||
|
||||
if(*s == '=') {
|
||||
x = (x << 6);
|
||||
padding++;
|
||||
}
|
||||
else {
|
||||
unsigned long v = 0;
|
||||
p = base64;
|
||||
|
||||
while(*p && (*p != *s)) {
|
||||
|
|
|
|||
|
|
@ -1237,8 +1237,6 @@ static int conn_is_conn(struct connectdata *conn, void *param)
|
|||
curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
|
||||
struct connectdata **connp)
|
||||
{
|
||||
curl_socket_t sockfd;
|
||||
|
||||
DEBUGASSERT(data);
|
||||
|
||||
/* this works for an easy handle:
|
||||
|
|
@ -1264,12 +1262,10 @@ curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
|
|||
if(connp)
|
||||
/* only store this if the caller cares for it */
|
||||
*connp = c;
|
||||
sockfd = c->sock[FIRSTSOCKET];
|
||||
return c->sock[FIRSTSOCKET];
|
||||
}
|
||||
else
|
||||
return CURL_SOCKET_BAD;
|
||||
|
||||
return sockfd;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -163,7 +163,6 @@ static CURLcode inflate_stream(struct connectdata *conn,
|
|||
z_stream *z = &zp->z; /* zlib state structure */
|
||||
uInt nread = z->avail_in;
|
||||
Bytef *orig_in = z->next_in;
|
||||
int status; /* zlib status */
|
||||
bool done = FALSE;
|
||||
CURLcode result = CURLE_OK; /* Curl_client_write status */
|
||||
char *decomp; /* Put the decompressed data here. */
|
||||
|
|
@ -184,6 +183,7 @@ static CURLcode inflate_stream(struct connectdata *conn,
|
|||
/* because the buffer size is fixed, iteratively decompress and transfer to
|
||||
the client via downstream_write function. */
|
||||
while(!done) {
|
||||
int status; /* zlib status */
|
||||
done = TRUE;
|
||||
|
||||
/* (re)set buffer for decompressed output for every iteration */
|
||||
|
|
@ -761,7 +761,6 @@ char *Curl_all_content_encodings(void)
|
|||
const content_encoding * const *cep;
|
||||
const content_encoding *ce;
|
||||
char *ace;
|
||||
char *p;
|
||||
|
||||
for(cep = encodings; *cep; cep++) {
|
||||
ce = *cep;
|
||||
|
|
@ -774,7 +773,7 @@ char *Curl_all_content_encodings(void)
|
|||
|
||||
ace = malloc(len);
|
||||
if(ace) {
|
||||
p = ace;
|
||||
char *p = ace;
|
||||
for(cep = encodings; *cep; cep++) {
|
||||
ce = *cep;
|
||||
if(!strcasecompare(ce->name, CONTENT_ENCODING_DEFAULT)) {
|
||||
|
|
@ -921,10 +920,9 @@ void Curl_unencode_cleanup(struct connectdata *conn)
|
|||
static const content_encoding *find_encoding(const char *name, size_t len)
|
||||
{
|
||||
const content_encoding * const *cep;
|
||||
const content_encoding *ce;
|
||||
|
||||
for(cep = encodings; *cep; cep++) {
|
||||
ce = *cep;
|
||||
const content_encoding *ce = *cep;
|
||||
if((strncasecompare(name, ce->name, len) && !ce->name[len]) ||
|
||||
(ce->alias && strncasecompare(name, ce->alias, len) && !ce->alias[len]))
|
||||
return ce;
|
||||
|
|
|
|||
|
|
@ -376,13 +376,13 @@ static void strstore(char **str, const char *newstr)
|
|||
*/
|
||||
static void remove_expired(struct CookieInfo *cookies)
|
||||
{
|
||||
struct Cookie *co, *nx, *pv;
|
||||
struct Cookie *co, *nx;
|
||||
curl_off_t now = (curl_off_t)time(NULL);
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < COOKIE_HASH_SIZE; i++) {
|
||||
struct Cookie *pv = NULL;
|
||||
co = cookies->cookies[i];
|
||||
pv = NULL;
|
||||
while(co) {
|
||||
nx = co->next;
|
||||
if(co->expires && co->expires < now) {
|
||||
|
|
@ -1385,9 +1385,8 @@ void Curl_cookie_clearsess(struct CookieInfo *cookies)
|
|||
****************************************************************************/
|
||||
void Curl_cookie_cleanup(struct CookieInfo *c)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if(c) {
|
||||
unsigned int i;
|
||||
free(c->filename);
|
||||
for(i = 0; i < COOKIE_HASH_SIZE; i++)
|
||||
Curl_cookie_freelist(c->cookies[i]);
|
||||
|
|
|
|||
|
|
@ -146,7 +146,6 @@ CURLcode Curl_sasl_parse_url_auth_option(struct SASL *sasl,
|
|||
const char *value, size_t len)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
unsigned int mechbit;
|
||||
size_t mechlen;
|
||||
|
||||
if(!len)
|
||||
|
|
@ -160,7 +159,7 @@ CURLcode Curl_sasl_parse_url_auth_option(struct SASL *sasl,
|
|||
if(!strncmp(value, "*", len))
|
||||
sasl->prefmech = SASL_AUTH_DEFAULT;
|
||||
else {
|
||||
mechbit = Curl_sasl_decode_mech(value, len, &mechlen);
|
||||
unsigned int mechbit = Curl_sasl_decode_mech(value, len, &mechlen);
|
||||
if(mechbit && mechlen == len)
|
||||
sasl->prefmech |= mechbit;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -95,10 +95,7 @@ static char *unescape_word(struct Curl_easy *data, const char *inputbuff)
|
|||
{
|
||||
char *newp = NULL;
|
||||
char *dictp;
|
||||
char *ptr;
|
||||
size_t len;
|
||||
char ch;
|
||||
int olen = 0;
|
||||
|
||||
CURLcode result = Curl_urldecode(data, inputbuff, 0, &newp, &len, FALSE);
|
||||
if(!newp || result)
|
||||
|
|
@ -106,6 +103,9 @@ static char *unescape_word(struct Curl_easy *data, const char *inputbuff)
|
|||
|
||||
dictp = malloc(((size_t)len)*2 + 1); /* add one for terminating zero */
|
||||
if(dictp) {
|
||||
char *ptr;
|
||||
char ch;
|
||||
int olen = 0;
|
||||
/* According to RFC2229 section 2.2, these letters need to be escaped with
|
||||
\[letter] */
|
||||
for(ptr = newp;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
|
|||
size_t alloc;
|
||||
char *ns;
|
||||
char *testing_ptr = NULL;
|
||||
unsigned char in; /* we need to treat the characters unsigned */
|
||||
size_t newlen;
|
||||
size_t strindex = 0;
|
||||
size_t length;
|
||||
|
|
@ -100,7 +99,7 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
|
|||
|
||||
length = alloc-1;
|
||||
while(length--) {
|
||||
in = *string;
|
||||
unsigned char in = *string; /* we need to treat the characters unsigned */
|
||||
|
||||
if(Curl_isunreserved(in))
|
||||
/* just copy this */
|
||||
|
|
@ -150,7 +149,6 @@ CURLcode Curl_urldecode(struct Curl_easy *data,
|
|||
{
|
||||
size_t alloc = (length?length:strlen(string)) + 1;
|
||||
char *ns = malloc(alloc);
|
||||
unsigned char in;
|
||||
size_t strindex = 0;
|
||||
unsigned long hex;
|
||||
CURLcode result;
|
||||
|
|
@ -159,7 +157,7 @@ CURLcode Curl_urldecode(struct Curl_easy *data,
|
|||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
while(--alloc > 0) {
|
||||
in = *string;
|
||||
unsigned char in = *string;
|
||||
if(('%' == in) && (alloc > 2) &&
|
||||
ISXDIGIT(string[1]) && ISXDIGIT(string[2])) {
|
||||
/* this is two hexadecimal digits following a '%' */
|
||||
|
|
|
|||
|
|
@ -256,8 +256,6 @@ static CURLcode file_upload(struct connectdata *conn)
|
|||
CURLcode result = CURLE_OK;
|
||||
struct Curl_easy *data = conn->data;
|
||||
char *buf = data->state.buffer;
|
||||
size_t nread;
|
||||
size_t nwrite;
|
||||
curl_off_t bytecount = 0;
|
||||
struct_stat file_stat;
|
||||
const char *buf2;
|
||||
|
|
@ -306,6 +304,8 @@ static CURLcode file_upload(struct connectdata *conn)
|
|||
}
|
||||
|
||||
while(!result) {
|
||||
size_t nread;
|
||||
size_t nwrite;
|
||||
int readcount;
|
||||
result = Curl_fillreadbuffer(conn, (int)data->set.buffer_size, &readcount);
|
||||
if(result)
|
||||
|
|
@ -378,7 +378,6 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
|
|||
curl_off_t expected_size = 0;
|
||||
bool size_known;
|
||||
bool fstated = FALSE;
|
||||
ssize_t nread;
|
||||
struct Curl_easy *data = conn->data;
|
||||
char *buf = data->state.buffer;
|
||||
curl_off_t bytecount = 0;
|
||||
|
|
@ -502,6 +501,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
|
|||
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
|
||||
|
||||
while(!result) {
|
||||
ssize_t nread;
|
||||
/* Don't fill a whole buffer if we want less than all data */
|
||||
size_t bytestoread;
|
||||
|
||||
|
|
|
|||
|
|
@ -812,7 +812,6 @@ CURLcode Curl_getformdata(struct Curl_easy *data,
|
|||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
curl_mime *form = NULL;
|
||||
curl_mime *multipart;
|
||||
curl_mimepart *part;
|
||||
struct curl_httppost *file;
|
||||
|
||||
|
|
@ -831,7 +830,7 @@ CURLcode Curl_getformdata(struct Curl_easy *data,
|
|||
/* Process each top part. */
|
||||
for(; !result && post; post = post->next) {
|
||||
/* If we have more than a file here, create a mime subpart and fill it. */
|
||||
multipart = form;
|
||||
curl_mime *multipart = form;
|
||||
if(post->more) {
|
||||
part = curl_mime_addpart(form);
|
||||
if(!part)
|
||||
|
|
|
|||
13
lib/ftp.c
13
lib/ftp.c
|
|
@ -239,8 +239,8 @@ static void close_secondarysocket(struct connectdata *conn)
|
|||
|
||||
static void freedirs(struct ftp_conn *ftpc)
|
||||
{
|
||||
int i;
|
||||
if(ftpc->dirs) {
|
||||
int i;
|
||||
for(i = 0; i < ftpc->dirdepth; i++) {
|
||||
free(ftpc->dirs[i]);
|
||||
ftpc->dirs[i] = NULL;
|
||||
|
|
@ -637,8 +637,6 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
|
|||
* line in a response or continue reading. */
|
||||
|
||||
curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
|
||||
time_t timeout; /* timeout in milliseconds */
|
||||
time_t interval_ms;
|
||||
struct Curl_easy *data = conn->data;
|
||||
CURLcode result = CURLE_OK;
|
||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||
|
|
@ -657,7 +655,8 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
|
|||
|
||||
while(!*ftpcode && !result) {
|
||||
/* check and reset timeout value every lap */
|
||||
timeout = Curl_pp_state_timeout(pp);
|
||||
time_t timeout = Curl_pp_state_timeout(pp); /* timeout in milliseconds */
|
||||
time_t interval_ms;
|
||||
|
||||
if(timeout <= 0) {
|
||||
failf(data, "FTP response timeout");
|
||||
|
|
@ -1589,7 +1588,6 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
|
|||
struct FTP *ftp = conn->data->req.protop;
|
||||
struct Curl_easy *data = conn->data;
|
||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||
int seekerr = CURL_SEEKFUNC_OK;
|
||||
|
||||
if((data->state.resume_from && !sizechecked) ||
|
||||
((data->state.resume_from > 0) && sizechecked)) {
|
||||
|
|
@ -1605,6 +1603,7 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
|
|||
/* 3. pass file-size number of bytes in the source file */
|
||||
/* 4. lower the infilesize counter */
|
||||
/* => transfer as usual */
|
||||
int seekerr = CURL_SEEKFUNC_OK;
|
||||
|
||||
if(data->state.resume_from < 0) {
|
||||
/* Got no given size to start from, figure it out */
|
||||
|
|
@ -2782,7 +2781,6 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
|
|||
char *ptr = &data->state.buffer[4]; /* start on the first letter */
|
||||
const size_t buf_size = data->set.buffer_size;
|
||||
char *dir;
|
||||
char *store;
|
||||
bool entry_extracted = FALSE;
|
||||
|
||||
dir = malloc(nread + 1);
|
||||
|
|
@ -2805,6 +2803,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
|
|||
|
||||
if('\"' == *ptr) {
|
||||
/* it started good */
|
||||
char *store;
|
||||
ptr++;
|
||||
for(store = dir; *ptr;) {
|
||||
if('\"' == *ptr) {
|
||||
|
|
@ -4384,7 +4383,6 @@ static CURLcode ftp_setup_connection(struct connectdata *conn)
|
|||
{
|
||||
struct Curl_easy *data = conn->data;
|
||||
char *type;
|
||||
char command;
|
||||
struct FTP *ftp;
|
||||
|
||||
conn->data->req.protop = ftp = malloc(sizeof(struct FTP));
|
||||
|
|
@ -4402,6 +4400,7 @@ static CURLcode ftp_setup_connection(struct connectdata *conn)
|
|||
type = strstr(conn->host.rawalloc, ";type=");
|
||||
|
||||
if(type) {
|
||||
char command;
|
||||
*type = 0; /* it was in the middle of the hostname */
|
||||
command = Curl_raw_toupper(type[6]);
|
||||
conn->bits.type_set = TRUE;
|
||||
|
|
|
|||
11
lib/hash.c
11
lib/hash.c
|
|
@ -60,8 +60,6 @@ Curl_hash_init(struct curl_hash *h,
|
|||
comp_function comparator,
|
||||
curl_hash_dtor dtor)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(!slots || !hfunc || !comparator ||!dtor) {
|
||||
return 1; /* failure */
|
||||
}
|
||||
|
|
@ -74,6 +72,7 @@ Curl_hash_init(struct curl_hash *h,
|
|||
|
||||
h->table = malloc(slots * sizeof(struct curl_llist));
|
||||
if(h->table) {
|
||||
int i;
|
||||
for(i = 0; i < slots; ++i)
|
||||
Curl_llist_init(&h->table[i], (curl_llist_dtor) hash_element_dtor);
|
||||
return 0; /* fine */
|
||||
|
|
@ -140,11 +139,10 @@ Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p)
|
|||
int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len)
|
||||
{
|
||||
struct curl_llist_element *le;
|
||||
struct curl_hash_element *he;
|
||||
struct curl_llist *l = FETCH_LIST(h, key, key_len);
|
||||
|
||||
for(le = l->head; le; le = le->next) {
|
||||
he = le->ptr;
|
||||
struct curl_hash_element *he = le->ptr;
|
||||
if(h->comp_func(he->key, he->key_len, key, key_len)) {
|
||||
Curl_llist_remove(l, le, (void *) h);
|
||||
--h->size;
|
||||
|
|
@ -162,13 +160,12 @@ void *
|
|||
Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len)
|
||||
{
|
||||
struct curl_llist_element *le;
|
||||
struct curl_hash_element *he;
|
||||
struct curl_llist *l;
|
||||
|
||||
if(h) {
|
||||
l = FETCH_LIST(h, key, key_len);
|
||||
for(le = l->head; le; le = le->next) {
|
||||
he = le->ptr;
|
||||
struct curl_hash_element *he = le->ptr;
|
||||
if(h->comp_func(he->key, he->key_len, key, key_len)) {
|
||||
return he->ptr;
|
||||
}
|
||||
|
|
@ -291,7 +288,6 @@ void Curl_hash_start_iterate(struct curl_hash *hash,
|
|||
struct curl_hash_element *
|
||||
Curl_hash_next_element(struct curl_hash_iterator *iter)
|
||||
{
|
||||
int i;
|
||||
struct curl_hash *h = iter->hash;
|
||||
|
||||
/* Get the next element in the current list, if any */
|
||||
|
|
@ -300,6 +296,7 @@ Curl_hash_next_element(struct curl_hash_iterator *iter)
|
|||
|
||||
/* If we have reached the end of the list, find the next one */
|
||||
if(!iter->current_element) {
|
||||
int i;
|
||||
for(i = iter->slot_index; i < h->slots; i++) {
|
||||
if(h->table[i].head) {
|
||||
iter->current_element = h->table[i].head;
|
||||
|
|
|
|||
10
lib/http.c
10
lib/http.c
|
|
@ -1276,7 +1276,6 @@ CURLcode Curl_add_bufferf(Curl_send_buffer *in, const char *fmt, ...)
|
|||
CURLcode Curl_add_buffer(Curl_send_buffer *in, const void *inptr, size_t size)
|
||||
{
|
||||
char *new_rb;
|
||||
size_t new_size;
|
||||
|
||||
if(~size < in->size_used) {
|
||||
/* If resulting used size of send buffer would wrap size_t, cleanup
|
||||
|
|
@ -1289,10 +1288,10 @@ CURLcode Curl_add_buffer(Curl_send_buffer *in, const void *inptr, size_t size)
|
|||
|
||||
if(!in->buffer ||
|
||||
((in->size_used + size) > (in->size_max - 1))) {
|
||||
|
||||
/* If current buffer size isn't enough to hold the result, use a
|
||||
buffer size that doubles the required size. If this new size
|
||||
would wrap size_t, then just use the largest possible one */
|
||||
size_t new_size;
|
||||
|
||||
if((size > (size_t)-1 / 2) || (in->size_used > (size_t)-1 / 2) ||
|
||||
(~(size * 2) < (in->size_used * 2)))
|
||||
|
|
@ -1627,7 +1626,6 @@ static CURLcode expect100(struct Curl_easy *data,
|
|||
Curl_send_buffer *req_buffer)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
const char *ptr;
|
||||
data->state.expect100header = FALSE; /* default to false unless it is set
|
||||
to TRUE below */
|
||||
if(use_http_1_1plus(data, conn) &&
|
||||
|
|
@ -1635,7 +1633,7 @@ static CURLcode expect100(struct Curl_easy *data,
|
|||
/* if not doing HTTP 1.0 or version 2, or disabled explicitly, we add an
|
||||
Expect: 100-continue to the headers which actually speeds up post
|
||||
operations (as there is one packet coming back from the web server) */
|
||||
ptr = Curl_checkheaders(conn, "Expect");
|
||||
const char *ptr = Curl_checkheaders(conn, "Expect");
|
||||
if(ptr) {
|
||||
data->state.expect100header =
|
||||
Curl_compareheader(ptr, "Expect:", "100-continue");
|
||||
|
|
@ -1872,7 +1870,6 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||
const char *httpstring;
|
||||
Curl_send_buffer *req_buffer;
|
||||
curl_off_t postsize = 0; /* curl_off_t to handle large file sizes */
|
||||
int seekerr = CURL_SEEKFUNC_CANTSEEK;
|
||||
|
||||
/* Always consider the DO phase done after this function call, even if there
|
||||
may be parts of the request that is not yet sent, since we can deal with
|
||||
|
|
@ -2141,7 +2138,6 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||
else {
|
||||
/* If the host begins with '[', we start searching for the port after
|
||||
the bracket has been closed */
|
||||
int startsearch = 0;
|
||||
if(*cookiehost == '[') {
|
||||
char *closingbracket;
|
||||
/* since the 'cookiehost' is an allocated memory area that will be
|
||||
|
|
@ -2152,6 +2148,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||
*closingbracket = 0;
|
||||
}
|
||||
else {
|
||||
int startsearch = 0;
|
||||
char *colon = strchr(cookiehost + startsearch, ':');
|
||||
if(colon)
|
||||
*colon = 0; /* The host must not include an embedded port number */
|
||||
|
|
@ -2297,6 +2294,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||
|
||||
/* Now, let's read off the proper amount of bytes from the
|
||||
input. */
|
||||
int seekerr = CURL_SEEKFUNC_CANTSEEK;
|
||||
if(conn->seek_func) {
|
||||
Curl_set_in_callback(data, true);
|
||||
seekerr = conn->seek_func(conn->seek_client, data->state.resume_from,
|
||||
|
|
|
|||
|
|
@ -188,7 +188,6 @@ static CURLcode CONNECT(struct connectdata *conn,
|
|||
struct SingleRequest *k = &data->req;
|
||||
CURLcode result;
|
||||
curl_socket_t tunnelsocket = conn->sock[sockindex];
|
||||
timediff_t check;
|
||||
struct http_connect_state *s = conn->connect_state;
|
||||
|
||||
#define SELECT_OK 0
|
||||
|
|
@ -201,6 +200,7 @@ static CURLcode CONNECT(struct connectdata *conn,
|
|||
conn->bits.proxy_connect_closed = FALSE;
|
||||
|
||||
do {
|
||||
timediff_t check;
|
||||
if(TUNNEL_INIT == s->tunnel_state) {
|
||||
/* BEGIN CONNECT PHASE */
|
||||
char *host_port;
|
||||
|
|
|
|||
|
|
@ -609,7 +609,6 @@ static CURLcode imap_perform_list(struct connectdata *conn)
|
|||
CURLcode result = CURLE_OK;
|
||||
struct Curl_easy *data = conn->data;
|
||||
struct IMAP *imap = data->req.protop;
|
||||
char *mailbox;
|
||||
|
||||
if(imap->custom)
|
||||
/* Send the custom request */
|
||||
|
|
@ -617,7 +616,8 @@ static CURLcode imap_perform_list(struct connectdata *conn)
|
|||
imap->custom_params ? imap->custom_params : "");
|
||||
else {
|
||||
/* Make sure the mailbox is in the correct atom format if necessary */
|
||||
mailbox = imap->mailbox ? imap_atom(imap->mailbox, true) : strdup("");
|
||||
char *mailbox = imap->mailbox ? imap_atom(imap->mailbox, true)
|
||||
: strdup("");
|
||||
if(!mailbox)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -854,7 +854,6 @@ static CURLcode imap_state_capability_resp(struct connectdata *conn,
|
|||
struct Curl_easy *data = conn->data;
|
||||
struct imap_conn *imapc = &conn->proto.imapc;
|
||||
const char *line = data->state.buffer;
|
||||
size_t wordlen;
|
||||
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
|
|
@ -864,6 +863,7 @@ static CURLcode imap_state_capability_resp(struct connectdata *conn,
|
|||
|
||||
/* Loop through the data line */
|
||||
for(;;) {
|
||||
size_t wordlen;
|
||||
while(*line &&
|
||||
(*line == ' ' || *line == '\t' ||
|
||||
*line == '\r' || *line == '\n')) {
|
||||
|
|
@ -1046,12 +1046,12 @@ static CURLcode imap_state_select_resp(struct connectdata *conn, int imapcode,
|
|||
struct IMAP *imap = conn->data->req.protop;
|
||||
struct imap_conn *imapc = &conn->proto.imapc;
|
||||
const char *line = data->state.buffer;
|
||||
char tmp[20];
|
||||
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
if(imapcode == '*') {
|
||||
/* See if this is an UIDVALIDITY response */
|
||||
char tmp[20];
|
||||
if(sscanf(line + 2, "OK [UIDVALIDITY %19[0123456789]]", tmp) == 1) {
|
||||
Curl_safefree(imapc->mailbox_uidvalidity);
|
||||
imapc->mailbox_uidvalidity = strdup(tmp);
|
||||
|
|
|
|||
32
lib/mime.c
32
lib/mime.c
|
|
@ -505,9 +505,6 @@ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
|
|||
mime_encoder_state *st = &part->encstate;
|
||||
char *ptr = buffer;
|
||||
size_t cursize = 0;
|
||||
int i;
|
||||
size_t len;
|
||||
size_t consumed;
|
||||
int softlinebreak;
|
||||
char buf[4];
|
||||
|
||||
|
|
@ -516,9 +513,9 @@ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
|
|||
character constants that can be interpreted as non-ascii on some
|
||||
platforms. Preserve ASCII encoding on output too. */
|
||||
while(st->bufbeg < st->bufend) {
|
||||
len = 1;
|
||||
consumed = 1;
|
||||
i = st->buf[st->bufbeg];
|
||||
size_t len = 1;
|
||||
size_t consumed = 1;
|
||||
int i = st->buf[st->bufbeg];
|
||||
buf[0] = (char) i;
|
||||
buf[1] = aschex[(i >> 4) & 0xF];
|
||||
buf[2] = aschex[i & 0xF];
|
||||
|
|
@ -813,8 +810,6 @@ static size_t readback_part(curl_mimepart *part,
|
|||
char *buffer, size_t bufsize)
|
||||
{
|
||||
size_t cursize = 0;
|
||||
size_t sz;
|
||||
struct curl_slist *hdr;
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
char *convbuf = buffer;
|
||||
#endif
|
||||
|
|
@ -822,8 +817,8 @@ static size_t readback_part(curl_mimepart *part,
|
|||
/* Readback from part. */
|
||||
|
||||
while(bufsize) {
|
||||
sz = 0;
|
||||
hdr = (struct curl_slist *) part->state.ptr;
|
||||
size_t sz = 0;
|
||||
struct curl_slist *hdr = (struct curl_slist *) part->state.ptr;
|
||||
switch(part->state.state) {
|
||||
case MIMESTATE_BEGIN:
|
||||
mimesetstate(&part->state, part->flags & MIME_BODY_ONLY? MIMESTATE_BODY:
|
||||
|
|
@ -918,8 +913,6 @@ static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
|
|||
{
|
||||
curl_mime *mime = (curl_mime *) instream;
|
||||
size_t cursize = 0;
|
||||
size_t sz;
|
||||
curl_mimepart *part;
|
||||
#ifdef CURL_DOES_CONVERSIONS
|
||||
char *convbuf = buffer;
|
||||
#endif
|
||||
|
|
@ -927,8 +920,8 @@ static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
|
|||
(void) size; /* Always 1. */
|
||||
|
||||
while(nitems) {
|
||||
sz = 0;
|
||||
part = mime->state.ptr;
|
||||
size_t sz = 0;
|
||||
curl_mimepart *part = mime->state.ptr;
|
||||
switch(mime->state.state) {
|
||||
case MIMESTATE_BEGIN:
|
||||
case MIMESTATE_BODY:
|
||||
|
|
@ -1044,7 +1037,6 @@ static int mime_subparts_seek(void *instream, curl_off_t offset, int whence)
|
|||
curl_mime *mime = (curl_mime *) instream;
|
||||
curl_mimepart *part;
|
||||
int result = CURL_SEEKFUNC_OK;
|
||||
int res;
|
||||
|
||||
if(whence != SEEK_SET || offset)
|
||||
return CURL_SEEKFUNC_CANTSEEK; /* Only support full rewind. */
|
||||
|
|
@ -1053,7 +1045,7 @@ static int mime_subparts_seek(void *instream, curl_off_t offset, int whence)
|
|||
return CURL_SEEKFUNC_OK; /* Already rewound. */
|
||||
|
||||
for(part = mime->firstpart; part; part = part->nextpart) {
|
||||
res = mime_part_rewind(part);
|
||||
int res = mime_part_rewind(part);
|
||||
if(res != CURL_SEEKFUNC_OK)
|
||||
result = res;
|
||||
}
|
||||
|
|
@ -1349,7 +1341,6 @@ CURLcode curl_mime_data(curl_mimepart *part,
|
|||
CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
char *base;
|
||||
|
||||
if(!part)
|
||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
|
|
@ -1357,6 +1348,7 @@ CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename)
|
|||
cleanup_part_content(part);
|
||||
|
||||
if(filename) {
|
||||
char *base;
|
||||
struct_stat sbuf;
|
||||
|
||||
if(stat(filename, &sbuf) || access(filename, R_OK))
|
||||
|
|
@ -1564,7 +1556,6 @@ static size_t slist_size(struct curl_slist *s,
|
|||
static curl_off_t multipart_size(curl_mime *mime)
|
||||
{
|
||||
curl_off_t size;
|
||||
curl_off_t sz;
|
||||
size_t boundarysize;
|
||||
curl_mimepart *part;
|
||||
|
||||
|
|
@ -1575,7 +1566,7 @@ static curl_off_t multipart_size(curl_mime *mime)
|
|||
size = boundarysize; /* Final boundary - CRLF after headers. */
|
||||
|
||||
for(part = mime->firstpart; part; part = part->nextpart) {
|
||||
sz = Curl_mime_size(part);
|
||||
curl_off_t sz = Curl_mime_size(part);
|
||||
|
||||
if(sz < 0)
|
||||
size = sz;
|
||||
|
|
@ -1643,8 +1634,6 @@ static CURLcode add_content_type(struct curl_slist **slp,
|
|||
|
||||
const char *Curl_mime_contenttype(const char *filename)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
/*
|
||||
* If no content type was specified, we scan through a few well-known
|
||||
* extensions and pick the first we match!
|
||||
|
|
@ -1669,6 +1658,7 @@ const char *Curl_mime_contenttype(const char *filename)
|
|||
if(filename) {
|
||||
size_t len1 = strlen(filename);
|
||||
const char *nameend = filename + len1;
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < sizeof(ctts) / sizeof(ctts[0]); i++) {
|
||||
size_t len2 = strlen(ctts[i].extension);
|
||||
|
|
|
|||
|
|
@ -917,7 +917,6 @@ CURLMcode curl_multi_fdset(struct Curl_multi *multi,
|
|||
struct Curl_easy *data;
|
||||
int this_max_fd = -1;
|
||||
curl_socket_t sockbunch[MAX_SOCKSPEREASYHANDLE];
|
||||
int bitmap;
|
||||
int i;
|
||||
(void)exc_fd_set; /* not used */
|
||||
|
||||
|
|
@ -929,7 +928,7 @@ CURLMcode curl_multi_fdset(struct Curl_multi *multi,
|
|||
|
||||
data = multi->easyp;
|
||||
while(data) {
|
||||
bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE);
|
||||
int bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE);
|
||||
|
||||
for(i = 0; i< MAX_SOCKSPEREASYHANDLE; i++) {
|
||||
curl_socket_t s = CURL_SOCKET_BAD;
|
||||
|
|
@ -2943,7 +2942,6 @@ void Curl_expire(struct Curl_easy *data, time_t milli, expire_id id)
|
|||
{
|
||||
struct Curl_multi *multi = data->multi;
|
||||
struct curltime *nowp = &data->state.expiretime;
|
||||
int rc;
|
||||
struct curltime set;
|
||||
|
||||
/* this is only interesting while there is still an associated multi struct
|
||||
|
|
@ -2974,6 +2972,7 @@ void Curl_expire(struct Curl_easy *data, time_t milli, expire_id id)
|
|||
Compare if the new time is earlier, and only remove-old/add-new if it
|
||||
is. */
|
||||
timediff_t diff = Curl_timediff(set, *nowp);
|
||||
int rc;
|
||||
|
||||
if(diff > 0) {
|
||||
/* The current splay tree entry is sooner than this new expiry time.
|
||||
|
|
@ -3019,7 +3018,6 @@ void Curl_expire_clear(struct Curl_easy *data)
|
|||
{
|
||||
struct Curl_multi *multi = data->multi;
|
||||
struct curltime *nowp = &data->state.expiretime;
|
||||
int rc;
|
||||
|
||||
/* this is only interesting while there is still an associated multi struct
|
||||
remaining! */
|
||||
|
|
@ -3030,6 +3028,7 @@ void Curl_expire_clear(struct Curl_easy *data)
|
|||
/* Since this is an cleared time, we must remove the previous entry from
|
||||
the splay tree */
|
||||
struct curl_llist *list = &data->state.timeoutlist;
|
||||
int rc;
|
||||
|
||||
rc = Curl_splayremovebyaddr(multi->timetree,
|
||||
&data->state.timenode,
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ time_t Curl_pp_state_timeout(struct pingpong *pp)
|
|||
struct connectdata *conn = pp->conn;
|
||||
struct Curl_easy *data = conn->data;
|
||||
time_t timeout_ms; /* in milliseconds */
|
||||
time_t timeout2_ms; /* in milliseconds */
|
||||
long response_time = (data->set.server_response_timeout)?
|
||||
data->set.server_response_timeout: pp->response_time;
|
||||
|
||||
|
|
@ -65,7 +64,7 @@ time_t Curl_pp_state_timeout(struct pingpong *pp)
|
|||
|
||||
if(data->set.timeout) {
|
||||
/* if timeout is requested, find out how much remaining time we have */
|
||||
timeout2_ms = data->set.timeout - /* timeout time */
|
||||
time_t timeout2_ms = data->set.timeout - /* timeout time */
|
||||
Curl_timediff(Curl_now(), conn->now); /* spent time */
|
||||
|
||||
/* pick the lowest number */
|
||||
|
|
|
|||
|
|
@ -613,7 +613,6 @@ static CURLcode pop3_state_servergreet_resp(struct connectdata *conn,
|
|||
struct pop3_conn *pop3c = &conn->proto.pop3c;
|
||||
const char *line = data->state.buffer;
|
||||
size_t len = strlen(line);
|
||||
size_t i;
|
||||
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
|
|
@ -625,6 +624,7 @@ static CURLcode pop3_state_servergreet_resp(struct connectdata *conn,
|
|||
/* Does the server support APOP authentication? */
|
||||
if(len >= 4 && line[len - 2] == '>') {
|
||||
/* Look for the APOP timestamp */
|
||||
size_t i;
|
||||
for(i = 3; i < len - 2; ++i) {
|
||||
if(line[i] == '<') {
|
||||
/* Calculate the length of the timestamp */
|
||||
|
|
@ -664,7 +664,6 @@ static CURLcode pop3_state_capa_resp(struct connectdata *conn, int pop3code,
|
|||
struct pop3_conn *pop3c = &conn->proto.pop3c;
|
||||
const char *line = data->state.buffer;
|
||||
size_t len = strlen(line);
|
||||
size_t wordlen;
|
||||
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
|
|
@ -689,6 +688,7 @@ static CURLcode pop3_state_capa_resp(struct connectdata *conn, int pop3code,
|
|||
/* Loop through the data line */
|
||||
for(;;) {
|
||||
size_t llen;
|
||||
size_t wordlen;
|
||||
unsigned int mechbit;
|
||||
|
||||
while(len &&
|
||||
|
|
|
|||
|
|
@ -35,22 +35,22 @@
|
|||
byte) */
|
||||
static void time2str(char *r, curl_off_t seconds)
|
||||
{
|
||||
curl_off_t d, h, m, s;
|
||||
curl_off_t h;
|
||||
if(seconds <= 0) {
|
||||
strcpy(r, "--:--:--");
|
||||
return;
|
||||
}
|
||||
h = seconds / CURL_OFF_T_C(3600);
|
||||
if(h <= CURL_OFF_T_C(99)) {
|
||||
m = (seconds - (h*CURL_OFF_T_C(3600))) / CURL_OFF_T_C(60);
|
||||
s = (seconds - (h*CURL_OFF_T_C(3600))) - (m*CURL_OFF_T_C(60));
|
||||
curl_off_t m = (seconds - (h*CURL_OFF_T_C(3600))) / CURL_OFF_T_C(60);
|
||||
curl_off_t s = (seconds - (h*CURL_OFF_T_C(3600))) - (m*CURL_OFF_T_C(60));
|
||||
snprintf(r, 9, "%2" CURL_FORMAT_CURL_OFF_T ":%02" CURL_FORMAT_CURL_OFF_T
|
||||
":%02" CURL_FORMAT_CURL_OFF_T, h, m, s);
|
||||
}
|
||||
else {
|
||||
/* this equals to more than 99 hours, switch to a more suitable output
|
||||
format to fit within the limits. */
|
||||
d = seconds / CURL_OFF_T_C(86400);
|
||||
curl_off_t d = seconds / CURL_OFF_T_C(86400);
|
||||
h = (seconds - (d*CURL_OFF_T_C(86400))) / CURL_OFF_T_C(3600);
|
||||
if(d <= CURL_OFF_T_C(999))
|
||||
snprintf(r, 9, "%3" CURL_FORMAT_CURL_OFF_T
|
||||
|
|
@ -369,25 +369,10 @@ void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size)
|
|||
int Curl_pgrsUpdate(struct connectdata *conn)
|
||||
{
|
||||
struct curltime now;
|
||||
int result;
|
||||
char max5[6][10];
|
||||
curl_off_t dlpercen = 0;
|
||||
curl_off_t ulpercen = 0;
|
||||
curl_off_t total_percen = 0;
|
||||
curl_off_t total_transfer;
|
||||
curl_off_t total_expected_transfer;
|
||||
curl_off_t timespent;
|
||||
curl_off_t timespent_ms; /* milliseconds */
|
||||
struct Curl_easy *data = conn->data;
|
||||
int nowindex = data->progress.speeder_c% CURR_TIME;
|
||||
int checkindex;
|
||||
int countindex; /* amount of seconds stored in the speeder array */
|
||||
char time_left[10];
|
||||
char time_total[10];
|
||||
char time_spent[10];
|
||||
curl_off_t ulestimate = 0;
|
||||
curl_off_t dlestimate = 0;
|
||||
curl_off_t total_estimate;
|
||||
bool shownow = FALSE;
|
||||
curl_off_t dl = data->progress.downloaded;
|
||||
curl_off_t ul = data->progress.uploaded;
|
||||
|
|
@ -413,6 +398,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
|||
|
||||
/* Calculations done at most once a second, unless end is reached */
|
||||
if(data->progress.lastshow != now.tv_sec) {
|
||||
int countindex; /* amount of seconds stored in the speeder array */
|
||||
shownow = TRUE;
|
||||
|
||||
data->progress.lastshow = now.tv_sec;
|
||||
|
|
@ -438,6 +424,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
|||
|
||||
/* first of all, we don't do this if there's no counted seconds yet */
|
||||
if(countindex) {
|
||||
int checkindex;
|
||||
timediff_t span_ms;
|
||||
|
||||
/* Get the index position to compare with the 'nowindex' position.
|
||||
|
|
@ -477,8 +464,21 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
|||
|
||||
if(!(data->progress.flags & PGRS_HIDE)) {
|
||||
/* progress meter has not been shut off */
|
||||
char max5[6][10];
|
||||
curl_off_t dlpercen = 0;
|
||||
curl_off_t ulpercen = 0;
|
||||
curl_off_t total_percen = 0;
|
||||
curl_off_t total_transfer;
|
||||
curl_off_t total_expected_transfer;
|
||||
char time_left[10];
|
||||
char time_total[10];
|
||||
char time_spent[10];
|
||||
curl_off_t ulestimate = 0;
|
||||
curl_off_t dlestimate = 0;
|
||||
curl_off_t total_estimate;
|
||||
|
||||
if(data->set.fxferinfo) {
|
||||
int result;
|
||||
/* There's a callback set, call that */
|
||||
Curl_set_in_callback(data, true);
|
||||
result = data->set.fxferinfo(data->set.progress_client,
|
||||
|
|
@ -492,6 +492,7 @@ int Curl_pgrsUpdate(struct connectdata *conn)
|
|||
return result;
|
||||
}
|
||||
if(data->set.fprogress) {
|
||||
int result;
|
||||
/* The older deprecated callback is set, call that */
|
||||
Curl_set_in_callback(data, true);
|
||||
result = data->set.fprogress(data->set.progress_client,
|
||||
|
|
|
|||
|
|
@ -218,8 +218,6 @@ static CURLcode rtsp_done(struct connectdata *conn,
|
|||
struct Curl_easy *data = conn->data;
|
||||
struct RTSP *rtsp = data->req.protop;
|
||||
CURLcode httpStatus;
|
||||
long CSeq_sent;
|
||||
long CSeq_recv;
|
||||
|
||||
/* Bypass HTTP empty-reply checks on receive */
|
||||
if(data->set.rtspreq == RTSPREQ_RECEIVE)
|
||||
|
|
@ -229,8 +227,8 @@ static CURLcode rtsp_done(struct connectdata *conn,
|
|||
|
||||
if(rtsp) {
|
||||
/* Check the sequence numbers */
|
||||
CSeq_sent = rtsp->CSeq_sent;
|
||||
CSeq_recv = rtsp->CSeq_recv;
|
||||
long CSeq_sent = rtsp->CSeq_sent;
|
||||
long CSeq_recv = rtsp->CSeq_recv;
|
||||
if((data->set.rtspreq != RTSPREQ_RECEIVE) && (CSeq_sent != CSeq_recv)) {
|
||||
failf(data,
|
||||
"The CSeq of this request %ld did not match the response %ld",
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ int Curl_wait_ms(int timeout_ms)
|
|||
#endif
|
||||
struct curltime initial_tv;
|
||||
int pending_ms;
|
||||
int error;
|
||||
#endif
|
||||
int r = 0;
|
||||
|
||||
|
|
@ -98,6 +97,7 @@ int Curl_wait_ms(int timeout_ms)
|
|||
pending_ms = timeout_ms;
|
||||
initial_tv = Curl_now();
|
||||
do {
|
||||
int error;
|
||||
#if defined(HAVE_POLL_FINE)
|
||||
r = poll(NULL, 0, pending_ms);
|
||||
#else
|
||||
|
|
@ -160,7 +160,6 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
|
|||
#endif
|
||||
struct curltime initial_tv = {0, 0};
|
||||
int pending_ms = 0;
|
||||
int error;
|
||||
int r;
|
||||
int ret;
|
||||
|
||||
|
|
@ -210,6 +209,7 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
|
|||
}
|
||||
|
||||
do {
|
||||
int error;
|
||||
if(timeout_ms < 0)
|
||||
pending_ms = -1;
|
||||
else if(!timeout_ms)
|
||||
|
|
@ -291,6 +291,7 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
|
|||
ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
|
||||
|
||||
do {
|
||||
int error;
|
||||
if(timeout_ms > 0) {
|
||||
pending_tv.tv_sec = pending_ms / 1000;
|
||||
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
|
||||
|
|
@ -402,7 +403,6 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
|||
bool fds_none = TRUE;
|
||||
unsigned int i;
|
||||
int pending_ms = 0;
|
||||
int error;
|
||||
int r;
|
||||
|
||||
if(ufds) {
|
||||
|
|
@ -431,6 +431,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
|||
#ifdef HAVE_POLL_FINE
|
||||
|
||||
do {
|
||||
int error;
|
||||
if(timeout_ms < 0)
|
||||
pending_ms = -1;
|
||||
else if(!timeout_ms)
|
||||
|
|
@ -502,6 +503,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
|
|||
ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
|
||||
|
||||
do {
|
||||
int error;
|
||||
if(timeout_ms > 0) {
|
||||
pending_tv.tv_sec = pending_ms / 1000;
|
||||
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
|
||||
|
|
|
|||
|
|
@ -841,7 +841,6 @@ int Curl_debug(struct Curl_easy *data, curl_infotype type,
|
|||
{
|
||||
int rc;
|
||||
if(data->set.printhost && conn && conn->host.dispname) {
|
||||
char buffer[160];
|
||||
const char *t = NULL;
|
||||
const char *w = "Data";
|
||||
switch(type) {
|
||||
|
|
@ -862,6 +861,7 @@ int Curl_debug(struct Curl_easy *data, curl_infotype type,
|
|||
}
|
||||
|
||||
if(t) {
|
||||
char buffer[160];
|
||||
snprintf(buffer, sizeof(buffer), "[%s %s %s]", w, t,
|
||||
conn->host.dispname);
|
||||
rc = showit(data, CURLINFO_TEXT, buffer, strlen(buffer));
|
||||
|
|
|
|||
|
|
@ -84,8 +84,8 @@ CURLcode Curl_write_plain(struct connectdata *conn,
|
|||
ssize_t *written);
|
||||
|
||||
/* the function used to output verbose information */
|
||||
int Curl_debug(struct Curl_easy *handle, curl_infotype type,
|
||||
char *data, size_t size,
|
||||
int Curl_debug(struct Curl_easy *data, curl_infotype type,
|
||||
char *ptr, size_t size,
|
||||
struct connectdata *conn);
|
||||
|
||||
|
||||
|
|
|
|||
12
lib/sha256.c
12
lib/sha256.c
|
|
@ -130,8 +130,7 @@ static const unsigned long K[64] = {
|
|||
static int sha256_compress(struct sha256_state *md,
|
||||
unsigned char *buf)
|
||||
{
|
||||
unsigned long S[8], W[64], t0, t1;
|
||||
unsigned long t;
|
||||
unsigned long S[8], W[64];
|
||||
int i;
|
||||
/* copy state into S */
|
||||
for(i = 0; i < 8; i++) {
|
||||
|
|
@ -146,12 +145,13 @@ static int sha256_compress(struct sha256_state *md,
|
|||
W[i - 16];
|
||||
}
|
||||
/* Compress */
|
||||
#define RND(a,b,c,d,e,f,g,h,i) \
|
||||
t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
|
||||
t1 = Sigma0(a) + Maj(a, b, c); \
|
||||
d += t0; \
|
||||
#define RND(a,b,c,d,e,f,g,h,i) \
|
||||
unsigned long t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
|
||||
unsigned long t1 = Sigma0(a) + Maj(a, b, c); \
|
||||
d += t0; \
|
||||
h = t0 + t1;
|
||||
for(i = 0; i < 64; ++i) {
|
||||
unsigned long t;
|
||||
RND(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i);
|
||||
t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4];
|
||||
S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t;
|
||||
|
|
|
|||
|
|
@ -704,7 +704,6 @@ static CURLcode smtp_state_ehlo_resp(struct connectdata *conn, int smtpcode,
|
|||
struct smtp_conn *smtpc = &conn->proto.smtpc;
|
||||
const char *line = data->state.buffer;
|
||||
size_t len = strlen(line);
|
||||
size_t wordlen;
|
||||
|
||||
(void)instate; /* no use for this yet */
|
||||
|
||||
|
|
@ -739,6 +738,7 @@ static CURLcode smtp_state_ehlo_resp(struct connectdata *conn, int smtpcode,
|
|||
/* Loop through the data line */
|
||||
for(;;) {
|
||||
size_t llen;
|
||||
size_t wordlen;
|
||||
unsigned int mechbit;
|
||||
|
||||
while(len &&
|
||||
|
|
|
|||
|
|
@ -57,10 +57,9 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
|
|||
ssize_t nread;
|
||||
ssize_t allread = 0;
|
||||
int result;
|
||||
timediff_t timeleft;
|
||||
*n = 0;
|
||||
for(;;) {
|
||||
timeleft = Curl_timeleft(conn->data, NULL, TRUE);
|
||||
timediff_t timeleft = Curl_timeleft(conn->data, NULL, TRUE);
|
||||
if(timeleft < 0) {
|
||||
/* we already got the timeout */
|
||||
result = CURLE_OPERATION_TIMEDOUT;
|
||||
|
|
@ -116,7 +115,6 @@ CURLcode Curl_SOCKS4(const char *proxy_user,
|
|||
#define SOCKS4REQLEN 262
|
||||
unsigned char socksreq[SOCKS4REQLEN]; /* room for SOCKS4 request incl. user
|
||||
id */
|
||||
int result;
|
||||
CURLcode code;
|
||||
curl_socket_t sock = conn->sock[sockindex];
|
||||
struct Curl_easy *data = conn->data;
|
||||
|
|
@ -220,6 +218,7 @@ CURLcode Curl_SOCKS4(const char *proxy_user,
|
|||
* Make connection
|
||||
*/
|
||||
{
|
||||
int result;
|
||||
ssize_t actualread;
|
||||
ssize_t written;
|
||||
ssize_t hostnamelen = 0;
|
||||
|
|
@ -617,11 +616,11 @@ CURLcode Curl_SOCKS5(const char *proxy_user,
|
|||
if(dns)
|
||||
hp = dns->addr;
|
||||
if(hp) {
|
||||
int i;
|
||||
char buf[64];
|
||||
Curl_printable_address(hp, buf, sizeof(buf));
|
||||
|
||||
if(hp->ai_family == AF_INET) {
|
||||
int i;
|
||||
struct sockaddr_in *saddr_in;
|
||||
socksreq[len++] = 1; /* ATYP: IPv4 = 1 */
|
||||
|
||||
|
|
@ -634,6 +633,7 @@ CURLcode Curl_SOCKS5(const char *proxy_user,
|
|||
}
|
||||
#ifdef ENABLE_IPV6
|
||||
else if(hp->ai_family == AF_INET6) {
|
||||
int i;
|
||||
struct sockaddr_in6 *saddr_in6;
|
||||
socksreq[len++] = 4; /* ATYP: IPv6 = 4 */
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ struct Curl_tree *Curl_splay(struct curltime i,
|
|||
struct Curl_tree *t)
|
||||
{
|
||||
struct Curl_tree N, *l, *r, *y;
|
||||
long comp;
|
||||
|
||||
if(t == NULL)
|
||||
return t;
|
||||
|
|
@ -49,7 +48,7 @@ struct Curl_tree *Curl_splay(struct curltime i,
|
|||
l = r = &N;
|
||||
|
||||
for(;;) {
|
||||
comp = compare(i, t->key);
|
||||
long comp = compare(i, t->key);
|
||||
if(comp < 0) {
|
||||
if(t->smaller == NULL)
|
||||
break;
|
||||
|
|
|
|||
32
lib/telnet.c
32
lib/telnet.c
|
|
@ -109,8 +109,10 @@ static void printoption(struct Curl_easy *data,
|
|||
|
||||
static void negotiate(struct connectdata *);
|
||||
static void send_negotiation(struct connectdata *, int cmd, int option);
|
||||
static void set_local_option(struct connectdata *, int cmd, int option);
|
||||
static void set_remote_option(struct connectdata *, int cmd, int option);
|
||||
static void set_local_option(struct connectdata *conn,
|
||||
int option, int newstate);
|
||||
static void set_remote_option(struct connectdata *conn,
|
||||
int option, int newstate);
|
||||
|
||||
static void printsub(struct Curl_easy *data,
|
||||
int direction, unsigned char *pointer,
|
||||
|
|
@ -311,9 +313,6 @@ static void negotiate(struct connectdata *conn)
|
|||
static void printoption(struct Curl_easy *data,
|
||||
const char *direction, int cmd, int option)
|
||||
{
|
||||
const char *fmt;
|
||||
const char *opt;
|
||||
|
||||
if(data->set.verbose) {
|
||||
if(cmd == CURL_IAC) {
|
||||
if(CURL_TELCMD_OK(option))
|
||||
|
|
@ -322,9 +321,12 @@ static void printoption(struct Curl_easy *data,
|
|||
infof(data, "%s IAC %d\n", direction, option);
|
||||
}
|
||||
else {
|
||||
fmt = (cmd == CURL_WILL) ? "WILL" : (cmd == CURL_WONT) ? "WONT" :
|
||||
(cmd == CURL_DO) ? "DO" : (cmd == CURL_DONT) ? "DONT" : 0;
|
||||
const char *fmt = (cmd == CURL_WILL) ? "WILL" :
|
||||
(cmd == CURL_WONT) ? "WONT" :
|
||||
(cmd == CURL_DO) ? "DO" :
|
||||
(cmd == CURL_DONT) ? "DONT" : 0;
|
||||
if(fmt) {
|
||||
const char *opt;
|
||||
if(CURL_TELOPT_OK(option))
|
||||
opt = CURL_TELOPT(option);
|
||||
else if(option == CURL_TELOPT_EXOPL)
|
||||
|
|
@ -348,7 +350,6 @@ static void send_negotiation(struct connectdata *conn, int cmd, int option)
|
|||
{
|
||||
unsigned char buf[3];
|
||||
ssize_t bytes_written;
|
||||
int err;
|
||||
struct Curl_easy *data = conn->data;
|
||||
|
||||
buf[0] = CURL_IAC;
|
||||
|
|
@ -357,7 +358,7 @@ static void send_negotiation(struct connectdata *conn, int cmd, int option)
|
|||
|
||||
bytes_written = swrite(conn->sock[FIRSTSOCKET], buf, 3);
|
||||
if(bytes_written < 0) {
|
||||
err = SOCKERRNO;
|
||||
int err = SOCKERRNO;
|
||||
failf(data,"Sending data failed (%d)",err);
|
||||
}
|
||||
|
||||
|
|
@ -710,9 +711,8 @@ static void printsub(struct Curl_easy *data,
|
|||
unsigned char *pointer, /* where suboption data is */
|
||||
size_t length) /* length of suboption data */
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
if(data->set.verbose) {
|
||||
unsigned int i = 0;
|
||||
if(direction) {
|
||||
infof(data, "%s IAC SB ", (direction == '<')? "RCVD":"SENT");
|
||||
if(length >= 3) {
|
||||
|
|
@ -928,7 +928,6 @@ static void suboption(struct connectdata *conn)
|
|||
unsigned char temp[2048];
|
||||
ssize_t bytes_written;
|
||||
size_t len;
|
||||
size_t tmplen;
|
||||
int err;
|
||||
char varname[128] = "";
|
||||
char varval[128] = "";
|
||||
|
|
@ -968,7 +967,7 @@ static void suboption(struct connectdata *conn)
|
|||
len = 4;
|
||||
|
||||
for(v = tn->telnet_vars; v; v = v->next) {
|
||||
tmplen = (strlen(v->data) + 1);
|
||||
size_t tmplen = (strlen(v->data) + 1);
|
||||
/* Add the variable only if it fits */
|
||||
if(len + tmplen < (int)sizeof(temp)-6) {
|
||||
if(sscanf(v->data, "%127[^,],%127s", varname, varval)) {
|
||||
|
|
@ -1223,7 +1222,7 @@ CURLcode telrcv(struct connectdata *conn,
|
|||
static CURLcode send_telnet_data(struct connectdata *conn,
|
||||
char *buffer, ssize_t nread)
|
||||
{
|
||||
ssize_t escapes, i, j, outlen;
|
||||
ssize_t escapes, i, outlen;
|
||||
unsigned char *outbuf = NULL;
|
||||
CURLcode result = CURLE_OK;
|
||||
ssize_t bytes_written, total_written;
|
||||
|
|
@ -1238,6 +1237,7 @@ static CURLcode send_telnet_data(struct connectdata *conn,
|
|||
if(outlen == nread)
|
||||
outbuf = (unsigned char *)buffer;
|
||||
else {
|
||||
ssize_t j;
|
||||
outbuf = malloc(nread + escapes + 1);
|
||||
if(!outbuf)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
@ -1315,7 +1315,6 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
|||
HANDLE objs[2];
|
||||
DWORD obj_count;
|
||||
DWORD wait_timeout;
|
||||
DWORD waitret;
|
||||
DWORD readfile_read;
|
||||
int err;
|
||||
#else
|
||||
|
|
@ -1438,7 +1437,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
|
|||
/* Keep on listening and act on events */
|
||||
while(keepon) {
|
||||
const DWORD buf_size = (DWORD)data->set.buffer_size;
|
||||
waitret = WaitForMultipleObjects(obj_count, objs, FALSE, wait_timeout);
|
||||
DWORD waitret = WaitForMultipleObjects(obj_count, objs,
|
||||
FALSE, wait_timeout);
|
||||
switch(waitret) {
|
||||
case WAIT_TIMEOUT:
|
||||
{
|
||||
|
|
|
|||
16
lib/tftp.c
16
lib/tftp.c
|
|
@ -451,7 +451,6 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
|
|||
ssize_t senddata;
|
||||
const char *mode = "octet";
|
||||
char *filename;
|
||||
char buf[64];
|
||||
struct Curl_easy *data = state->conn->data;
|
||||
CURLcode result = CURLE_OK;
|
||||
|
||||
|
|
@ -504,6 +503,7 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
|
|||
|
||||
/* optional addition of TFTP options */
|
||||
if(!data->set.tftp_no_options) {
|
||||
char buf[64];
|
||||
/* add tsize option */
|
||||
if(data->set.upload && (data->state.infilesize != -1))
|
||||
snprintf(buf, sizeof(buf), "%" CURL_FORMAT_CURL_OFF_T,
|
||||
|
|
@ -710,7 +710,6 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event)
|
|||
{
|
||||
struct Curl_easy *data = state->conn->data;
|
||||
ssize_t sbytes;
|
||||
int rblock;
|
||||
CURLcode result = CURLE_OK;
|
||||
struct SingleRequest *k = &data->req;
|
||||
int cb; /* Bytes currently read */
|
||||
|
|
@ -721,7 +720,7 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event)
|
|||
case TFTP_EVENT_OACK:
|
||||
if(event == TFTP_EVENT_ACK) {
|
||||
/* Ack the packet */
|
||||
rblock = getrpacketblock(&state->rpacket);
|
||||
int rblock = getrpacketblock(&state->rpacket);
|
||||
|
||||
if(rblock != state->block &&
|
||||
/* There's a bug in tftpd-hpa that causes it to send us an ack for
|
||||
|
|
@ -969,7 +968,7 @@ static CURLcode tftp_disconnect(struct connectdata *conn, bool dead_connection)
|
|||
static CURLcode tftp_connect(struct connectdata *conn, bool *done)
|
||||
{
|
||||
tftp_state_data_t *state;
|
||||
int blksize, rc;
|
||||
int blksize;
|
||||
|
||||
blksize = TFTP_BLKSIZE_DEFAULT;
|
||||
|
||||
|
|
@ -1028,8 +1027,8 @@ static CURLcode tftp_connect(struct connectdata *conn, bool *done)
|
|||
* assume uses the same IP version and thus hopefully this works for both
|
||||
* IPv4 and IPv6...
|
||||
*/
|
||||
rc = bind(state->sockfd, (struct sockaddr *)&state->local_addr,
|
||||
conn->ip_addr->ai_addrlen);
|
||||
int rc = bind(state->sockfd, (struct sockaddr *)&state->local_addr,
|
||||
conn->ip_addr->ai_addrlen);
|
||||
if(rc) {
|
||||
failf(conn->data, "bind() failed; %s",
|
||||
Curl_strerror(conn, SOCKERRNO));
|
||||
|
|
@ -1224,7 +1223,6 @@ static long tftp_state_timeout(struct connectdata *conn, tftp_event_t *event)
|
|||
**********************************************************/
|
||||
static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
|
||||
{
|
||||
int rc;
|
||||
tftp_event_t event;
|
||||
CURLcode result = CURLE_OK;
|
||||
struct Curl_easy *data = conn->data;
|
||||
|
|
@ -1248,7 +1246,7 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
|
|||
}
|
||||
else {
|
||||
/* no timeouts to handle, check our socket */
|
||||
rc = SOCKET_READABLE(state->sockfd, 0);
|
||||
int rc = SOCKET_READABLE(state->sockfd, 0);
|
||||
|
||||
if(rc == -1) {
|
||||
/* bail out */
|
||||
|
|
@ -1371,7 +1369,6 @@ static CURLcode tftp_setup_connection(struct connectdata * conn)
|
|||
{
|
||||
struct Curl_easy *data = conn->data;
|
||||
char *type;
|
||||
char command;
|
||||
|
||||
conn->socktype = SOCK_DGRAM; /* UDP datagram based */
|
||||
|
||||
|
|
@ -1383,6 +1380,7 @@ static CURLcode tftp_setup_connection(struct connectdata * conn)
|
|||
type = strstr(conn->host.rawalloc, ";mode=");
|
||||
|
||||
if(type) {
|
||||
char command;
|
||||
*type = 0; /* it was in the middle of the hostname */
|
||||
command = Curl_raw_toupper(type[6]);
|
||||
|
||||
|
|
|
|||
|
|
@ -444,7 +444,6 @@ static CURLcode readwrite_data(struct Curl_easy *data,
|
|||
CURLcode result = CURLE_OK;
|
||||
ssize_t nread; /* number of bytes read */
|
||||
size_t excess = 0; /* excess bytes read */
|
||||
bool is_empty_data = FALSE;
|
||||
bool readmore = FALSE; /* used by RTP to signal for more data */
|
||||
int maxloops = 100;
|
||||
|
||||
|
|
@ -454,6 +453,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
|
|||
/* This is where we loop until we have read everything there is to
|
||||
read or we get a CURLE_AGAIN */
|
||||
do {
|
||||
bool is_empty_data = FALSE;
|
||||
size_t buffersize = data->set.buffer_size;
|
||||
size_t bytestoread = buffersize;
|
||||
|
||||
|
|
|
|||
15
lib/url.c
15
lib/url.c
|
|
@ -2003,7 +2003,6 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
|
|||
char *fragment;
|
||||
char *path = data->state.path;
|
||||
char *query;
|
||||
int i;
|
||||
int rc;
|
||||
const char *protop = "";
|
||||
CURLcode result;
|
||||
|
|
@ -2055,6 +2054,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
|
|||
; /* do nothing */
|
||||
}
|
||||
else { /* check for a scheme */
|
||||
int i;
|
||||
for(i = 0; i < 16 && data->change.url[i]; ++i) {
|
||||
if(data->change.url[i] == '/')
|
||||
break;
|
||||
|
|
@ -2543,14 +2543,13 @@ static bool check_noproxy(const char *name, const char *no_proxy)
|
|||
* not be proxied, or an asterisk to override
|
||||
* all proxy variables)
|
||||
*/
|
||||
size_t tok_start;
|
||||
size_t tok_end;
|
||||
const char *separator = ", ";
|
||||
size_t no_proxy_len;
|
||||
size_t namelen;
|
||||
char *endptr;
|
||||
|
||||
if(no_proxy && no_proxy[0]) {
|
||||
size_t tok_start;
|
||||
size_t tok_end;
|
||||
const char *separator = ", ";
|
||||
size_t no_proxy_len;
|
||||
size_t namelen;
|
||||
char *endptr;
|
||||
if(strcasecompare("*", no_proxy)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ static void auth_digest_sha256_to_ascii(unsigned char *source, /* 32 bytes */
|
|||
/* Perform quoted-string escaping as described in RFC2616 and its errata */
|
||||
static char *auth_digest_string_quoted(const char *source)
|
||||
{
|
||||
char *dest, *d;
|
||||
char *dest;
|
||||
const char *s = source;
|
||||
size_t n = 1; /* null terminator */
|
||||
|
||||
|
|
@ -173,8 +173,8 @@ static char *auth_digest_string_quoted(const char *source)
|
|||
|
||||
dest = malloc(n);
|
||||
if(dest) {
|
||||
char *d = dest;
|
||||
s = source;
|
||||
d = dest;
|
||||
while(*s) {
|
||||
if(*s == '"' || *s == '\\') {
|
||||
*d++ = '\\';
|
||||
|
|
@ -696,7 +696,6 @@ static CURLcode _Curl_auth_create_digest_http_message(
|
|||
unsigned char ha1[65]; /* 64 digits and 1 zero byte */
|
||||
unsigned char ha2[65]; /* 64 digits and 1 zero byte */
|
||||
char userh[65];
|
||||
char cnoncebuf[33];
|
||||
char *cnonce = NULL;
|
||||
size_t cnonce_sz = 0;
|
||||
char *userp_quoted;
|
||||
|
|
@ -707,6 +706,7 @@ static CURLcode _Curl_auth_create_digest_http_message(
|
|||
digest->nc = 1;
|
||||
|
||||
if(!digest->cnonce) {
|
||||
char cnoncebuf[33];
|
||||
result = Curl_rand_hex(data, (unsigned char *)cnoncebuf,
|
||||
sizeof(cnoncebuf));
|
||||
if(result)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue