code cleanup: we prefer 'CURLcode result'
... for the local variable name in functions holding the return code. Using the same name universally makes code easier to read and follow. Also, unify code for checking for CURLcode errors with: if(result) or if(!result) instead of if(result == CURLE_OK), if(CURLE_OK == result) or if(result != CURLE_OK)
This commit is contained in:
Родитель
1752e9c088
Коммит
0eb3d15ccb
|
@ -131,7 +131,7 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc,
|
||||||
conn->host.name);
|
conn->host.name);
|
||||||
if(!bundle) {
|
if(!bundle) {
|
||||||
result = Curl_bundle_create(data, &new_bundle);
|
result = Curl_bundle_create(data, &new_bundle);
|
||||||
if(result != CURLE_OK)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
if(!conncache_add_bundle(data->state.conn_cache,
|
if(!conncache_add_bundle(data->state.conn_cache,
|
||||||
|
@ -143,7 +143,7 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc,
|
||||||
}
|
}
|
||||||
|
|
||||||
result = Curl_bundle_add_conn(bundle, conn);
|
result = Curl_bundle_add_conn(bundle, conn);
|
||||||
if(result != CURLE_OK) {
|
if(result) {
|
||||||
if(new_bundle)
|
if(new_bundle)
|
||||||
conncache_remove_bundle(data->state.conn_cache, new_bundle);
|
conncache_remove_bundle(data->state.conn_cache, new_bundle);
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -717,11 +717,11 @@ CURLcode Curl_is_connected(struct connectdata *conn,
|
||||||
bool *connected)
|
bool *connected)
|
||||||
{
|
{
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
CURLcode code = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
long allow;
|
long allow;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
int result;
|
int rc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
DEBUGASSERT(sockindex >= FIRSTSOCKET && sockindex <= SECONDARYSOCKET);
|
DEBUGASSERT(sockindex >= FIRSTSOCKET && sockindex <= SECONDARYSOCKET);
|
||||||
|
@ -757,9 +757,9 @@ CURLcode Curl_is_connected(struct connectdata *conn,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* check socket for connect */
|
/* check socket for connect */
|
||||||
result = Curl_socket_ready(CURL_SOCKET_BAD, conn->tempsock[i], 0);
|
rc = Curl_socket_ready(CURL_SOCKET_BAD, conn->tempsock[i], 0);
|
||||||
|
|
||||||
if(result == 0) { /* no connection yet */
|
if(rc == 0) { /* no connection yet */
|
||||||
if(curlx_tvdiff(now, conn->connecttime) >= conn->timeoutms_per_addr) {
|
if(curlx_tvdiff(now, conn->connecttime) >= conn->timeoutms_per_addr) {
|
||||||
infof(data, "After %ldms connect time, move on!\n",
|
infof(data, "After %ldms connect time, move on!\n",
|
||||||
conn->timeoutms_per_addr);
|
conn->timeoutms_per_addr);
|
||||||
|
@ -772,7 +772,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
|
||||||
trynextip(conn, sockindex, 1);
|
trynextip(conn, sockindex, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(result == CURL_CSELECT_OUT) {
|
else if(rc == CURL_CSELECT_OUT) {
|
||||||
if(verifyconnect(conn->tempsock[i], &error)) {
|
if(verifyconnect(conn->tempsock[i], &error)) {
|
||||||
/* we are connected with TCP, awesome! */
|
/* we are connected with TCP, awesome! */
|
||||||
int other = i ^ 1;
|
int other = i ^ 1;
|
||||||
|
@ -789,9 +789,9 @@ CURLcode Curl_is_connected(struct connectdata *conn,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* see if we need to do any proxy magic first once we connected */
|
/* see if we need to do any proxy magic first once we connected */
|
||||||
code = Curl_connected_proxy(conn, sockindex);
|
result = Curl_connected_proxy(conn, sockindex);
|
||||||
if(code)
|
if(result)
|
||||||
return code;
|
return result;
|
||||||
|
|
||||||
conn->bits.tcpconnect[sockindex] = TRUE;
|
conn->bits.tcpconnect[sockindex] = TRUE;
|
||||||
|
|
||||||
|
@ -806,7 +806,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
|
||||||
else
|
else
|
||||||
infof(data, "Connection failed\n");
|
infof(data, "Connection failed\n");
|
||||||
}
|
}
|
||||||
else if(result & CURL_CSELECT_ERR)
|
else if(rc & CURL_CSELECT_ERR)
|
||||||
(void)verifyconnect(conn->tempsock[i], &error);
|
(void)verifyconnect(conn->tempsock[i], &error);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -825,21 +825,20 @@ CURLcode Curl_is_connected(struct connectdata *conn,
|
||||||
conn->timeoutms_per_addr = conn->tempaddr[i]->ai_next == NULL ?
|
conn->timeoutms_per_addr = conn->tempaddr[i]->ai_next == NULL ?
|
||||||
allow : allow / 2;
|
allow : allow / 2;
|
||||||
|
|
||||||
code = trynextip(conn, sockindex, i);
|
result = trynextip(conn, sockindex, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(code) {
|
if(result) {
|
||||||
/* no more addresses to try */
|
/* no more addresses to try */
|
||||||
|
|
||||||
/* if the first address family runs out of addresses to try before
|
/* if the first address family runs out of addresses to try before
|
||||||
the happy eyeball timeout, go ahead and try the next family now */
|
the happy eyeball timeout, go ahead and try the next family now */
|
||||||
if(conn->tempaddr[1] == NULL) {
|
if(conn->tempaddr[1] == NULL) {
|
||||||
int rc;
|
result = trynextip(conn, sockindex, 1);
|
||||||
rc = trynextip(conn, sockindex, 1);
|
if(!result)
|
||||||
if(rc == CURLE_OK)
|
return result;
|
||||||
return CURLE_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
failf(data, "Failed to connect to %s port %ld: %s",
|
failf(data, "Failed to connect to %s port %ld: %s",
|
||||||
|
@ -847,7 +846,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
|
||||||
conn->port, Curl_strerror(conn, error));
|
conn->port, Curl_strerror(conn, error));
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tcpnodelay(struct connectdata *conn,
|
static void tcpnodelay(struct connectdata *conn,
|
||||||
|
@ -1117,7 +1116,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
|
||||||
{
|
{
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
struct timeval before = Curl_tvnow();
|
struct timeval before = Curl_tvnow();
|
||||||
CURLcode res = CURLE_COULDNT_CONNECT;
|
CURLcode result = CURLE_COULDNT_CONNECT;
|
||||||
|
|
||||||
long timeout_ms = Curl_timeleft(data, &before, TRUE);
|
long timeout_ms = Curl_timeleft(data, &before, TRUE);
|
||||||
|
|
||||||
|
@ -1140,14 +1139,14 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
|
||||||
|
|
||||||
/* start connecting to first IP */
|
/* start connecting to first IP */
|
||||||
while(conn->tempaddr[0]) {
|
while(conn->tempaddr[0]) {
|
||||||
res = singleipconnect(conn, conn->tempaddr[0], &(conn->tempsock[0]));
|
result = singleipconnect(conn, conn->tempaddr[0], &(conn->tempsock[0]));
|
||||||
if(res == CURLE_OK)
|
if(!result)
|
||||||
break;
|
break;
|
||||||
conn->tempaddr[0] = conn->tempaddr[0]->ai_next;
|
conn->tempaddr[0] = conn->tempaddr[0]->ai_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(conn->tempsock[0] == CURL_SOCKET_BAD)
|
if(conn->tempsock[0] == CURL_SOCKET_BAD)
|
||||||
return res;
|
return result;
|
||||||
|
|
||||||
data->info.numconnects++; /* to track the number of connections made */
|
data->info.numconnects++; /* to track the number of connections made */
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
|
@ -354,7 +354,7 @@ Curl_he2ai(const struct hostent *he, int port)
|
||||||
prevai = ai;
|
prevai = ai;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(result != CURLE_OK) {
|
if(result) {
|
||||||
Curl_freeaddrinfo(firstai);
|
Curl_freeaddrinfo(firstai);
|
||||||
firstai = NULL;
|
firstai = NULL;
|
||||||
}
|
}
|
||||||
|
|
94
lib/easy.c
94
lib/easy.c
|
@ -136,9 +136,9 @@ static CURLcode win32_init(void)
|
||||||
|
|
||||||
#ifdef USE_WINDOWS_SSPI
|
#ifdef USE_WINDOWS_SSPI
|
||||||
{
|
{
|
||||||
CURLcode err = Curl_sspi_global_init();
|
CURLcode result = Curl_sspi_global_init();
|
||||||
if(err != CURLE_OK)
|
if(result)
|
||||||
return err;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ CURLcode curl_global_init(long flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flags & CURL_GLOBAL_WIN32)
|
if(flags & CURL_GLOBAL_WIN32)
|
||||||
if(win32_init() != CURLE_OK) {
|
if(win32_init()) {
|
||||||
DEBUGF(fprintf(stderr, "Error: win32_init failed\n"));
|
DEBUGF(fprintf(stderr, "Error: win32_init failed\n"));
|
||||||
return CURLE_FAILED_INIT;
|
return CURLE_FAILED_INIT;
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ CURLcode curl_global_init(long flags)
|
||||||
idna_init();
|
idna_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(Curl_resolver_global_init() != CURLE_OK) {
|
if(Curl_resolver_global_init()) {
|
||||||
DEBUGF(fprintf(stderr, "Error: resolver_global_init failed\n"));
|
DEBUGF(fprintf(stderr, "Error: resolver_global_init failed\n"));
|
||||||
return CURLE_FAILED_INIT;
|
return CURLE_FAILED_INIT;
|
||||||
}
|
}
|
||||||
|
@ -293,7 +293,7 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m,
|
||||||
curl_free_callback f, curl_realloc_callback r,
|
curl_free_callback f, curl_realloc_callback r,
|
||||||
curl_strdup_callback s, curl_calloc_callback c)
|
curl_strdup_callback s, curl_calloc_callback c)
|
||||||
{
|
{
|
||||||
CURLcode code = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
|
|
||||||
/* Invalid input, return immediately */
|
/* Invalid input, return immediately */
|
||||||
if(!m || !f || !r || !s || !c)
|
if(!m || !f || !r || !s || !c)
|
||||||
|
@ -308,8 +308,8 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call the actual init function first */
|
/* Call the actual init function first */
|
||||||
code = curl_global_init(flags);
|
result = curl_global_init(flags);
|
||||||
if(code == CURLE_OK) {
|
if(!result) {
|
||||||
Curl_cmalloc = m;
|
Curl_cmalloc = m;
|
||||||
Curl_cfree = f;
|
Curl_cfree = f;
|
||||||
Curl_cstrdup = s;
|
Curl_cstrdup = s;
|
||||||
|
@ -317,7 +317,7 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m,
|
||||||
Curl_ccalloc = c;
|
Curl_ccalloc = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -357,13 +357,13 @@ void curl_global_cleanup(void)
|
||||||
*/
|
*/
|
||||||
CURL *curl_easy_init(void)
|
CURL *curl_easy_init(void)
|
||||||
{
|
{
|
||||||
CURLcode res;
|
CURLcode result;
|
||||||
struct SessionHandle *data;
|
struct SessionHandle *data;
|
||||||
|
|
||||||
/* Make sure we inited the global SSL stuff */
|
/* Make sure we inited the global SSL stuff */
|
||||||
if(!initialized) {
|
if(!initialized) {
|
||||||
res = curl_global_init(CURL_GLOBAL_DEFAULT);
|
result = curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||||
if(res) {
|
if(result) {
|
||||||
/* something in the global init failed, return nothing */
|
/* something in the global init failed, return nothing */
|
||||||
DEBUGF(fprintf(stderr, "Error: curl_global_init failed\n"));
|
DEBUGF(fprintf(stderr, "Error: curl_global_init failed\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -371,8 +371,8 @@ CURL *curl_easy_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We use curl_open() with undefined URL so far */
|
/* We use curl_open() with undefined URL so far */
|
||||||
res = Curl_open(&data);
|
result = Curl_open(&data);
|
||||||
if(res != CURLE_OK) {
|
if(result) {
|
||||||
DEBUGF(fprintf(stderr, "Error: Curl_open failed\n"));
|
DEBUGF(fprintf(stderr, "Error: Curl_open failed\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -390,17 +390,17 @@ CURLcode curl_easy_setopt(CURL *curl, CURLoption tag, ...)
|
||||||
{
|
{
|
||||||
va_list arg;
|
va_list arg;
|
||||||
struct SessionHandle *data = curl;
|
struct SessionHandle *data = curl;
|
||||||
CURLcode ret;
|
CURLcode result;
|
||||||
|
|
||||||
if(!curl)
|
if(!curl)
|
||||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
|
|
||||||
va_start(arg, tag);
|
va_start(arg, tag);
|
||||||
|
|
||||||
ret = Curl_setopt(data, tag, arg);
|
result = Curl_setopt(data, tag, arg);
|
||||||
|
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
return ret;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CURLDEBUG
|
#ifdef CURLDEBUG
|
||||||
|
@ -570,7 +570,7 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
|
||||||
{
|
{
|
||||||
bool done = FALSE;
|
bool done = FALSE;
|
||||||
CURLMcode mcode;
|
CURLMcode mcode;
|
||||||
CURLcode rc = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
|
|
||||||
while(!done) {
|
while(!done) {
|
||||||
CURLMsg *msg;
|
CURLMsg *msg;
|
||||||
|
@ -640,12 +640,12 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
|
||||||
second argument */
|
second argument */
|
||||||
msg = curl_multi_info_read(multi, &pollrc);
|
msg = curl_multi_info_read(multi, &pollrc);
|
||||||
if(msg) {
|
if(msg) {
|
||||||
rc = msg->data.result;
|
result = msg->data.result;
|
||||||
done = TRUE;
|
done = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -671,7 +671,7 @@ static CURLcode easy_transfer(CURLM *multi)
|
||||||
{
|
{
|
||||||
bool done = FALSE;
|
bool done = FALSE;
|
||||||
CURLMcode mcode = CURLM_OK;
|
CURLMcode mcode = CURLM_OK;
|
||||||
CURLcode code = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
struct timeval before;
|
struct timeval before;
|
||||||
int without_fds = 0; /* count number of consecutive returns from
|
int without_fds = 0; /* count number of consecutive returns from
|
||||||
curl_multi_wait() without any filedescriptors */
|
curl_multi_wait() without any filedescriptors */
|
||||||
|
@ -686,7 +686,7 @@ static CURLcode easy_transfer(CURLM *multi)
|
||||||
if(mcode == CURLM_OK) {
|
if(mcode == CURLM_OK) {
|
||||||
if(ret == -1) {
|
if(ret == -1) {
|
||||||
/* poll() failed not on EINTR, indicate a network problem */
|
/* poll() failed not on EINTR, indicate a network problem */
|
||||||
code = CURLE_RECV_ERROR;
|
result = CURLE_RECV_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if(ret == 0) {
|
else if(ret == 0) {
|
||||||
|
@ -717,7 +717,7 @@ static CURLcode easy_transfer(CURLM *multi)
|
||||||
int rc;
|
int rc;
|
||||||
CURLMsg *msg = curl_multi_info_read(multi, &rc);
|
CURLMsg *msg = curl_multi_info_read(multi, &rc);
|
||||||
if(msg) {
|
if(msg) {
|
||||||
code = msg->data.result;
|
result = msg->data.result;
|
||||||
done = TRUE;
|
done = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -731,7 +731,7 @@ static CURLcode easy_transfer(CURLM *multi)
|
||||||
CURLE_BAD_FUNCTION_ARGUMENT;
|
CURLE_BAD_FUNCTION_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -756,7 +756,7 @@ static CURLcode easy_perform(struct SessionHandle *data, bool events)
|
||||||
{
|
{
|
||||||
CURLM *multi;
|
CURLM *multi;
|
||||||
CURLMcode mcode;
|
CURLMcode mcode;
|
||||||
CURLcode code = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
SIGPIPE_VARIABLE(pipe_st);
|
SIGPIPE_VARIABLE(pipe_st);
|
||||||
|
|
||||||
if(!data)
|
if(!data)
|
||||||
|
@ -797,7 +797,7 @@ static CURLcode easy_perform(struct SessionHandle *data, bool events)
|
||||||
data->multi = multi;
|
data->multi = multi;
|
||||||
|
|
||||||
/* run the transfer */
|
/* run the transfer */
|
||||||
code = events ? easy_events(multi) : easy_transfer(multi);
|
result = events ? easy_events(multi) : easy_transfer(multi);
|
||||||
|
|
||||||
/* ignoring the return code isn't nice, but atm we can't really handle
|
/* ignoring the return code isn't nice, but atm we can't really handle
|
||||||
a failure here, room for future improvement! */
|
a failure here, room for future improvement! */
|
||||||
|
@ -806,7 +806,7 @@ static CURLcode easy_perform(struct SessionHandle *data, bool events)
|
||||||
sigpipe_restore(&pipe_st);
|
sigpipe_restore(&pipe_st);
|
||||||
|
|
||||||
/* The multi handle is kept alive, owned by the easy handle */
|
/* The multi handle is kept alive, owned by the easy handle */
|
||||||
return code;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -857,16 +857,16 @@ CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...)
|
||||||
{
|
{
|
||||||
va_list arg;
|
va_list arg;
|
||||||
void *paramp;
|
void *paramp;
|
||||||
CURLcode ret;
|
CURLcode result;
|
||||||
struct SessionHandle *data = (struct SessionHandle *)curl;
|
struct SessionHandle *data = (struct SessionHandle *)curl;
|
||||||
|
|
||||||
va_start(arg, info);
|
va_start(arg, info);
|
||||||
paramp = va_arg(arg, void *);
|
paramp = va_arg(arg, void *);
|
||||||
|
|
||||||
ret = Curl_getinfo(data, info, paramp);
|
result = Curl_getinfo(data, info, paramp);
|
||||||
|
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
return ret;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -893,7 +893,7 @@ CURL *curl_easy_duphandle(CURL *incurl)
|
||||||
outcurl->state.headersize = HEADERSIZE;
|
outcurl->state.headersize = HEADERSIZE;
|
||||||
|
|
||||||
/* copy all userdefined values */
|
/* copy all userdefined values */
|
||||||
if(Curl_dupset(outcurl, data) != CURLE_OK)
|
if(Curl_dupset(outcurl, data))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* the connection cache is setup on demand */
|
/* the connection cache is setup on demand */
|
||||||
|
@ -939,7 +939,7 @@ CURL *curl_easy_duphandle(CURL *incurl)
|
||||||
|
|
||||||
/* Clone the resolver handle, if present, for the new handle */
|
/* Clone the resolver handle, if present, for the new handle */
|
||||||
if(Curl_resolver_duphandle(&outcurl->state.resolver,
|
if(Curl_resolver_duphandle(&outcurl->state.resolver,
|
||||||
data->state.resolver) != CURLE_OK)
|
data->state.resolver))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
Curl_convert_setup(outcurl);
|
Curl_convert_setup(outcurl);
|
||||||
|
@ -1085,7 +1085,7 @@ CURLcode curl_easy_pause(CURL *curl, int action)
|
||||||
tempwrite += chunklen; /* advance the pointer */
|
tempwrite += chunklen; /* advance the pointer */
|
||||||
}
|
}
|
||||||
|
|
||||||
} while((result == CURLE_OK) && tempsize);
|
} while(!result && tempsize);
|
||||||
|
|
||||||
free(freewrite); /* this is unconditionally no longer used */
|
free(freewrite); /* this is unconditionally no longer used */
|
||||||
}
|
}
|
||||||
|
@ -1132,20 +1132,20 @@ static CURLcode easy_connection(struct SessionHandle *data,
|
||||||
CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, size_t *n)
|
CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, size_t *n)
|
||||||
{
|
{
|
||||||
curl_socket_t sfd;
|
curl_socket_t sfd;
|
||||||
CURLcode ret;
|
CURLcode result;
|
||||||
ssize_t n1;
|
ssize_t n1;
|
||||||
struct connectdata *c;
|
struct connectdata *c;
|
||||||
struct SessionHandle *data = (struct SessionHandle *)curl;
|
struct SessionHandle *data = (struct SessionHandle *)curl;
|
||||||
|
|
||||||
ret = easy_connection(data, &sfd, &c);
|
result = easy_connection(data, &sfd, &c);
|
||||||
if(ret)
|
if(result)
|
||||||
return ret;
|
return result;
|
||||||
|
|
||||||
*n = 0;
|
*n = 0;
|
||||||
ret = Curl_read(c, sfd, buffer, buflen, &n1);
|
result = Curl_read(c, sfd, buffer, buflen, &n1);
|
||||||
|
|
||||||
if(ret != CURLE_OK)
|
if(result)
|
||||||
return ret;
|
return result;
|
||||||
|
|
||||||
*n = (size_t)n1;
|
*n = (size_t)n1;
|
||||||
|
|
||||||
|
@ -1160,26 +1160,26 @@ CURLcode curl_easy_send(CURL *curl, const void *buffer, size_t buflen,
|
||||||
size_t *n)
|
size_t *n)
|
||||||
{
|
{
|
||||||
curl_socket_t sfd;
|
curl_socket_t sfd;
|
||||||
CURLcode ret;
|
CURLcode result;
|
||||||
ssize_t n1;
|
ssize_t n1;
|
||||||
struct connectdata *c = NULL;
|
struct connectdata *c = NULL;
|
||||||
struct SessionHandle *data = (struct SessionHandle *)curl;
|
struct SessionHandle *data = (struct SessionHandle *)curl;
|
||||||
|
|
||||||
ret = easy_connection(data, &sfd, &c);
|
result = easy_connection(data, &sfd, &c);
|
||||||
if(ret)
|
if(result)
|
||||||
return ret;
|
return result;
|
||||||
|
|
||||||
*n = 0;
|
*n = 0;
|
||||||
ret = Curl_write(c, sfd, buffer, buflen, &n1);
|
result = Curl_write(c, sfd, buffer, buflen, &n1);
|
||||||
|
|
||||||
if(n1 == -1)
|
if(n1 == -1)
|
||||||
return CURLE_SEND_ERROR;
|
return CURLE_SEND_ERROR;
|
||||||
|
|
||||||
/* detect EAGAIN */
|
/* detect EAGAIN */
|
||||||
if((CURLE_OK == ret) && (0 == n1))
|
if(!result && !n1)
|
||||||
return CURLE_AGAIN;
|
return CURLE_AGAIN;
|
||||||
|
|
||||||
*n = (size_t)n1;
|
*n = (size_t)n1;
|
||||||
|
|
||||||
return ret;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
39
lib/file.c
39
lib/file.c
|
@ -303,7 +303,7 @@ static CURLcode file_upload(struct connectdata *conn)
|
||||||
const char *dir = strchr(file->path, DIRSEP);
|
const char *dir = strchr(file->path, DIRSEP);
|
||||||
int fd;
|
int fd;
|
||||||
int mode;
|
int mode;
|
||||||
CURLcode res=CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
char *buf = data->state.buffer;
|
char *buf = data->state.buffer;
|
||||||
size_t nread;
|
size_t nread;
|
||||||
|
@ -359,10 +359,10 @@ static CURLcode file_upload(struct connectdata *conn)
|
||||||
data->state.resume_from = (curl_off_t)file_stat.st_size;
|
data->state.resume_from = (curl_off_t)file_stat.st_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(res == CURLE_OK) {
|
while(!result) {
|
||||||
int readcount;
|
int readcount;
|
||||||
res = Curl_fillreadbuffer(conn, BUFSIZE, &readcount);
|
result = Curl_fillreadbuffer(conn, BUFSIZE, &readcount);
|
||||||
if(res)
|
if(result)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(readcount <= 0) /* fix questionable compare error. curlvms */
|
if(readcount <= 0) /* fix questionable compare error. curlvms */
|
||||||
|
@ -389,7 +389,7 @@ static CURLcode file_upload(struct connectdata *conn)
|
||||||
/* write the data to the target */
|
/* write the data to the target */
|
||||||
nwrite = write(fd, buf2, nread);
|
nwrite = write(fd, buf2, nread);
|
||||||
if(nwrite != nread) {
|
if(nwrite != nread) {
|
||||||
res = CURLE_SEND_ERROR;
|
result = CURLE_SEND_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,16 +398,16 @@ static CURLcode file_upload(struct connectdata *conn)
|
||||||
Curl_pgrsSetUploadCounter(data, bytecount);
|
Curl_pgrsSetUploadCounter(data, bytecount);
|
||||||
|
|
||||||
if(Curl_pgrsUpdate(conn))
|
if(Curl_pgrsUpdate(conn))
|
||||||
res = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
else
|
else
|
||||||
res = Curl_speedcheck(data, now);
|
result = Curl_speedcheck(data, now);
|
||||||
}
|
}
|
||||||
if(!res && Curl_pgrsUpdate(conn))
|
if(!result && Curl_pgrsUpdate(conn))
|
||||||
res = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -425,7 +425,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
|
||||||
are supported. This means that files on remotely mounted directories
|
are supported. This means that files on remotely mounted directories
|
||||||
(via NFS, Samba, NT sharing) can be accessed through a file:// URL
|
(via NFS, Samba, NT sharing) can be accessed through a file:// URL
|
||||||
*/
|
*/
|
||||||
CURLcode res = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
struct_stat statbuf; /* struct_stat instead of struct stat just to allow the
|
struct_stat statbuf; /* struct_stat instead of struct stat just to allow the
|
||||||
Windows version to have a different struct without
|
Windows version to have a different struct without
|
||||||
having to redefine the simple word 'stat' */
|
having to redefine the simple word 'stat' */
|
||||||
|
@ -472,7 +472,6 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
|
||||||
information. Which for FILE can't be much more than the file size and
|
information. Which for FILE can't be much more than the file size and
|
||||||
date. */
|
date. */
|
||||||
if(data->set.opt_no_body && data->set.include_header && fstated) {
|
if(data->set.opt_no_body && data->set.include_header && fstated) {
|
||||||
CURLcode result;
|
|
||||||
snprintf(buf, sizeof(data->state.buffer),
|
snprintf(buf, sizeof(data->state.buffer),
|
||||||
"Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n", expected_size);
|
"Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n", expected_size);
|
||||||
result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
|
result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
|
||||||
|
@ -554,7 +553,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
|
||||||
|
|
||||||
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
|
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
|
||||||
|
|
||||||
while(res == CURLE_OK) {
|
while(!result) {
|
||||||
/* Don't fill a whole buffer if we want less than all data */
|
/* Don't fill a whole buffer if we want less than all data */
|
||||||
size_t bytestoread =
|
size_t bytestoread =
|
||||||
(expected_size < CURL_OFF_T_C(BUFSIZE) - CURL_OFF_T_C(1)) ?
|
(expected_size < CURL_OFF_T_C(BUFSIZE) - CURL_OFF_T_C(1)) ?
|
||||||
|
@ -571,21 +570,21 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
|
||||||
bytecount += nread;
|
bytecount += nread;
|
||||||
expected_size -= nread;
|
expected_size -= nread;
|
||||||
|
|
||||||
res = Curl_client_write(conn, CLIENTWRITE_BODY, buf, nread);
|
result = Curl_client_write(conn, CLIENTWRITE_BODY, buf, nread);
|
||||||
if(res)
|
if(result)
|
||||||
return res;
|
return result;
|
||||||
|
|
||||||
Curl_pgrsSetDownloadCounter(data, bytecount);
|
Curl_pgrsSetDownloadCounter(data, bytecount);
|
||||||
|
|
||||||
if(Curl_pgrsUpdate(conn))
|
if(Curl_pgrsUpdate(conn))
|
||||||
res = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
else
|
else
|
||||||
res = Curl_speedcheck(data, now);
|
result = Curl_speedcheck(data, now);
|
||||||
}
|
}
|
||||||
if(Curl_pgrsUpdate(conn))
|
if(Curl_pgrsUpdate(conn))
|
||||||
res = CURLE_ABORTED_BY_CALLBACK;
|
result = CURLE_ABORTED_BY_CALLBACK;
|
||||||
|
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -950,13 +950,13 @@ void Curl_formclean(struct FormData **form_ptr)
|
||||||
int curl_formget(struct curl_httppost *form, void *arg,
|
int curl_formget(struct curl_httppost *form, void *arg,
|
||||||
curl_formget_callback append)
|
curl_formget_callback append)
|
||||||
{
|
{
|
||||||
CURLcode rc;
|
CURLcode result;
|
||||||
curl_off_t size;
|
curl_off_t size;
|
||||||
struct FormData *data, *ptr;
|
struct FormData *data, *ptr;
|
||||||
|
|
||||||
rc = Curl_getformdata(NULL, &data, form, NULL, &size);
|
result = Curl_getformdata(NULL, &data, form, NULL, &size);
|
||||||
if(rc != CURLE_OK)
|
if(result)
|
||||||
return (int)rc;
|
return (int)result;
|
||||||
|
|
||||||
for(ptr = data; ptr; ptr = ptr->next) {
|
for(ptr = data; ptr; ptr = ptr->next) {
|
||||||
if((ptr->type == FORM_FILE) || (ptr->type == FORM_CALLBACK)) {
|
if((ptr->type == FORM_FILE) || (ptr->type == FORM_CALLBACK)) {
|
||||||
|
@ -1365,10 +1365,8 @@ CURLcode Curl_getformdata(struct SessionHandle *data,
|
||||||
} while((post = post->next) != NULL); /* for each field */
|
} while((post = post->next) != NULL); /* for each field */
|
||||||
|
|
||||||
/* end-boundary for everything */
|
/* end-boundary for everything */
|
||||||
if(CURLE_OK == result)
|
if(!result)
|
||||||
result = AddFormDataf(&form, &size,
|
result = AddFormDataf(&form, &size, "\r\n--%s--\r\n", boundary);
|
||||||
"\r\n--%s--\r\n",
|
|
||||||
boundary);
|
|
||||||
|
|
||||||
if(result) {
|
if(result) {
|
||||||
Curl_formclean(&firstform);
|
Curl_formclean(&firstform);
|
||||||
|
|
115
lib/ftp.c
115
lib/ftp.c
|
@ -157,7 +157,7 @@ static CURLcode ftp_dophase_done(struct connectdata *conn,
|
||||||
bool connected);
|
bool connected);
|
||||||
|
|
||||||
/* easy-to-use macro: */
|
/* easy-to-use macro: */
|
||||||
#define PPSENDF(x,y,z) if((result = Curl_pp_sendf(x,y,z)) != CURLE_OK) \
|
#define PPSENDF(x,y,z) if((result = Curl_pp_sendf(x,y,z))) \
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@ -541,7 +541,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn, bool *connected)
|
||||||
{
|
{
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
long timeout_ms;
|
long timeout_ms;
|
||||||
CURLcode ret = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
|
|
||||||
*connected = FALSE;
|
*connected = FALSE;
|
||||||
infof(data, "Preparing for accepting server on data port\n");
|
infof(data, "Preparing for accepting server on data port\n");
|
||||||
|
@ -557,22 +557,22 @@ static CURLcode AllowServerConnect(struct connectdata *conn, bool *connected)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* see if the connection request is already here */
|
/* see if the connection request is already here */
|
||||||
ret = ReceivedServerConnect(conn, connected);
|
result = ReceivedServerConnect(conn, connected);
|
||||||
if(ret)
|
if(result)
|
||||||
return ret;
|
return result;
|
||||||
|
|
||||||
if(*connected) {
|
if(*connected) {
|
||||||
ret = AcceptServerConnect(conn);
|
result = AcceptServerConnect(conn);
|
||||||
if(ret)
|
if(result)
|
||||||
return ret;
|
return result;
|
||||||
|
|
||||||
ret = InitiateTransfer(conn);
|
result = InitiateTransfer(conn);
|
||||||
if(ret)
|
if(result)
|
||||||
return ret;
|
return result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Add timeout to multi handle and break out of the loop */
|
/* Add timeout to multi handle and break out of the loop */
|
||||||
if(ret == CURLE_OK && *connected == FALSE) {
|
if(!result && *connected == FALSE) {
|
||||||
if(data->set.accepttimeout > 0)
|
if(data->set.accepttimeout > 0)
|
||||||
Curl_expire(data, data->set.accepttimeout);
|
Curl_expire(data, data->set.accepttimeout);
|
||||||
else
|
else
|
||||||
|
@ -580,7 +580,7 @@ static CURLcode AllowServerConnect(struct connectdata *conn, bool *connected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* macro to check for a three-digit ftp status code at the start of the
|
/* macro to check for a three-digit ftp status code at the start of the
|
||||||
|
@ -1529,7 +1529,7 @@ static CURLcode ftp_state_list(struct connectdata *conn)
|
||||||
|
|
||||||
free(cmd);
|
free(cmd);
|
||||||
|
|
||||||
if(result != CURLE_OK)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
state(conn, FTP_LIST);
|
state(conn, FTP_LIST);
|
||||||
|
@ -2714,7 +2714,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
|
||||||
set a valid level */
|
set a valid level */
|
||||||
Curl_sec_request_prot(conn, data->set.str[STRING_KRB_LEVEL]);
|
Curl_sec_request_prot(conn, data->set.str[STRING_KRB_LEVEL]);
|
||||||
|
|
||||||
if(Curl_sec_login(conn) != CURLE_OK)
|
if(Curl_sec_login(conn))
|
||||||
infof(data, "Logging in with password in cleartext!\n");
|
infof(data, "Logging in with password in cleartext!\n");
|
||||||
else
|
else
|
||||||
infof(data, "Authentication successful\n");
|
infof(data, "Authentication successful\n");
|
||||||
|
@ -2765,7 +2765,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
|
||||||
if((ftpcode == 234) || (ftpcode == 334)) {
|
if((ftpcode == 234) || (ftpcode == 334)) {
|
||||||
/* Curl_ssl_connect is BLOCKING */
|
/* Curl_ssl_connect is BLOCKING */
|
||||||
result = Curl_ssl_connect(conn, FIRSTSOCKET);
|
result = Curl_ssl_connect(conn, FIRSTSOCKET);
|
||||||
if(CURLE_OK == result) {
|
if(!result) {
|
||||||
conn->ssl[SECONDARYSOCKET].use = FALSE; /* clear-text data */
|
conn->ssl[SECONDARYSOCKET].use = FALSE; /* clear-text data */
|
||||||
result = ftp_state_user(conn);
|
result = ftp_state_user(conn);
|
||||||
}
|
}
|
||||||
|
@ -2907,7 +2907,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
|
||||||
if(!ftpc->server_os && dir[0] != '/') {
|
if(!ftpc->server_os && dir[0] != '/') {
|
||||||
|
|
||||||
result = Curl_pp_sendf(&ftpc->pp, "%s", "SYST");
|
result = Curl_pp_sendf(&ftpc->pp, "%s", "SYST");
|
||||||
if(result != CURLE_OK) {
|
if(result) {
|
||||||
free(dir);
|
free(dir);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -2960,7 +2960,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
|
||||||
if(strequal(os, "OS/400")) {
|
if(strequal(os, "OS/400")) {
|
||||||
/* Force OS400 name format 1. */
|
/* Force OS400 name format 1. */
|
||||||
result = Curl_pp_sendf(&ftpc->pp, "%s", "SITE NAMEFMT 1");
|
result = Curl_pp_sendf(&ftpc->pp, "%s", "SITE NAMEFMT 1");
|
||||||
if(result != CURLE_OK) {
|
if(result) {
|
||||||
free(os);
|
free(os);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -3736,7 +3736,7 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((result == CURLE_OK) && (ftp->transfer != FTPTRANSFER_BODY))
|
if(!result && (ftp->transfer != FTPTRANSFER_BODY))
|
||||||
/* no data to transfer. FIX: it feels like a kludge to have this here
|
/* no data to transfer. FIX: it feels like a kludge to have this here
|
||||||
too! */
|
too! */
|
||||||
Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
|
Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
|
||||||
|
@ -3809,7 +3809,7 @@ static CURLcode init_wc_data(struct connectdata *conn)
|
||||||
char *last_slash;
|
char *last_slash;
|
||||||
char *path = conn->data->state.path;
|
char *path = conn->data->state.path;
|
||||||
struct WildcardData *wildcard = &(conn->data->wildcard);
|
struct WildcardData *wildcard = &(conn->data->wildcard);
|
||||||
CURLcode ret = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
struct ftp_wc_tmpdata *ftp_tmp;
|
struct ftp_wc_tmpdata *ftp_tmp;
|
||||||
|
|
||||||
last_slash = strrchr(conn->data->state.path, '/');
|
last_slash = strrchr(conn->data->state.path, '/');
|
||||||
|
@ -3817,8 +3817,8 @@ static CURLcode init_wc_data(struct connectdata *conn)
|
||||||
last_slash++;
|
last_slash++;
|
||||||
if(last_slash[0] == '\0') {
|
if(last_slash[0] == '\0') {
|
||||||
wildcard->state = CURLWC_CLEAN;
|
wildcard->state = CURLWC_CLEAN;
|
||||||
ret = ftp_parse_url_path(conn);
|
result = ftp_parse_url_path(conn);
|
||||||
return ret;
|
return result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wildcard->pattern = strdup(last_slash);
|
wildcard->pattern = strdup(last_slash);
|
||||||
|
@ -3836,8 +3836,8 @@ static CURLcode init_wc_data(struct connectdata *conn)
|
||||||
}
|
}
|
||||||
else { /* only list */
|
else { /* only list */
|
||||||
wildcard->state = CURLWC_CLEAN;
|
wildcard->state = CURLWC_CLEAN;
|
||||||
ret = ftp_parse_url_path(conn);
|
result = ftp_parse_url_path(conn);
|
||||||
return ret;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3867,13 +3867,13 @@ static CURLcode init_wc_data(struct connectdata *conn)
|
||||||
conn->data->set.ftp_filemethod = FTPFILE_MULTICWD;
|
conn->data->set.ftp_filemethod = FTPFILE_MULTICWD;
|
||||||
|
|
||||||
/* try to parse ftp url */
|
/* try to parse ftp url */
|
||||||
ret = ftp_parse_url_path(conn);
|
result = ftp_parse_url_path(conn);
|
||||||
if(ret) {
|
if(result) {
|
||||||
Curl_safefree(wildcard->pattern);
|
Curl_safefree(wildcard->pattern);
|
||||||
wildcard->tmp_dtor(wildcard->tmp);
|
wildcard->tmp_dtor(wildcard->tmp);
|
||||||
wildcard->tmp_dtor = ZERO_NULL;
|
wildcard->tmp_dtor = ZERO_NULL;
|
||||||
wildcard->tmp = NULL;
|
wildcard->tmp = NULL;
|
||||||
return ret;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
wildcard->path = strdup(conn->data->state.path);
|
wildcard->path = strdup(conn->data->state.path);
|
||||||
|
@ -3902,16 +3902,16 @@ static CURLcode init_wc_data(struct connectdata *conn)
|
||||||
static CURLcode wc_statemach(struct connectdata *conn)
|
static CURLcode wc_statemach(struct connectdata *conn)
|
||||||
{
|
{
|
||||||
struct WildcardData * const wildcard = &(conn->data->wildcard);
|
struct WildcardData * const wildcard = &(conn->data->wildcard);
|
||||||
CURLcode ret = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
|
|
||||||
switch (wildcard->state) {
|
switch (wildcard->state) {
|
||||||
case CURLWC_INIT:
|
case CURLWC_INIT:
|
||||||
ret = init_wc_data(conn);
|
result = init_wc_data(conn);
|
||||||
if(wildcard->state == CURLWC_CLEAN)
|
if(wildcard->state == CURLWC_CLEAN)
|
||||||
/* only listing! */
|
/* only listing! */
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
wildcard->state = ret ? CURLWC_ERROR : CURLWC_MATCHING;
|
wildcard->state = result ? CURLWC_ERROR : CURLWC_MATCHING;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURLWC_MATCHING: {
|
case CURLWC_MATCHING: {
|
||||||
|
@ -3975,10 +3975,9 @@ static CURLcode wc_statemach(struct connectdata *conn)
|
||||||
if(finfo->flags & CURLFINFOFLAG_KNOWN_SIZE)
|
if(finfo->flags & CURLFINFOFLAG_KNOWN_SIZE)
|
||||||
ftpc->known_filesize = finfo->size;
|
ftpc->known_filesize = finfo->size;
|
||||||
|
|
||||||
ret = ftp_parse_url_path(conn);
|
result = ftp_parse_url_path(conn);
|
||||||
if(ret) {
|
if(result)
|
||||||
return ret;
|
return result;
|
||||||
}
|
|
||||||
|
|
||||||
/* we don't need the Curl_fileinfo of first file anymore */
|
/* we don't need the Curl_fileinfo of first file anymore */
|
||||||
Curl_llist_remove(wildcard->filelist, wildcard->filelist->head, NULL);
|
Curl_llist_remove(wildcard->filelist, wildcard->filelist->head, NULL);
|
||||||
|
@ -4002,11 +4001,11 @@ static CURLcode wc_statemach(struct connectdata *conn)
|
||||||
|
|
||||||
case CURLWC_CLEAN: {
|
case CURLWC_CLEAN: {
|
||||||
struct ftp_wc_tmpdata *ftp_tmp = wildcard->tmp;
|
struct ftp_wc_tmpdata *ftp_tmp = wildcard->tmp;
|
||||||
ret = CURLE_OK;
|
result = CURLE_OK;
|
||||||
if(ftp_tmp) {
|
if(ftp_tmp)
|
||||||
ret = Curl_ftp_parselist_geterror(ftp_tmp->parser);
|
result = Curl_ftp_parselist_geterror(ftp_tmp->parser);
|
||||||
}
|
|
||||||
wildcard->state = ret ? CURLWC_ERROR : CURLWC_DONE;
|
wildcard->state = result ? CURLWC_ERROR : CURLWC_DONE;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case CURLWC_DONE:
|
case CURLWC_DONE:
|
||||||
|
@ -4014,7 +4013,7 @@ static CURLcode wc_statemach(struct connectdata *conn)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -4028,31 +4027,31 @@ static CURLcode wc_statemach(struct connectdata *conn)
|
||||||
*/
|
*/
|
||||||
static CURLcode ftp_do(struct connectdata *conn, bool *done)
|
static CURLcode ftp_do(struct connectdata *conn, bool *done)
|
||||||
{
|
{
|
||||||
CURLcode retcode = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
struct ftp_conn *ftpc = &conn->proto.ftpc;
|
||||||
|
|
||||||
*done = FALSE; /* default to false */
|
*done = FALSE; /* default to false */
|
||||||
ftpc->wait_data_conn = FALSE; /* default to no such wait */
|
ftpc->wait_data_conn = FALSE; /* default to no such wait */
|
||||||
|
|
||||||
if(conn->data->set.wildcardmatch) {
|
if(conn->data->set.wildcardmatch) {
|
||||||
retcode = wc_statemach(conn);
|
result = wc_statemach(conn);
|
||||||
if(conn->data->wildcard.state == CURLWC_SKIP ||
|
if(conn->data->wildcard.state == CURLWC_SKIP ||
|
||||||
conn->data->wildcard.state == CURLWC_DONE) {
|
conn->data->wildcard.state == CURLWC_DONE) {
|
||||||
/* do not call ftp_regular_transfer */
|
/* do not call ftp_regular_transfer */
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
if(retcode) /* error, loop or skipping the file */
|
if(result) /* error, loop or skipping the file */
|
||||||
return retcode;
|
return result;
|
||||||
}
|
}
|
||||||
else { /* no wildcard FSM needed */
|
else { /* no wildcard FSM needed */
|
||||||
retcode = ftp_parse_url_path(conn);
|
result = ftp_parse_url_path(conn);
|
||||||
if(retcode)
|
if(result)
|
||||||
return retcode;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = ftp_regular_transfer(conn, done);
|
result = ftp_regular_transfer(conn, done);
|
||||||
|
|
||||||
return retcode;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4064,7 +4063,7 @@ CURLcode Curl_ftpsendf(struct connectdata *conn,
|
||||||
char s[SBUF_SIZE];
|
char s[SBUF_SIZE];
|
||||||
size_t write_len;
|
size_t write_len;
|
||||||
char *sptr=s;
|
char *sptr=s;
|
||||||
CURLcode res = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
#ifdef HAVE_GSSAPI
|
#ifdef HAVE_GSSAPI
|
||||||
enum protection_level data_sec = conn->data_prot;
|
enum protection_level data_sec = conn->data_prot;
|
||||||
#endif
|
#endif
|
||||||
|
@ -4079,23 +4078,23 @@ CURLcode Curl_ftpsendf(struct connectdata *conn,
|
||||||
|
|
||||||
bytes_written=0;
|
bytes_written=0;
|
||||||
|
|
||||||
res = Curl_convert_to_network(conn->data, s, write_len);
|
result = Curl_convert_to_network(conn->data, s, write_len);
|
||||||
/* Curl_convert_to_network calls failf if unsuccessful */
|
/* Curl_convert_to_network calls failf if unsuccessful */
|
||||||
if(res)
|
if(result)
|
||||||
return(res);
|
return(result);
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
#ifdef HAVE_GSSAPI
|
#ifdef HAVE_GSSAPI
|
||||||
conn->data_prot = PROT_CMD;
|
conn->data_prot = PROT_CMD;
|
||||||
#endif
|
#endif
|
||||||
res = Curl_write(conn, conn->sock[FIRSTSOCKET], sptr, write_len,
|
result = Curl_write(conn, conn->sock[FIRSTSOCKET], sptr, write_len,
|
||||||
&bytes_written);
|
&bytes_written);
|
||||||
#ifdef HAVE_GSSAPI
|
#ifdef HAVE_GSSAPI
|
||||||
DEBUGASSERT(data_sec > PROT_NONE && data_sec < PROT_LAST);
|
DEBUGASSERT(data_sec > PROT_NONE && data_sec < PROT_LAST);
|
||||||
conn->data_prot = data_sec;
|
conn->data_prot = data_sec;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(CURLE_OK != res)
|
if(result)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(conn->data->set.verbose)
|
if(conn->data->set.verbose)
|
||||||
|
@ -4110,7 +4109,7 @@ CURLcode Curl_ftpsendf(struct connectdata *conn,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -4479,7 +4478,7 @@ CURLcode ftp_regular_transfer(struct connectdata *conn,
|
||||||
&connected, /* have we connected after PASV/PORT */
|
&connected, /* have we connected after PASV/PORT */
|
||||||
dophase_done); /* all commands in the DO-phase done? */
|
dophase_done); /* all commands in the DO-phase done? */
|
||||||
|
|
||||||
if(CURLE_OK == result) {
|
if(!result) {
|
||||||
|
|
||||||
if(!*dophase_done)
|
if(!*dophase_done)
|
||||||
/* the DO phase has not completed yet */
|
/* the DO phase has not completed yet */
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
|
@ -121,7 +121,7 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
result = Curl_write(conn, sockfd, sel, k, &amount);
|
result = Curl_write(conn, sockfd, sel, k, &amount);
|
||||||
if(CURLE_OK == result) { /* Which may not have written it all! */
|
if(!result) { /* Which may not have written it all! */
|
||||||
result = Curl_client_write(conn, CLIENTWRITE_HEADER, sel, amount);
|
result = Curl_client_write(conn, CLIENTWRITE_HEADER, sel, amount);
|
||||||
if(result) {
|
if(result) {
|
||||||
Curl_safefree(sel_org);
|
Curl_safefree(sel_org);
|
||||||
|
@ -154,7 +154,7 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
|
||||||
/* We can use Curl_sendf to send the terminal \r\n relatively safely and
|
/* We can use Curl_sendf to send the terminal \r\n relatively safely and
|
||||||
save allocing another string/doing another _write loop. */
|
save allocing another string/doing another _write loop. */
|
||||||
result = Curl_sendf(sockfd, conn, "\r\n");
|
result = Curl_sendf(sockfd, conn, "\r\n");
|
||||||
if(result != CURLE_OK) {
|
if(result) {
|
||||||
failf(data, "Failed sending Gopher request");
|
failf(data, "Failed sending Gopher request");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
69
lib/http.c
69
lib/http.c
|
@ -279,7 +279,7 @@ static CURLcode http_output_basic(struct connectdata *conn, bool proxy)
|
||||||
char **userp;
|
char **userp;
|
||||||
const char *user;
|
const char *user;
|
||||||
const char *pwd;
|
const char *pwd;
|
||||||
CURLcode error;
|
CURLcode result;
|
||||||
|
|
||||||
if(proxy) {
|
if(proxy) {
|
||||||
userp = &conn->allocptr.proxyuserpwd;
|
userp = &conn->allocptr.proxyuserpwd;
|
||||||
|
@ -294,11 +294,11 @@ static CURLcode http_output_basic(struct connectdata *conn, bool proxy)
|
||||||
|
|
||||||
snprintf(data->state.buffer, sizeof(data->state.buffer), "%s:%s", user, pwd);
|
snprintf(data->state.buffer, sizeof(data->state.buffer), "%s:%s", user, pwd);
|
||||||
|
|
||||||
error = Curl_base64_encode(data,
|
result = Curl_base64_encode(data,
|
||||||
data->state.buffer, strlen(data->state.buffer),
|
data->state.buffer, strlen(data->state.buffer),
|
||||||
&authorization, &size);
|
&authorization, &size);
|
||||||
if(error)
|
if(result)
|
||||||
return error;
|
return result;
|
||||||
|
|
||||||
if(!authorization)
|
if(!authorization)
|
||||||
return CURLE_REMOTE_ACCESS_DENIED;
|
return CURLE_REMOTE_ACCESS_DENIED;
|
||||||
|
@ -476,7 +476,7 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
bool pickhost = FALSE;
|
bool pickhost = FALSE;
|
||||||
bool pickproxy = FALSE;
|
bool pickproxy = FALSE;
|
||||||
CURLcode code = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
|
|
||||||
if(100 <= data->req.httpcode && 199 >= data->req.httpcode)
|
if(100 <= data->req.httpcode && 199 >= data->req.httpcode)
|
||||||
/* this is a transient response code, ignore */
|
/* this is a transient response code, ignore */
|
||||||
|
@ -512,9 +512,9 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
|
||||||
if((data->set.httpreq != HTTPREQ_GET) &&
|
if((data->set.httpreq != HTTPREQ_GET) &&
|
||||||
(data->set.httpreq != HTTPREQ_HEAD) &&
|
(data->set.httpreq != HTTPREQ_HEAD) &&
|
||||||
!conn->bits.rewindaftersend) {
|
!conn->bits.rewindaftersend) {
|
||||||
code = http_perhapsrewind(conn);
|
result = http_perhapsrewind(conn);
|
||||||
if(code)
|
if(result)
|
||||||
return code;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,10 +536,10 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
|
||||||
if(http_should_fail(conn)) {
|
if(http_should_fail(conn)) {
|
||||||
failf (data, "The requested URL returned error: %d",
|
failf (data, "The requested URL returned error: %d",
|
||||||
data->req.httpcode);
|
data->req.httpcode);
|
||||||
code = CURLE_HTTP_RETURNED_ERROR;
|
result = CURLE_HTTP_RETURNED_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -804,9 +804,8 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy,
|
||||||
if(authp->picked == CURLAUTH_NTLM ||
|
if(authp->picked == CURLAUTH_NTLM ||
|
||||||
authp->picked == CURLAUTH_NTLM_WB) {
|
authp->picked == CURLAUTH_NTLM_WB) {
|
||||||
/* NTLM authentication is picked and activated */
|
/* NTLM authentication is picked and activated */
|
||||||
CURLcode ntlm =
|
CURLcode result = Curl_input_ntlm(conn, proxy, auth);
|
||||||
Curl_input_ntlm(conn, proxy, auth);
|
if(!result) {
|
||||||
if(CURLE_OK == ntlm) {
|
|
||||||
data->state.authproblem = FALSE;
|
data->state.authproblem = FALSE;
|
||||||
#ifdef NTLM_WB_ENABLED
|
#ifdef NTLM_WB_ENABLED
|
||||||
if(authp->picked == CURLAUTH_NTLM_WB) {
|
if(authp->picked == CURLAUTH_NTLM_WB) {
|
||||||
|
@ -1041,7 +1040,7 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
|
||||||
|
|
||||||
{
|
{
|
||||||
ssize_t amount;
|
ssize_t amount;
|
||||||
CURLcode res;
|
CURLcode result;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
size_t size;
|
size_t size;
|
||||||
struct HTTP *http = conn->data->req.protop;
|
struct HTTP *http = conn->data->req.protop;
|
||||||
|
@ -1064,14 +1063,14 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
|
||||||
|
|
||||||
DEBUGASSERT(size > included_body_bytes);
|
DEBUGASSERT(size > included_body_bytes);
|
||||||
|
|
||||||
res = Curl_convert_to_network(conn->data, ptr, headersize);
|
result = Curl_convert_to_network(conn->data, ptr, headersize);
|
||||||
/* Curl_convert_to_network calls failf if unsuccessful */
|
/* Curl_convert_to_network calls failf if unsuccessful */
|
||||||
if(res) {
|
if(result) {
|
||||||
/* conversion failed, free memory and return to the caller */
|
/* conversion failed, free memory and return to the caller */
|
||||||
if(in->buffer)
|
if(in->buffer)
|
||||||
free(in->buffer);
|
free(in->buffer);
|
||||||
free(in);
|
free(in);
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1096,9 +1095,9 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
|
||||||
else
|
else
|
||||||
sendsize = size;
|
sendsize = size;
|
||||||
|
|
||||||
res = Curl_write(conn, sockfd, ptr, sendsize, &amount);
|
result = Curl_write(conn, sockfd, ptr, sendsize, &amount);
|
||||||
|
|
||||||
if(CURLE_OK == res) {
|
if(!result) {
|
||||||
/*
|
/*
|
||||||
* Note that we may not send the entire chunk at once, and we have a set
|
* Note that we may not send the entire chunk at once, and we have a set
|
||||||
* number of data bytes at the end of the big buffer (out of which we may
|
* number of data bytes at the end of the big buffer (out of which we may
|
||||||
|
@ -1176,7 +1175,7 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
|
||||||
free(in->buffer);
|
free(in->buffer);
|
||||||
free(in);
|
free(in);
|
||||||
|
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1468,8 +1467,8 @@ CURLcode Curl_http_done(struct connectdata *conn,
|
||||||
else if(HTTPREQ_PUT == data->set.httpreq)
|
else if(HTTPREQ_PUT == data->set.httpreq)
|
||||||
data->req.bytecount = http->readbytecount + http->writebytecount;
|
data->req.bytecount = http->readbytecount + http->writebytecount;
|
||||||
|
|
||||||
if(status != CURLE_OK)
|
if(status)
|
||||||
return (status);
|
return status;
|
||||||
|
|
||||||
if(!premature && /* this check is pointless when DONE is called before the
|
if(!premature && /* this check is pointless when DONE is called before the
|
||||||
entire operation is complete */
|
entire operation is complete */
|
||||||
|
@ -1529,7 +1528,7 @@ static CURLcode expect100(struct SessionHandle *data,
|
||||||
else {
|
else {
|
||||||
result = Curl_add_bufferf(req_buffer,
|
result = Curl_add_bufferf(req_buffer,
|
||||||
"Expect: 100-continue\r\n");
|
"Expect: 100-continue\r\n");
|
||||||
if(result == CURLE_OK)
|
if(!result)
|
||||||
data->state.expect100header = TRUE;
|
data->state.expect100header = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2320,17 +2319,16 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||||
}
|
}
|
||||||
Curl_cookie_freelist(store, FALSE); /* free the cookie list */
|
Curl_cookie_freelist(store, FALSE); /* free the cookie list */
|
||||||
}
|
}
|
||||||
if(addcookies && (CURLE_OK == result)) {
|
if(addcookies && !result) {
|
||||||
if(!count)
|
if(!count)
|
||||||
result = Curl_add_bufferf(req_buffer, "Cookie: ");
|
result = Curl_add_bufferf(req_buffer, "Cookie: ");
|
||||||
if(CURLE_OK == result) {
|
if(!result) {
|
||||||
result = Curl_add_bufferf(req_buffer, "%s%s",
|
result = Curl_add_bufferf(req_buffer, "%s%s", count?"; ":"",
|
||||||
count?"; ":"",
|
|
||||||
addcookies);
|
addcookies);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(count && (CURLE_OK == result))
|
if(count && !result)
|
||||||
result = Curl_add_buffer(req_buffer, "\r\n", 2);
|
result = Curl_add_buffer(req_buffer, "\r\n", 2);
|
||||||
|
|
||||||
if(result)
|
if(result)
|
||||||
|
@ -2582,17 +2580,16 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||||
if(postsize) {
|
if(postsize) {
|
||||||
/* Append the POST data chunky-style */
|
/* Append the POST data chunky-style */
|
||||||
result = Curl_add_bufferf(req_buffer, "%x\r\n", (int)postsize);
|
result = Curl_add_bufferf(req_buffer, "%x\r\n", (int)postsize);
|
||||||
if(CURLE_OK == result) {
|
if(!result) {
|
||||||
result = Curl_add_buffer(req_buffer, data->set.postfields,
|
result = Curl_add_buffer(req_buffer, data->set.postfields,
|
||||||
(size_t)postsize);
|
(size_t)postsize);
|
||||||
if(CURLE_OK == result)
|
if(!result)
|
||||||
result = Curl_add_buffer(req_buffer, "\r\n", 2);
|
result = Curl_add_buffer(req_buffer, "\r\n", 2);
|
||||||
included_body = postsize + 2;
|
included_body = postsize + 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(CURLE_OK == result)
|
if(!result)
|
||||||
result = Curl_add_buffer(req_buffer,
|
result = Curl_add_buffer(req_buffer, "\x30\x0d\x0a\x0d\x0a", 5);
|
||||||
"\x30\x0d\x0a\x0d\x0a", 5);
|
|
||||||
/* 0 CR LF CR LF */
|
/* 0 CR LF CR LF */
|
||||||
included_body += 5;
|
included_body += 5;
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,7 +328,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
|
||||||
*/
|
*/
|
||||||
#define CURL_OUTPUT_DIGEST_CONV(a, b) \
|
#define CURL_OUTPUT_DIGEST_CONV(a, b) \
|
||||||
rc = Curl_convert_to_network(a, (char *)b, strlen((const char*)b)); \
|
rc = Curl_convert_to_network(a, (char *)b, strlen((const char*)b)); \
|
||||||
if(rc != CURLE_OK) { \
|
if(rc) { \
|
||||||
free(b); \
|
free(b); \
|
||||||
return rc; \
|
return rc; \
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
||||||
|
|
||||||
free(host_port);
|
free(host_port);
|
||||||
|
|
||||||
if(CURLE_OK == result) {
|
if(!result) {
|
||||||
char *host=(char *)"";
|
char *host=(char *)"";
|
||||||
const char *proxyconn="";
|
const char *proxyconn="";
|
||||||
const char *useragent="";
|
const char *useragent="";
|
||||||
|
@ -197,14 +197,14 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
|
||||||
free(host);
|
free(host);
|
||||||
free(hostheader);
|
free(hostheader);
|
||||||
|
|
||||||
if(CURLE_OK == result)
|
if(!result)
|
||||||
result = Curl_add_custom_headers(conn, TRUE, req_buffer);
|
result = Curl_add_custom_headers(conn, TRUE, req_buffer);
|
||||||
|
|
||||||
if(CURLE_OK == result)
|
if(!result)
|
||||||
/* CRLF terminate the request */
|
/* CRLF terminate the request */
|
||||||
result = Curl_add_bufferf(req_buffer, "\r\n");
|
result = Curl_add_bufferf(req_buffer, "\r\n");
|
||||||
|
|
||||||
if(CURLE_OK == result) {
|
if(!result) {
|
||||||
/* Send the connect request to the proxy */
|
/* Send the connect request to the proxy */
|
||||||
/* BLOCKING */
|
/* BLOCKING */
|
||||||
result =
|
result =
|
||||||
|
|
24
lib/multi.c
24
lib/multi.c
|
@ -1024,7 +1024,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||||
/* init this transfer. */
|
/* init this transfer. */
|
||||||
data->result=Curl_pretransfer(data);
|
data->result=Curl_pretransfer(data);
|
||||||
|
|
||||||
if(CURLE_OK == data->result) {
|
if(!data->result) {
|
||||||
/* after init, go CONNECT */
|
/* after init, go CONNECT */
|
||||||
multistate(data, CURLM_STATE_CONNECT);
|
multistate(data, CURLM_STATE_CONNECT);
|
||||||
Curl_pgrsTime(data, TIMER_STARTOP);
|
Curl_pgrsTime(data, TIMER_STARTOP);
|
||||||
|
@ -1055,7 +1055,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CURLE_OK == data->result) {
|
if(!data->result) {
|
||||||
/* Add this handle to the send or pend pipeline */
|
/* Add this handle to the send or pend pipeline */
|
||||||
data->result = Curl_add_handle_to_pipeline(data, data->easy_conn);
|
data->result = Curl_add_handle_to_pipeline(data, data->easy_conn);
|
||||||
if(CURLE_OK != data->result)
|
if(CURLE_OK != data->result)
|
||||||
|
@ -1171,7 +1171,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||||
result = CURLM_CALL_MULTI_PERFORM;
|
result = CURLM_CALL_MULTI_PERFORM;
|
||||||
multistate(data, CURLM_STATE_CONNECT);
|
multistate(data, CURLM_STATE_CONNECT);
|
||||||
}
|
}
|
||||||
else if(CURLE_OK == data->result) {
|
else if(!data->result) {
|
||||||
if(data->easy_conn->tunnel_state[FIRSTSOCKET] == TUNNEL_COMPLETE)
|
if(data->easy_conn->tunnel_state[FIRSTSOCKET] == TUNNEL_COMPLETE)
|
||||||
multistate(data, CURLM_STATE_WAITCONNECT);
|
multistate(data, CURLM_STATE_WAITCONNECT);
|
||||||
}
|
}
|
||||||
|
@ -1235,7 +1235,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||||
/* protocol-specific connect phase */
|
/* protocol-specific connect phase */
|
||||||
data->result = Curl_protocol_connecting(data->easy_conn,
|
data->result = Curl_protocol_connecting(data->easy_conn,
|
||||||
&protocol_connect);
|
&protocol_connect);
|
||||||
if((data->result == CURLE_OK) && protocol_connect) {
|
if(!data->result && protocol_connect) {
|
||||||
/* after the connect has completed, go WAITDO or DO */
|
/* after the connect has completed, go WAITDO or DO */
|
||||||
multistate(data, multi->pipelining_enabled?
|
multistate(data, multi->pipelining_enabled?
|
||||||
CURLM_STATE_WAITDO:CURLM_STATE_DO);
|
CURLM_STATE_WAITDO:CURLM_STATE_DO);
|
||||||
|
@ -1283,7 +1283,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||||
|
|
||||||
/* When Curl_do() returns failure, data->easy_conn might be NULL! */
|
/* When Curl_do() returns failure, data->easy_conn might be NULL! */
|
||||||
|
|
||||||
if(CURLE_OK == data->result) {
|
if(!data->result) {
|
||||||
if(!dophase_done) {
|
if(!dophase_done) {
|
||||||
/* some steps needed for wildcard matching */
|
/* some steps needed for wildcard matching */
|
||||||
if(data->set.wildcardmatch) {
|
if(data->set.wildcardmatch) {
|
||||||
|
@ -1342,10 +1342,10 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||||
/* When set to retry the connection, we must to go back to
|
/* When set to retry the connection, we must to go back to
|
||||||
* the CONNECT state */
|
* the CONNECT state */
|
||||||
if(retry) {
|
if(retry) {
|
||||||
if((drc == CURLE_OK) || (drc == CURLE_SEND_ERROR)) {
|
if(!drc || (drc == CURLE_SEND_ERROR)) {
|
||||||
follow = FOLLOW_RETRY;
|
follow = FOLLOW_RETRY;
|
||||||
drc = Curl_follow(data, newurl, follow);
|
drc = Curl_follow(data, newurl, follow);
|
||||||
if(drc == CURLE_OK) {
|
if(!drc) {
|
||||||
multistate(data, CURLM_STATE_CONNECT);
|
multistate(data, CURLM_STATE_CONNECT);
|
||||||
result = CURLM_CALL_MULTI_PERFORM;
|
result = CURLM_CALL_MULTI_PERFORM;
|
||||||
data->result = CURLE_OK;
|
data->result = CURLE_OK;
|
||||||
|
@ -1382,7 +1382,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||||
/* we continue DOING until the DO phase is complete */
|
/* we continue DOING until the DO phase is complete */
|
||||||
data->result = Curl_protocol_doing(data->easy_conn,
|
data->result = Curl_protocol_doing(data->easy_conn,
|
||||||
&dophase_done);
|
&dophase_done);
|
||||||
if(CURLE_OK == data->result) {
|
if(!data->result) {
|
||||||
if(dophase_done) {
|
if(dophase_done) {
|
||||||
/* after DO, go DO_DONE or DO_MORE */
|
/* after DO, go DO_DONE or DO_MORE */
|
||||||
multistate(data, data->easy_conn->bits.do_more?
|
multistate(data, data->easy_conn->bits.do_more?
|
||||||
|
@ -1407,7 +1407,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||||
|
|
||||||
/* No need to remove this handle from the send pipeline here since that
|
/* No need to remove this handle from the send pipeline here since that
|
||||||
is done in Curl_done() */
|
is done in Curl_done() */
|
||||||
if(CURLE_OK == data->result) {
|
if(!data->result) {
|
||||||
if(control) {
|
if(control) {
|
||||||
/* if positive, advance to DO_DONE
|
/* if positive, advance to DO_DONE
|
||||||
if negative, go back to DOING */
|
if negative, go back to DOING */
|
||||||
|
@ -1595,9 +1595,9 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||||
else
|
else
|
||||||
follow = FOLLOW_RETRY;
|
follow = FOLLOW_RETRY;
|
||||||
data->result = Curl_done(&data->easy_conn, CURLE_OK, FALSE);
|
data->result = Curl_done(&data->easy_conn, CURLE_OK, FALSE);
|
||||||
if(CURLE_OK == data->result) {
|
if(!data->result) {
|
||||||
data->result = Curl_follow(data, newurl, follow);
|
data->result = Curl_follow(data, newurl, follow);
|
||||||
if(CURLE_OK == data->result) {
|
if(!data->result) {
|
||||||
multistate(data, CURLM_STATE_CONNECT);
|
multistate(data, CURLM_STATE_CONNECT);
|
||||||
result = CURLM_CALL_MULTI_PERFORM;
|
result = CURLM_CALL_MULTI_PERFORM;
|
||||||
newurl = NULL; /* handed over the memory ownership to
|
newurl = NULL; /* handed over the memory ownership to
|
||||||
|
@ -1617,7 +1617,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
||||||
newurl = data->req.location;
|
newurl = data->req.location;
|
||||||
data->req.location = NULL;
|
data->req.location = NULL;
|
||||||
data->result = Curl_follow(data, newurl, FOLLOW_FAKE);
|
data->result = Curl_follow(data, newurl, FOLLOW_FAKE);
|
||||||
if(CURLE_OK == data->result)
|
if(!data->result)
|
||||||
newurl = NULL; /* allocation was handed over Curl_follow() */
|
newurl = NULL; /* allocation was handed over Curl_follow() */
|
||||||
else
|
else
|
||||||
disconnect_conn = TRUE;
|
disconnect_conn = TRUE;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
|
@ -87,7 +87,7 @@ CURLcode Curl_convert_to_network(struct SessionHandle *data,
|
||||||
if(data->set.convtonetwork) {
|
if(data->set.convtonetwork) {
|
||||||
/* use translation callback */
|
/* use translation callback */
|
||||||
rc = data->set.convtonetwork(buffer, length);
|
rc = data->set.convtonetwork(buffer, length);
|
||||||
if(rc != CURLE_OK) {
|
if(rc) {
|
||||||
failf(data,
|
failf(data,
|
||||||
"CURLOPT_CONV_TO_NETWORK_FUNCTION callback returned %d: %s",
|
"CURLOPT_CONV_TO_NETWORK_FUNCTION callback returned %d: %s",
|
||||||
(int)rc, curl_easy_strerror(rc));
|
(int)rc, curl_easy_strerror(rc));
|
||||||
|
@ -148,7 +148,7 @@ CURLcode Curl_convert_from_network(struct SessionHandle *data,
|
||||||
if(data->set.convfromnetwork) {
|
if(data->set.convfromnetwork) {
|
||||||
/* use translation callback */
|
/* use translation callback */
|
||||||
rc = data->set.convfromnetwork(buffer, length);
|
rc = data->set.convfromnetwork(buffer, length);
|
||||||
if(rc != CURLE_OK) {
|
if(rc) {
|
||||||
failf(data,
|
failf(data,
|
||||||
"CURLOPT_CONV_FROM_NETWORK_FUNCTION callback returned %d: %s",
|
"CURLOPT_CONV_FROM_NETWORK_FUNCTION callback returned %d: %s",
|
||||||
(int)rc, curl_easy_strerror(rc));
|
(int)rc, curl_easy_strerror(rc));
|
||||||
|
@ -209,7 +209,7 @@ CURLcode Curl_convert_from_utf8(struct SessionHandle *data,
|
||||||
if(data->set.convfromutf8) {
|
if(data->set.convfromutf8) {
|
||||||
/* use translation callback */
|
/* use translation callback */
|
||||||
rc = data->set.convfromutf8(buffer, length);
|
rc = data->set.convfromutf8(buffer, length);
|
||||||
if(rc != CURLE_OK) {
|
if(rc) {
|
||||||
failf(data,
|
failf(data,
|
||||||
"CURLOPT_CONV_FROM_UTF8_FUNCTION callback returned %d: %s",
|
"CURLOPT_CONV_FROM_UTF8_FUNCTION callback returned %d: %s",
|
||||||
(int)rc, curl_easy_strerror(rc));
|
(int)rc, curl_easy_strerror(rc));
|
||||||
|
@ -333,7 +333,7 @@ CURLcode Curl_convert_form(struct SessionHandle *data, struct FormData *form)
|
||||||
if(form->type == FORM_DATA) {
|
if(form->type == FORM_DATA) {
|
||||||
rc = Curl_convert_to_network(data, form->line, form->length);
|
rc = Curl_convert_to_network(data, form->line, form->length);
|
||||||
/* Curl_convert_to_network calls failf if unsuccessful */
|
/* Curl_convert_to_network calls failf if unsuccessful */
|
||||||
if(rc != CURLE_OK)
|
if(rc)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
} while((form = next) != NULL); /* continue */
|
} while((form = next) != NULL); /* continue */
|
||||||
|
|
|
@ -165,7 +165,7 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
|
||||||
size_t write_len;
|
size_t write_len;
|
||||||
char *fmt_crlf;
|
char *fmt_crlf;
|
||||||
char *s;
|
char *s;
|
||||||
CURLcode error;
|
CURLcode result;
|
||||||
struct connectdata *conn = pp->conn;
|
struct connectdata *conn = pp->conn;
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
|
|
||||||
|
@ -191,26 +191,26 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
|
||||||
|
|
||||||
Curl_pp_init(pp);
|
Curl_pp_init(pp);
|
||||||
|
|
||||||
error = Curl_convert_to_network(data, s, write_len);
|
result = Curl_convert_to_network(data, s, write_len);
|
||||||
/* Curl_convert_to_network calls failf if unsuccessful */
|
/* Curl_convert_to_network calls failf if unsuccessful */
|
||||||
if(error) {
|
if(result) {
|
||||||
free(s);
|
free(s);
|
||||||
return error;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_GSSAPI
|
#ifdef HAVE_GSSAPI
|
||||||
conn->data_prot = PROT_CMD;
|
conn->data_prot = PROT_CMD;
|
||||||
#endif
|
#endif
|
||||||
error = Curl_write(conn, conn->sock[FIRSTSOCKET], s, write_len,
|
result = Curl_write(conn, conn->sock[FIRSTSOCKET], s, write_len,
|
||||||
&bytes_written);
|
&bytes_written);
|
||||||
#ifdef HAVE_GSSAPI
|
#ifdef HAVE_GSSAPI
|
||||||
DEBUGASSERT(data_sec > PROT_NONE && data_sec < PROT_LAST);
|
DEBUGASSERT(data_sec > PROT_NONE && data_sec < PROT_LAST);
|
||||||
conn->data_prot = data_sec;
|
conn->data_prot = data_sec;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(error) {
|
if(result) {
|
||||||
free(s);
|
free(s);
|
||||||
return error;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(conn->data->set.verbose)
|
if(conn->data->set.verbose)
|
||||||
|
@ -247,15 +247,15 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
|
||||||
CURLcode Curl_pp_sendf(struct pingpong *pp,
|
CURLcode Curl_pp_sendf(struct pingpong *pp,
|
||||||
const char *fmt, ...)
|
const char *fmt, ...)
|
||||||
{
|
{
|
||||||
CURLcode res;
|
CURLcode result;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
||||||
res = Curl_pp_vsendf(pp, fmt, ap);
|
result = Curl_pp_vsendf(pp, fmt, ap);
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -303,30 +303,28 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
|
||||||
pp->cache_size = 0; /* zero the size just in case */
|
pp->cache_size = 0; /* zero the size just in case */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int res;
|
|
||||||
#ifdef HAVE_GSSAPI
|
#ifdef HAVE_GSSAPI
|
||||||
enum protection_level prot = conn->data_prot;
|
enum protection_level prot = conn->data_prot;
|
||||||
conn->data_prot = PROT_CLEAR;
|
conn->data_prot = PROT_CLEAR;
|
||||||
#endif
|
#endif
|
||||||
DEBUGASSERT((ptr+BUFSIZE-pp->nread_resp) <= (buf+BUFSIZE+1));
|
DEBUGASSERT((ptr+BUFSIZE-pp->nread_resp) <= (buf+BUFSIZE+1));
|
||||||
res = Curl_read(conn, sockfd, ptr, BUFSIZE-pp->nread_resp,
|
result = Curl_read(conn, sockfd, ptr, BUFSIZE-pp->nread_resp,
|
||||||
&gotbytes);
|
&gotbytes);
|
||||||
#ifdef HAVE_GSSAPI
|
#ifdef HAVE_GSSAPI
|
||||||
DEBUGASSERT(prot > PROT_NONE && prot < PROT_LAST);
|
DEBUGASSERT(prot > PROT_NONE && prot < PROT_LAST);
|
||||||
conn->data_prot = prot;
|
conn->data_prot = prot;
|
||||||
#endif
|
#endif
|
||||||
if(res == CURLE_AGAIN)
|
if(result == CURLE_AGAIN)
|
||||||
return CURLE_OK; /* return */
|
return CURLE_OK; /* return */
|
||||||
|
|
||||||
if((res == CURLE_OK) && (gotbytes > 0))
|
if(!result && (gotbytes > 0))
|
||||||
/* convert from the network encoding */
|
/* convert from the network encoding */
|
||||||
res = Curl_convert_from_network(data, ptr, gotbytes);
|
result = Curl_convert_from_network(data, ptr, gotbytes);
|
||||||
/* Curl_convert_from_network calls failf if unsuccessful */
|
/* Curl_convert_from_network calls failf if unsuccessful */
|
||||||
|
|
||||||
if(CURLE_OK != res) {
|
if(result)
|
||||||
result = (CURLcode)res; /* Set outer result variable to this error. */
|
/* Set outer result variable to this error. */
|
||||||
keepon = FALSE;
|
keepon = FALSE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!keepon)
|
if(!keepon)
|
||||||
|
|
|
@ -129,11 +129,11 @@ static int ftp_send_command(struct connectdata *conn, const char *message, ...)
|
||||||
vsnprintf(print_buffer, sizeof(print_buffer), message, args);
|
vsnprintf(print_buffer, sizeof(print_buffer), message, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if(Curl_ftpsendf(conn, print_buffer) != CURLE_OK) {
|
if(Curl_ftpsendf(conn, print_buffer)) {
|
||||||
ftp_code = -1;
|
ftp_code = -1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(Curl_GetFTPResponse(&nread, conn, &ftp_code) != CURLE_OK)
|
if(Curl_GetFTPResponse(&nread, conn, &ftp_code))
|
||||||
ftp_code = -1;
|
ftp_code = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,20 +147,20 @@ static CURLcode
|
||||||
socket_read(curl_socket_t fd, void *to, size_t len)
|
socket_read(curl_socket_t fd, void *to, size_t len)
|
||||||
{
|
{
|
||||||
char *to_p = to;
|
char *to_p = to;
|
||||||
CURLcode code;
|
CURLcode result;
|
||||||
ssize_t nread;
|
ssize_t nread;
|
||||||
|
|
||||||
while(len > 0) {
|
while(len > 0) {
|
||||||
code = Curl_read_plain(fd, to_p, len, &nread);
|
result = Curl_read_plain(fd, to_p, len, &nread);
|
||||||
if(code == CURLE_OK) {
|
if(!result) {
|
||||||
len -= nread;
|
len -= nread;
|
||||||
to_p += nread;
|
to_p += nread;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* FIXME: We are doing a busy wait */
|
/* FIXME: We are doing a busy wait */
|
||||||
if(code == CURLE_AGAIN)
|
if(result == CURLE_AGAIN)
|
||||||
continue;
|
continue;
|
||||||
return code;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
@ -175,20 +175,20 @@ socket_write(struct connectdata *conn, curl_socket_t fd, const void *to,
|
||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
const char *to_p = to;
|
const char *to_p = to;
|
||||||
CURLcode code;
|
CURLcode result;
|
||||||
ssize_t written;
|
ssize_t written;
|
||||||
|
|
||||||
while(len > 0) {
|
while(len > 0) {
|
||||||
code = Curl_write_plain(conn, fd, to_p, len, &written);
|
result = Curl_write_plain(conn, fd, to_p, len, &written);
|
||||||
if(code == CURLE_OK) {
|
if(!result) {
|
||||||
len -= written;
|
len -= written;
|
||||||
to_p += written;
|
to_p += written;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* FIXME: We are doing a busy wait */
|
/* FIXME: We are doing a busy wait */
|
||||||
if(code == CURLE_AGAIN)
|
if(result == CURLE_AGAIN)
|
||||||
continue;
|
continue;
|
||||||
return code;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
@ -200,11 +200,11 @@ static CURLcode read_data(struct connectdata *conn,
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
void* tmp;
|
void* tmp;
|
||||||
CURLcode ret;
|
CURLcode result;
|
||||||
|
|
||||||
ret = socket_read(fd, &len, sizeof(len));
|
result = socket_read(fd, &len, sizeof(len));
|
||||||
if(ret != CURLE_OK)
|
if(result)
|
||||||
return ret;
|
return result;
|
||||||
|
|
||||||
len = ntohl(len);
|
len = ntohl(len);
|
||||||
tmp = realloc(buf->data, len);
|
tmp = realloc(buf->data, len);
|
||||||
|
@ -212,9 +212,9 @@ static CURLcode read_data(struct connectdata *conn,
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
buf->data = tmp;
|
buf->data = tmp;
|
||||||
ret = socket_read(fd, buf->data, len);
|
result = socket_read(fd, buf->data, len);
|
||||||
if(ret != CURLE_OK)
|
if(result)
|
||||||
return ret;
|
return result;
|
||||||
buf->size = conn->mech->decode(conn->app_data, buf->data, len,
|
buf->size = conn->mech->decode(conn->app_data, buf->data, len,
|
||||||
conn->data_prot, conn);
|
conn->data_prot, conn);
|
||||||
buf->index = 0;
|
buf->index = 0;
|
||||||
|
@ -256,7 +256,7 @@ static ssize_t sec_recv(struct connectdata *conn, int sockindex,
|
||||||
buffer += bytes_read;
|
buffer += bytes_read;
|
||||||
|
|
||||||
while(len > 0) {
|
while(len > 0) {
|
||||||
if(read_data(conn, fd, &conn->in_buffer) != CURLE_OK)
|
if(read_data(conn, fd, &conn->in_buffer))
|
||||||
return -1;
|
return -1;
|
||||||
if(conn->in_buffer.size == 0) {
|
if(conn->in_buffer.size == 0) {
|
||||||
if(bytes_read > 0)
|
if(bytes_read > 0)
|
||||||
|
|
34
lib/sendf.c
34
lib/sendf.c
|
@ -174,7 +174,7 @@ CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *conn,
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
ssize_t bytes_written;
|
ssize_t bytes_written;
|
||||||
size_t write_len;
|
size_t write_len;
|
||||||
CURLcode res = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
char *s;
|
char *s;
|
||||||
char *sptr;
|
char *sptr;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -190,9 +190,9 @@ CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *conn,
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
/* Write the buffer to the socket */
|
/* Write the buffer to the socket */
|
||||||
res = Curl_write(conn, sockfd, sptr, write_len, &bytes_written);
|
result = Curl_write(conn, sockfd, sptr, write_len, &bytes_written);
|
||||||
|
|
||||||
if(CURLE_OK != res)
|
if(result)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(data->set.verbose)
|
if(data->set.verbose)
|
||||||
|
@ -210,7 +210,7 @@ CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *conn,
|
||||||
|
|
||||||
free(s); /* free the output string */
|
free(s); /* free the output string */
|
||||||
|
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -227,10 +227,10 @@ CURLcode Curl_write(struct connectdata *conn,
|
||||||
ssize_t *written)
|
ssize_t *written)
|
||||||
{
|
{
|
||||||
ssize_t bytes_written;
|
ssize_t bytes_written;
|
||||||
CURLcode curlcode = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
int num = (sockfd == conn->sock[SECONDARYSOCKET]);
|
int num = (sockfd == conn->sock[SECONDARYSOCKET]);
|
||||||
|
|
||||||
bytes_written = conn->send[num](conn, num, mem, len, &curlcode);
|
bytes_written = conn->send[num](conn, num, mem, len, &result);
|
||||||
|
|
||||||
*written = bytes_written;
|
*written = bytes_written;
|
||||||
if(bytes_written >= 0)
|
if(bytes_written >= 0)
|
||||||
|
@ -238,7 +238,7 @@ CURLcode Curl_write(struct connectdata *conn,
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
|
||||||
/* handle CURLE_AGAIN or a send failure */
|
/* handle CURLE_AGAIN or a send failure */
|
||||||
switch(curlcode) {
|
switch(result) {
|
||||||
case CURLE_AGAIN:
|
case CURLE_AGAIN:
|
||||||
*written = 0;
|
*written = 0;
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
|
@ -249,7 +249,7 @@ CURLcode Curl_write(struct connectdata *conn,
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* we got a specific curlcode, forward it */
|
/* we got a specific curlcode, forward it */
|
||||||
return curlcode;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,14 +300,14 @@ CURLcode Curl_write_plain(struct connectdata *conn,
|
||||||
ssize_t *written)
|
ssize_t *written)
|
||||||
{
|
{
|
||||||
ssize_t bytes_written;
|
ssize_t bytes_written;
|
||||||
CURLcode retcode;
|
CURLcode result;
|
||||||
int num = (sockfd == conn->sock[SECONDARYSOCKET]);
|
int num = (sockfd == conn->sock[SECONDARYSOCKET]);
|
||||||
|
|
||||||
bytes_written = Curl_send_plain(conn, num, mem, len, &retcode);
|
bytes_written = Curl_send_plain(conn, num, mem, len, &result);
|
||||||
|
|
||||||
*written = bytes_written;
|
*written = bytes_written;
|
||||||
|
|
||||||
return retcode;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t Curl_recv_plain(struct connectdata *conn, int num, char *buf,
|
ssize_t Curl_recv_plain(struct connectdata *conn, int num, char *buf,
|
||||||
|
@ -425,10 +425,10 @@ CURLcode Curl_client_write(struct connectdata *conn,
|
||||||
if((conn->handler->protocol&PROTO_FAMILY_FTP) &&
|
if((conn->handler->protocol&PROTO_FAMILY_FTP) &&
|
||||||
conn->proto.ftpc.transfertype == 'A') {
|
conn->proto.ftpc.transfertype == 'A') {
|
||||||
/* convert from the network encoding */
|
/* convert from the network encoding */
|
||||||
CURLcode rc = Curl_convert_from_network(data, ptr, len);
|
CURLcode result = Curl_convert_from_network(data, ptr, len);
|
||||||
/* Curl_convert_from_network calls failf if unsuccessful */
|
/* Curl_convert_from_network calls failf if unsuccessful */
|
||||||
if(rc)
|
if(result)
|
||||||
return rc;
|
return result;
|
||||||
|
|
||||||
#ifdef CURL_DO_LINEEND_CONV
|
#ifdef CURL_DO_LINEEND_CONV
|
||||||
/* convert end-of-line markers */
|
/* convert end-of-line markers */
|
||||||
|
@ -525,7 +525,7 @@ CURLcode Curl_read(struct connectdata *conn, /* connection data */
|
||||||
size_t sizerequested, /* max amount to read */
|
size_t sizerequested, /* max amount to read */
|
||||||
ssize_t *n) /* amount bytes read */
|
ssize_t *n) /* amount bytes read */
|
||||||
{
|
{
|
||||||
CURLcode curlcode = CURLE_RECV_ERROR;
|
CURLcode result = CURLE_RECV_ERROR;
|
||||||
ssize_t nread = 0;
|
ssize_t nread = 0;
|
||||||
size_t bytesfromsocket = 0;
|
size_t bytesfromsocket = 0;
|
||||||
char *buffertofill = NULL;
|
char *buffertofill = NULL;
|
||||||
|
@ -564,9 +564,9 @@ CURLcode Curl_read(struct connectdata *conn, /* connection data */
|
||||||
buffertofill = buf;
|
buffertofill = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
nread = conn->recv[num](conn, num, buffertofill, bytesfromsocket, &curlcode);
|
nread = conn->recv[num](conn, num, buffertofill, bytesfromsocket, &result);
|
||||||
if(nread < 0)
|
if(nread < 0)
|
||||||
return curlcode;
|
return result;
|
||||||
|
|
||||||
if(pipelining) {
|
if(pipelining) {
|
||||||
memcpy(buf, conn->master_buffer, nread);
|
memcpy(buf, conn->master_buffer, nread);
|
||||||
|
|
24
lib/socks.c
24
lib/socks.c
|
@ -238,7 +238,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
|
||||||
code = Curl_write_plain(conn, sock, (char *)socksreq,
|
code = Curl_write_plain(conn, sock, (char *)socksreq,
|
||||||
packetsize + hostnamelen,
|
packetsize + hostnamelen,
|
||||||
&written);
|
&written);
|
||||||
if((code != CURLE_OK) || (written != packetsize + hostnamelen)) {
|
if(code || (written != packetsize + hostnamelen)) {
|
||||||
failf(data, "Failed to send SOCKS4 connect request.");
|
failf(data, "Failed to send SOCKS4 connect request.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
|
||||||
hostnamelen = (ssize_t)strlen(hostname) + 1;
|
hostnamelen = (ssize_t)strlen(hostname) + 1;
|
||||||
code = Curl_write_plain(conn, sock, (char *)hostname, hostnamelen,
|
code = Curl_write_plain(conn, sock, (char *)hostname, hostnamelen,
|
||||||
&written);
|
&written);
|
||||||
if((code != CURLE_OK) || (written != hostnamelen)) {
|
if(code || (written != hostnamelen)) {
|
||||||
failf(data, "Failed to send SOCKS4 connect request.");
|
failf(data, "Failed to send SOCKS4 connect request.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
|
||||||
/* Receive response */
|
/* Receive response */
|
||||||
result = Curl_blockread_all(conn, sock, (char *)socksreq, packetsize,
|
result = Curl_blockread_all(conn, sock, (char *)socksreq, packetsize,
|
||||||
&actualread);
|
&actualread);
|
||||||
if((result != CURLE_OK) || (actualread != packetsize)) {
|
if(result || (actualread != packetsize)) {
|
||||||
failf(data, "Failed to receive SOCKS4 connect request ack.");
|
failf(data, "Failed to receive SOCKS4 connect request ack.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
|
@ -431,7 +431,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
||||||
|
|
||||||
code = Curl_write_plain(conn, sock, (char *)socksreq, (2 + (int)socksreq[1]),
|
code = Curl_write_plain(conn, sock, (char *)socksreq, (2 + (int)socksreq[1]),
|
||||||
&written);
|
&written);
|
||||||
if((code != CURLE_OK) || (written != (2 + (int)socksreq[1]))) {
|
if(code || (written != (2 + (int)socksreq[1]))) {
|
||||||
failf(data, "Unable to send initial SOCKS5 request.");
|
failf(data, "Unable to send initial SOCKS5 request.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
|
@ -457,7 +457,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
||||||
(void)curlx_nonblock(sock, FALSE);
|
(void)curlx_nonblock(sock, FALSE);
|
||||||
|
|
||||||
result=Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread);
|
result=Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread);
|
||||||
if((result != CURLE_OK) || (actualread != 2)) {
|
if(result || (actualread != 2)) {
|
||||||
failf(data, "Unable to receive initial SOCKS5 response.");
|
failf(data, "Unable to receive initial SOCKS5 response.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
|
@ -473,7 +473,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
||||||
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
|
||||||
else if(socksreq[1] == 1) {
|
else if(socksreq[1] == 1) {
|
||||||
code = Curl_SOCKS5_gssapi_negotiate(sockindex, conn);
|
code = Curl_SOCKS5_gssapi_negotiate(sockindex, conn);
|
||||||
if(code != CURLE_OK) {
|
if(code) {
|
||||||
failf(data, "Unable to negotiate SOCKS5 GSS-API context.");
|
failf(data, "Unable to negotiate SOCKS5 GSS-API context.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
|
@ -510,13 +510,13 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
||||||
len += proxy_password_len;
|
len += proxy_password_len;
|
||||||
|
|
||||||
code = Curl_write_plain(conn, sock, (char *)socksreq, len, &written);
|
code = Curl_write_plain(conn, sock, (char *)socksreq, len, &written);
|
||||||
if((code != CURLE_OK) || (len != written)) {
|
if(code || (len != written)) {
|
||||||
failf(data, "Failed to send SOCKS5 sub-negotiation request.");
|
failf(data, "Failed to send SOCKS5 sub-negotiation request.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
result=Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread);
|
result=Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread);
|
||||||
if((result != CURLE_OK) || (actualread != 2)) {
|
if(result || (actualread != 2)) {
|
||||||
failf(data, "Unable to receive SOCKS5 sub-negotiation response.");
|
failf(data, "Unable to receive SOCKS5 sub-negotiation response.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
|
@ -583,7 +583,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
||||||
if(rc == CURLRESOLV_PENDING) {
|
if(rc == CURLRESOLV_PENDING) {
|
||||||
/* this requires that we're in "wait for resolve" state */
|
/* this requires that we're in "wait for resolve" state */
|
||||||
code = Curl_resolver_wait_resolv(conn, &dns);
|
code = Curl_resolver_wait_resolv(conn, &dns);
|
||||||
if(code != CURLE_OK)
|
if(code)
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,7 +642,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
||||||
#endif
|
#endif
|
||||||
code = Curl_write_plain(conn, sock, (char *)socksreq, len, &written);
|
code = Curl_write_plain(conn, sock, (char *)socksreq, len, &written);
|
||||||
|
|
||||||
if((code != CURLE_OK) || (len != written)) {
|
if(code || (len != written)) {
|
||||||
failf(data, "Failed to send SOCKS5 connect request.");
|
failf(data, "Failed to send SOCKS5 connect request.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
|
@ -658,7 +658,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
||||||
result = Curl_blockread_all(conn, sock, (char *)socksreq,
|
result = Curl_blockread_all(conn, sock, (char *)socksreq,
|
||||||
len, &actualread);
|
len, &actualread);
|
||||||
|
|
||||||
if((result != CURLE_OK) || (len != actualread)) {
|
if(result || (len != actualread)) {
|
||||||
failf(data, "Failed to receive SOCKS5 connect request ack.");
|
failf(data, "Failed to receive SOCKS5 connect request ack.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
|
@ -738,7 +738,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
|
||||||
len -= 10;
|
len -= 10;
|
||||||
result = Curl_blockread_all(conn, sock, (char *)&socksreq[10],
|
result = Curl_blockread_all(conn, sock, (char *)&socksreq[10],
|
||||||
len, &actualread);
|
len, &actualread);
|
||||||
if((result != CURLE_OK) || (len != actualread)) {
|
if(result || (len != actualread)) {
|
||||||
failf(data, "Failed to receive SOCKS5 connect request ack.");
|
failf(data, "Failed to receive SOCKS5 connect request ack.");
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009, 2011, Markus Moeller, <markus_moeller@compuserve.com>
|
* Copyright (C) 2009, 2011, Markus Moeller, <markus_moeller@compuserve.com>
|
||||||
* Copyright (C) 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 2012 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
|
@ -206,7 +206,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
memcpy(socksreq+2,&us_length,sizeof(short));
|
memcpy(socksreq+2,&us_length,sizeof(short));
|
||||||
|
|
||||||
code = Curl_write_plain(conn, sock, (char *)socksreq, 4, &written);
|
code = Curl_write_plain(conn, sock, (char *)socksreq, 4, &written);
|
||||||
if((code != CURLE_OK) || (4 != written)) {
|
if(code || (4 != written)) {
|
||||||
failf(data, "Failed to send GSS-API authentication request.");
|
failf(data, "Failed to send GSS-API authentication request.");
|
||||||
gss_release_name(&gss_status, &server);
|
gss_release_name(&gss_status, &server);
|
||||||
gss_release_buffer(&gss_status, &gss_recv_token);
|
gss_release_buffer(&gss_status, &gss_recv_token);
|
||||||
|
@ -218,7 +218,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
code = Curl_write_plain(conn, sock, (char *)gss_send_token.value,
|
code = Curl_write_plain(conn, sock, (char *)gss_send_token.value,
|
||||||
gss_send_token.length, &written);
|
gss_send_token.length, &written);
|
||||||
|
|
||||||
if((code != CURLE_OK) || ((ssize_t)gss_send_token.length != written)) {
|
if(code || ((ssize_t)gss_send_token.length != written)) {
|
||||||
failf(data, "Failed to send GSS-API authentication token.");
|
failf(data, "Failed to send GSS-API authentication token.");
|
||||||
gss_release_name(&gss_status, &server);
|
gss_release_name(&gss_status, &server);
|
||||||
gss_release_buffer(&gss_status, &gss_recv_token);
|
gss_release_buffer(&gss_status, &gss_recv_token);
|
||||||
|
@ -244,7 +244,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
result=Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
|
result=Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
|
||||||
if(result != CURLE_OK || actualread != 4) {
|
if(result || (actualread != 4)) {
|
||||||
failf(data, "Failed to receive GSS-API authentication response.");
|
failf(data, "Failed to receive GSS-API authentication response.");
|
||||||
gss_release_name(&gss_status, &server);
|
gss_release_name(&gss_status, &server);
|
||||||
gss_delete_sec_context(&gss_status, &gss_context, NULL);
|
gss_delete_sec_context(&gss_status, &gss_context, NULL);
|
||||||
|
@ -285,7 +285,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
result=Curl_blockread_all(conn, sock, (char *)gss_recv_token.value,
|
result=Curl_blockread_all(conn, sock, (char *)gss_recv_token.value,
|
||||||
gss_recv_token.length, &actualread);
|
gss_recv_token.length, &actualread);
|
||||||
|
|
||||||
if(result != CURLE_OK || actualread != us_length) {
|
if(result || (actualread != us_length)) {
|
||||||
failf(data, "Failed to receive GSS-API authentication token.");
|
failf(data, "Failed to receive GSS-API authentication token.");
|
||||||
gss_release_name(&gss_status, &server);
|
gss_release_name(&gss_status, &server);
|
||||||
gss_release_buffer(&gss_status, &gss_recv_token);
|
gss_release_buffer(&gss_status, &gss_recv_token);
|
||||||
|
@ -412,7 +412,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
}
|
}
|
||||||
|
|
||||||
code = Curl_write_plain(conn, sock, (char *)socksreq, 4, &written);
|
code = Curl_write_plain(conn, sock, (char *)socksreq, 4, &written);
|
||||||
if((code != CURLE_OK) || (4 != written)) {
|
if(code || (4 != written)) {
|
||||||
failf(data, "Failed to send GSS-API encryption request.");
|
failf(data, "Failed to send GSS-API encryption request.");
|
||||||
gss_release_buffer(&gss_status, &gss_w_token);
|
gss_release_buffer(&gss_status, &gss_w_token);
|
||||||
gss_delete_sec_context(&gss_status, &gss_context, NULL);
|
gss_delete_sec_context(&gss_status, &gss_context, NULL);
|
||||||
|
@ -422,7 +422,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
if(data->set.socks5_gssapi_nec) {
|
if(data->set.socks5_gssapi_nec) {
|
||||||
memcpy(socksreq, &gss_enc, 1);
|
memcpy(socksreq, &gss_enc, 1);
|
||||||
code = Curl_write_plain(conn, sock, socksreq, 1, &written);
|
code = Curl_write_plain(conn, sock, socksreq, 1, &written);
|
||||||
if((code != CURLE_OK) || ( 1 != written)) {
|
if(code || ( 1 != written)) {
|
||||||
failf(data, "Failed to send GSS-API encryption type.");
|
failf(data, "Failed to send GSS-API encryption type.");
|
||||||
gss_delete_sec_context(&gss_status, &gss_context, NULL);
|
gss_delete_sec_context(&gss_status, &gss_context, NULL);
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
|
@ -431,7 +431,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
else {
|
else {
|
||||||
code = Curl_write_plain(conn, sock, (char *)gss_w_token.value,
|
code = Curl_write_plain(conn, sock, (char *)gss_w_token.value,
|
||||||
gss_w_token.length, &written);
|
gss_w_token.length, &written);
|
||||||
if((code != CURLE_OK) || ((ssize_t)gss_w_token.length != written)) {
|
if(code || ((ssize_t)gss_w_token.length != written)) {
|
||||||
failf(data, "Failed to send GSS-API encryption type.");
|
failf(data, "Failed to send GSS-API encryption type.");
|
||||||
gss_release_buffer(&gss_status, &gss_w_token);
|
gss_release_buffer(&gss_status, &gss_w_token);
|
||||||
gss_delete_sec_context(&gss_status, &gss_context, NULL);
|
gss_delete_sec_context(&gss_status, &gss_context, NULL);
|
||||||
|
@ -441,7 +441,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
}
|
}
|
||||||
|
|
||||||
result=Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
|
result=Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
|
||||||
if(result != CURLE_OK || actualread != 4) {
|
if(result || (actualread != 4)) {
|
||||||
failf(data, "Failed to receive GSS-API encryption response.");
|
failf(data, "Failed to receive GSS-API encryption response.");
|
||||||
gss_delete_sec_context(&gss_status, &gss_context, NULL);
|
gss_delete_sec_context(&gss_status, &gss_context, NULL);
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
|
@ -474,7 +474,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
result=Curl_blockread_all(conn, sock, (char *)gss_recv_token.value,
|
result=Curl_blockread_all(conn, sock, (char *)gss_recv_token.value,
|
||||||
gss_recv_token.length, &actualread);
|
gss_recv_token.length, &actualread);
|
||||||
|
|
||||||
if(result != CURLE_OK || actualread != us_length) {
|
if(result || (actualread != us_length)) {
|
||||||
failf(data, "Failed to receive GSS-API encryptrion type.");
|
failf(data, "Failed to receive GSS-API encryptrion type.");
|
||||||
gss_release_buffer(&gss_status, &gss_recv_token);
|
gss_release_buffer(&gss_status, &gss_recv_token);
|
||||||
gss_delete_sec_context(&gss_status, &gss_context, NULL);
|
gss_delete_sec_context(&gss_status, &gss_context, NULL);
|
||||||
|
|
|
@ -201,7 +201,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
memcpy(socksreq+2, &us_length, sizeof(short));
|
memcpy(socksreq+2, &us_length, sizeof(short));
|
||||||
|
|
||||||
code = Curl_write_plain(conn, sock, (char *)socksreq, 4, &written);
|
code = Curl_write_plain(conn, sock, (char *)socksreq, 4, &written);
|
||||||
if((code != CURLE_OK) || (4 != written)) {
|
if(code || (4 != written)) {
|
||||||
failf(data, "Failed to send SSPI authentication request.");
|
failf(data, "Failed to send SSPI authentication request.");
|
||||||
Curl_safefree(service_name);
|
Curl_safefree(service_name);
|
||||||
if(sspi_send_token.pvBuffer)
|
if(sspi_send_token.pvBuffer)
|
||||||
|
@ -215,7 +215,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
|
|
||||||
code = Curl_write_plain(conn, sock, (char *)sspi_send_token.pvBuffer,
|
code = Curl_write_plain(conn, sock, (char *)sspi_send_token.pvBuffer,
|
||||||
sspi_send_token.cbBuffer, &written);
|
sspi_send_token.cbBuffer, &written);
|
||||||
if((code != CURLE_OK) || (sspi_send_token.cbBuffer != (size_t)written)) {
|
if(code || (sspi_send_token.cbBuffer != (size_t)written)) {
|
||||||
failf(data, "Failed to send SSPI authentication token.");
|
failf(data, "Failed to send SSPI authentication token.");
|
||||||
Curl_safefree(service_name);
|
Curl_safefree(service_name);
|
||||||
if(sspi_send_token.pvBuffer)
|
if(sspi_send_token.pvBuffer)
|
||||||
|
@ -255,7 +255,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
|
result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
|
||||||
if(result != CURLE_OK || actualread != 4) {
|
if(result || (actualread != 4)) {
|
||||||
failf(data, "Failed to receive SSPI authentication response.");
|
failf(data, "Failed to receive SSPI authentication response.");
|
||||||
Curl_safefree(service_name);
|
Curl_safefree(service_name);
|
||||||
s_pSecFn->FreeCredentialsHandle(&cred_handle);
|
s_pSecFn->FreeCredentialsHandle(&cred_handle);
|
||||||
|
@ -297,7 +297,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
result = Curl_blockread_all(conn, sock, (char *)sspi_recv_token.pvBuffer,
|
result = Curl_blockread_all(conn, sock, (char *)sspi_recv_token.pvBuffer,
|
||||||
sspi_recv_token.cbBuffer, &actualread);
|
sspi_recv_token.cbBuffer, &actualread);
|
||||||
|
|
||||||
if(result != CURLE_OK || actualread != us_length) {
|
if(result || (actualread != us_length)) {
|
||||||
failf(data, "Failed to receive SSPI authentication token.");
|
failf(data, "Failed to receive SSPI authentication token.");
|
||||||
Curl_safefree(service_name);
|
Curl_safefree(service_name);
|
||||||
if(sspi_recv_token.pvBuffer)
|
if(sspi_recv_token.pvBuffer)
|
||||||
|
@ -463,7 +463,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
}
|
}
|
||||||
|
|
||||||
code = Curl_write_plain(conn, sock, (char *)socksreq, 4, &written);
|
code = Curl_write_plain(conn, sock, (char *)socksreq, 4, &written);
|
||||||
if((code != CURLE_OK) || (4 != written)) {
|
if(code || (4 != written)) {
|
||||||
failf(data, "Failed to send SSPI encryption request.");
|
failf(data, "Failed to send SSPI encryption request.");
|
||||||
if(sspi_send_token.pvBuffer)
|
if(sspi_send_token.pvBuffer)
|
||||||
s_pSecFn->FreeContextBuffer(sspi_send_token.pvBuffer);
|
s_pSecFn->FreeContextBuffer(sspi_send_token.pvBuffer);
|
||||||
|
@ -474,7 +474,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
if(data->set.socks5_gssapi_nec) {
|
if(data->set.socks5_gssapi_nec) {
|
||||||
memcpy(socksreq,&gss_enc,1);
|
memcpy(socksreq,&gss_enc,1);
|
||||||
code = Curl_write_plain(conn, sock, (char *)socksreq, 1, &written);
|
code = Curl_write_plain(conn, sock, (char *)socksreq, 1, &written);
|
||||||
if((code != CURLE_OK) || (1 != written)) {
|
if(code || (1 != written)) {
|
||||||
failf(data, "Failed to send SSPI encryption type.");
|
failf(data, "Failed to send SSPI encryption type.");
|
||||||
s_pSecFn->DeleteSecurityContext(&sspi_context);
|
s_pSecFn->DeleteSecurityContext(&sspi_context);
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
|
@ -483,7 +483,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
else {
|
else {
|
||||||
code = Curl_write_plain(conn, sock, (char *)sspi_send_token.pvBuffer,
|
code = Curl_write_plain(conn, sock, (char *)sspi_send_token.pvBuffer,
|
||||||
sspi_send_token.cbBuffer, &written);
|
sspi_send_token.cbBuffer, &written);
|
||||||
if((code != CURLE_OK) || (sspi_send_token.cbBuffer != (size_t)written)) {
|
if(code || (sspi_send_token.cbBuffer != (size_t)written)) {
|
||||||
failf(data, "Failed to send SSPI encryption type.");
|
failf(data, "Failed to send SSPI encryption type.");
|
||||||
if(sspi_send_token.pvBuffer)
|
if(sspi_send_token.pvBuffer)
|
||||||
s_pSecFn->FreeContextBuffer(sspi_send_token.pvBuffer);
|
s_pSecFn->FreeContextBuffer(sspi_send_token.pvBuffer);
|
||||||
|
@ -495,7 +495,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
}
|
}
|
||||||
|
|
||||||
result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
|
result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
|
||||||
if(result != CURLE_OK || actualread != 4) {
|
if(result || (actualread != 4)) {
|
||||||
failf(data, "Failed to receive SSPI encryption response.");
|
failf(data, "Failed to receive SSPI encryption response.");
|
||||||
s_pSecFn->DeleteSecurityContext(&sspi_context);
|
s_pSecFn->DeleteSecurityContext(&sspi_context);
|
||||||
return CURLE_COULDNT_CONNECT;
|
return CURLE_COULDNT_CONNECT;
|
||||||
|
@ -529,7 +529,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
|
||||||
result = Curl_blockread_all(conn, sock, (char *)sspi_w_token[0].pvBuffer,
|
result = Curl_blockread_all(conn, sock, (char *)sspi_w_token[0].pvBuffer,
|
||||||
sspi_w_token[0].cbBuffer, &actualread);
|
sspi_w_token[0].cbBuffer, &actualread);
|
||||||
|
|
||||||
if(result != CURLE_OK || actualread != us_length) {
|
if(result || (actualread != us_length)) {
|
||||||
failf(data, "Failed to receive SSPI encryption type.");
|
failf(data, "Failed to receive SSPI encryption type.");
|
||||||
s_pSecFn->FreeContextBuffer(sspi_w_token[0].pvBuffer);
|
s_pSecFn->FreeContextBuffer(sspi_w_token[0].pvBuffer);
|
||||||
s_pSecFn->DeleteSecurityContext(&sspi_context);
|
s_pSecFn->DeleteSecurityContext(&sspi_context);
|
||||||
|
|
23
lib/ssh.c
23
lib/ssh.c
|
@ -734,7 +734,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||||
* whatever) is up to us.
|
* whatever) is up to us.
|
||||||
*/
|
*/
|
||||||
result = ssh_check_fingerprint(conn);
|
result = ssh_check_fingerprint(conn);
|
||||||
if(result == CURLE_OK)
|
if(!result)
|
||||||
state(conn, SSH_AUTHLIST);
|
state(conn, SSH_AUTHLIST);
|
||||||
/* ssh_check_fingerprint sets state appropriately on error */
|
/* ssh_check_fingerprint sets state appropriately on error */
|
||||||
break;
|
break;
|
||||||
|
@ -2022,7 +2022,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
|
||||||
sshc->readdir_line,
|
sshc->readdir_line,
|
||||||
sshc->readdir_currLen);
|
sshc->readdir_currLen);
|
||||||
|
|
||||||
if(result == CURLE_OK) {
|
if(!result) {
|
||||||
|
|
||||||
/* output debug output if that is requested */
|
/* output debug output if that is requested */
|
||||||
if(data->set.verbose) {
|
if(data->set.verbose) {
|
||||||
|
@ -2715,7 +2715,7 @@ static CURLcode ssh_block_statemach(struct connectdata *conn,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBSSH2_SESSION_BLOCK_DIRECTION
|
#ifdef HAVE_LIBSSH2_SESSION_BLOCK_DIRECTION
|
||||||
if((CURLE_OK == result) && block) {
|
if(!result && block) {
|
||||||
int dir = libssh2_session_block_directions(sshc->ssh_session);
|
int dir = libssh2_session_block_directions(sshc->ssh_session);
|
||||||
curl_socket_t sock = conn->sock[FIRSTSOCKET];
|
curl_socket_t sock = conn->sock[FIRSTSOCKET];
|
||||||
curl_socket_t fd_read = CURL_SOCKET_BAD;
|
curl_socket_t fd_read = CURL_SOCKET_BAD;
|
||||||
|
@ -2887,7 +2887,7 @@ static CURLcode scp_doing(struct connectdata *conn,
|
||||||
|
|
||||||
static CURLcode ssh_do(struct connectdata *conn, bool *done)
|
static CURLcode ssh_do(struct connectdata *conn, bool *done)
|
||||||
{
|
{
|
||||||
CURLcode res;
|
CURLcode result;
|
||||||
bool connected = 0;
|
bool connected = 0;
|
||||||
struct SessionHandle *data = conn->data;
|
struct SessionHandle *data = conn->data;
|
||||||
struct ssh_conn *sshc = &conn->proto.sshc;
|
struct ssh_conn *sshc = &conn->proto.sshc;
|
||||||
|
@ -2906,11 +2906,11 @@ static CURLcode ssh_do(struct connectdata *conn, bool *done)
|
||||||
Curl_pgrsSetDownloadSize(data, -1);
|
Curl_pgrsSetDownloadSize(data, -1);
|
||||||
|
|
||||||
if(conn->handler->protocol & CURLPROTO_SCP)
|
if(conn->handler->protocol & CURLPROTO_SCP)
|
||||||
res = scp_perform(conn, &connected, done);
|
result = scp_perform(conn, &connected, done);
|
||||||
else
|
else
|
||||||
res = sftp_perform(conn, &connected, done);
|
result = sftp_perform(conn, &connected, done);
|
||||||
|
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* BLOCKING, but the function is using the state machine so the only reason
|
/* BLOCKING, but the function is using the state machine so the only reason
|
||||||
|
@ -2942,7 +2942,7 @@ static CURLcode ssh_done(struct connectdata *conn, CURLcode status)
|
||||||
CURLcode result = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
struct SSHPROTO *sftp_scp = conn->data->req.protop;
|
struct SSHPROTO *sftp_scp = conn->data->req.protop;
|
||||||
|
|
||||||
if(status == CURLE_OK) {
|
if(!status) {
|
||||||
/* run the state-machine
|
/* run the state-machine
|
||||||
|
|
||||||
TODO: when the multi interface is used, this _really_ should be using
|
TODO: when the multi interface is used, this _really_ should be using
|
||||||
|
@ -2970,7 +2970,7 @@ static CURLcode scp_done(struct connectdata *conn, CURLcode status,
|
||||||
{
|
{
|
||||||
(void)premature; /* not used */
|
(void)premature; /* not used */
|
||||||
|
|
||||||
if(status == CURLE_OK)
|
if(!status)
|
||||||
state(conn, SSH_SCP_DONE);
|
state(conn, SSH_SCP_DONE);
|
||||||
|
|
||||||
return ssh_done(conn, status);
|
return ssh_done(conn, status);
|
||||||
|
@ -3068,8 +3068,7 @@ CURLcode sftp_perform(struct connectdata *conn,
|
||||||
static CURLcode sftp_doing(struct connectdata *conn,
|
static CURLcode sftp_doing(struct connectdata *conn,
|
||||||
bool *dophase_done)
|
bool *dophase_done)
|
||||||
{
|
{
|
||||||
CURLcode result;
|
CURLcode result = ssh_multi_statemach(conn, dophase_done);
|
||||||
result = ssh_multi_statemach(conn, dophase_done);
|
|
||||||
|
|
||||||
if(*dophase_done) {
|
if(*dophase_done) {
|
||||||
DEBUGF(infof(conn->data, "DO phase is complete\n"));
|
DEBUGF(infof(conn->data, "DO phase is complete\n"));
|
||||||
|
@ -3106,7 +3105,7 @@ static CURLcode sftp_done(struct connectdata *conn, CURLcode status,
|
||||||
{
|
{
|
||||||
struct ssh_conn *sshc = &conn->proto.sshc;
|
struct ssh_conn *sshc = &conn->proto.sshc;
|
||||||
|
|
||||||
if(status == CURLE_OK) {
|
if(!status) {
|
||||||
/* Post quote commands are executed after the SFTP_CLOSE state to avoid
|
/* Post quote commands are executed after the SFTP_CLOSE state to avoid
|
||||||
errors that could happen due to open file handles during POSTQUOTE
|
errors that could happen due to open file handles during POSTQUOTE
|
||||||
operation */
|
operation */
|
||||||
|
|
|
@ -330,7 +330,7 @@ curl_easy_strerror(CURLcode error)
|
||||||
*/
|
*/
|
||||||
return "Unknown error";
|
return "Unknown error";
|
||||||
#else
|
#else
|
||||||
if(error == CURLE_OK)
|
if(!error)
|
||||||
return "No error";
|
return "No error";
|
||||||
else
|
else
|
||||||
return "Error";
|
return "Error";
|
||||||
|
@ -597,7 +597,7 @@ get_winsock_error (int err, char *buf, size_t len)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if(err == CURLE_OK)
|
if(!err)
|
||||||
return NULL;
|
return NULL;
|
||||||
else
|
else
|
||||||
p = "error";
|
p = "error";
|
||||||
|
|
19
lib/telnet.c
19
lib/telnet.c
|
@ -1076,7 +1076,7 @@ CURLcode telrcv(struct connectdata *conn,
|
||||||
CLIENTWRITE_BODY, \
|
CLIENTWRITE_BODY, \
|
||||||
(char *)&inbuf[startwrite], \
|
(char *)&inbuf[startwrite], \
|
||||||
in-startwrite); \
|
in-startwrite); \
|
||||||
if(result != CURLE_OK) \
|
if(result) \
|
||||||
return result; \
|
return result; \
|
||||||
} \
|
} \
|
||||||
startwrite = -1
|
startwrite = -1
|
||||||
|
@ -1230,9 +1230,9 @@ static CURLcode send_telnet_data(struct connectdata *conn,
|
||||||
unsigned char outbuf[2];
|
unsigned char outbuf[2];
|
||||||
ssize_t bytes_written, total_written;
|
ssize_t bytes_written, total_written;
|
||||||
int out_count;
|
int out_count;
|
||||||
CURLcode rc = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
|
|
||||||
while(rc == CURLE_OK && nread--) {
|
while(!result && nread--) {
|
||||||
outbuf[0] = *buffer++;
|
outbuf[0] = *buffer++;
|
||||||
out_count = 1;
|
out_count = 1;
|
||||||
if(outbuf[0] == CURL_IAC)
|
if(outbuf[0] == CURL_IAC)
|
||||||
|
@ -1247,19 +1247,20 @@ static CURLcode send_telnet_data(struct connectdata *conn,
|
||||||
switch (Curl_poll(pfd, 1, -1)) {
|
switch (Curl_poll(pfd, 1, -1)) {
|
||||||
case -1: /* error, abort writing */
|
case -1: /* error, abort writing */
|
||||||
case 0: /* timeout (will never happen) */
|
case 0: /* timeout (will never happen) */
|
||||||
rc = CURLE_SEND_ERROR;
|
result = CURLE_SEND_ERROR;
|
||||||
break;
|
break;
|
||||||
default: /* write! */
|
default: /* write! */
|
||||||
bytes_written = 0;
|
bytes_written = 0;
|
||||||
rc = Curl_write(conn, conn->sock[FIRSTSOCKET], outbuf+total_written,
|
result = Curl_write(conn, conn->sock[FIRSTSOCKET],
|
||||||
out_count-total_written, &bytes_written);
|
outbuf+total_written, out_count-total_written,
|
||||||
|
&bytes_written);
|
||||||
total_written += bytes_written;
|
total_written += bytes_written;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* handle partial write */
|
/* handle partial write */
|
||||||
} while(rc == CURLE_OK && total_written < out_count);
|
} while(!result && total_written < out_count);
|
||||||
}
|
}
|
||||||
return rc;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CURLcode telnet_done(struct connectdata *conn,
|
static CURLcode telnet_done(struct connectdata *conn,
|
||||||
|
|
44
lib/tftp.c
44
lib/tftp.c
|
@ -417,32 +417,32 @@ static size_t tftp_option_add(tftp_state_data_t *state, size_t csize,
|
||||||
static CURLcode tftp_connect_for_tx(tftp_state_data_t *state,
|
static CURLcode tftp_connect_for_tx(tftp_state_data_t *state,
|
||||||
tftp_event_t event)
|
tftp_event_t event)
|
||||||
{
|
{
|
||||||
CURLcode res;
|
CURLcode result;
|
||||||
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
||||||
struct SessionHandle *data = state->conn->data;
|
struct SessionHandle *data = state->conn->data;
|
||||||
|
|
||||||
infof(data, "%s\n", "Connected for transmit");
|
infof(data, "%s\n", "Connected for transmit");
|
||||||
#endif
|
#endif
|
||||||
state->state = TFTP_STATE_TX;
|
state->state = TFTP_STATE_TX;
|
||||||
res = tftp_set_timeouts(state);
|
result = tftp_set_timeouts(state);
|
||||||
if(res != CURLE_OK)
|
if(result)
|
||||||
return(res);
|
return(result);
|
||||||
return tftp_tx(state, event);
|
return tftp_tx(state, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CURLcode tftp_connect_for_rx(tftp_state_data_t *state,
|
static CURLcode tftp_connect_for_rx(tftp_state_data_t *state,
|
||||||
tftp_event_t event)
|
tftp_event_t event)
|
||||||
{
|
{
|
||||||
CURLcode res;
|
CURLcode result;
|
||||||
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
||||||
struct SessionHandle *data = state->conn->data;
|
struct SessionHandle *data = state->conn->data;
|
||||||
|
|
||||||
infof(data, "%s\n", "Connected for receive");
|
infof(data, "%s\n", "Connected for receive");
|
||||||
#endif
|
#endif
|
||||||
state->state = TFTP_STATE_RX;
|
state->state = TFTP_STATE_RX;
|
||||||
res = tftp_set_timeouts(state);
|
result = tftp_set_timeouts(state);
|
||||||
if(res != CURLE_OK)
|
if(result)
|
||||||
return(res);
|
return(result);
|
||||||
return tftp_rx(state, event);
|
return tftp_rx(state, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1208,7 +1208,7 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
|
||||||
}
|
}
|
||||||
else if(event != TFTP_EVENT_NONE) {
|
else if(event != TFTP_EVENT_NONE) {
|
||||||
result = tftp_state_machine(state, event);
|
result = tftp_state_machine(state, event);
|
||||||
if(result != CURLE_OK)
|
if(result)
|
||||||
return(result);
|
return(result);
|
||||||
*done = (state->state == TFTP_STATE_FIN) ? TRUE : FALSE;
|
*done = (state->state == TFTP_STATE_FIN) ? TRUE : FALSE;
|
||||||
if(*done)
|
if(*done)
|
||||||
|
@ -1227,10 +1227,10 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
|
||||||
}
|
}
|
||||||
else if(rc != 0) {
|
else if(rc != 0) {
|
||||||
result = tftp_receive_packet(conn);
|
result = tftp_receive_packet(conn);
|
||||||
if(result != CURLE_OK)
|
if(result)
|
||||||
return(result);
|
return(result);
|
||||||
result = tftp_state_machine(state, state->event);
|
result = tftp_state_machine(state, state->event);
|
||||||
if(result != CURLE_OK)
|
if(result)
|
||||||
return(result);
|
return(result);
|
||||||
*done = (state->state == TFTP_STATE_FIN) ? TRUE : FALSE;
|
*done = (state->state == TFTP_STATE_FIN) ? TRUE : FALSE;
|
||||||
if(*done)
|
if(*done)
|
||||||
|
@ -1286,8 +1286,8 @@ static CURLcode tftp_perform(struct connectdata *conn, bool *dophase_done)
|
||||||
|
|
||||||
result = tftp_state_machine(state, TFTP_EVENT_INIT);
|
result = tftp_state_machine(state, TFTP_EVENT_INIT);
|
||||||
|
|
||||||
if(state->state == TFTP_STATE_FIN || result != CURLE_OK)
|
if((state->state == TFTP_STATE_FIN) || result)
|
||||||
return(result);
|
return result;
|
||||||
|
|
||||||
tftp_multi_statemach(conn, dophase_done);
|
tftp_multi_statemach(conn, dophase_done);
|
||||||
|
|
||||||
|
@ -1310,30 +1310,30 @@ static CURLcode tftp_perform(struct connectdata *conn, bool *dophase_done)
|
||||||
|
|
||||||
static CURLcode tftp_do(struct connectdata *conn, bool *done)
|
static CURLcode tftp_do(struct connectdata *conn, bool *done)
|
||||||
{
|
{
|
||||||
tftp_state_data_t *state;
|
tftp_state_data_t *state;
|
||||||
CURLcode code;
|
CURLcode result;
|
||||||
|
|
||||||
*done = FALSE;
|
*done = FALSE;
|
||||||
|
|
||||||
if(!conn->proto.tftpc) {
|
if(!conn->proto.tftpc) {
|
||||||
code = tftp_connect(conn, done);
|
result = tftp_connect(conn, done);
|
||||||
if(code)
|
if(result)
|
||||||
return code;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
state = (tftp_state_data_t *)conn->proto.tftpc;
|
state = (tftp_state_data_t *)conn->proto.tftpc;
|
||||||
if(!state)
|
if(!state)
|
||||||
return CURLE_BAD_CALLING_ORDER;
|
return CURLE_BAD_CALLING_ORDER;
|
||||||
|
|
||||||
code = tftp_perform(conn, done);
|
result = tftp_perform(conn, done);
|
||||||
|
|
||||||
/* If tftp_perform() returned an error, use that for return code. If it
|
/* If tftp_perform() returned an error, use that for return code. If it
|
||||||
was OK, see if tftp_translate_code() has an error. */
|
was OK, see if tftp_translate_code() has an error. */
|
||||||
if(code == CURLE_OK)
|
if(!result)
|
||||||
/* If we have encountered an internal tftp error, translate it. */
|
/* If we have encountered an internal tftp error, translate it. */
|
||||||
code = tftp_translate_code(state->error);
|
result = tftp_translate_code(state->error);
|
||||||
|
|
||||||
return code;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CURLcode tftp_setup_connection(struct connectdata * conn)
|
static CURLcode tftp_setup_connection(struct connectdata * conn)
|
||||||
|
|
|
@ -203,7 +203,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
|
||||||
strlen(endofline_network));
|
strlen(endofline_network));
|
||||||
|
|
||||||
#ifdef CURL_DOES_CONVERSIONS
|
#ifdef CURL_DOES_CONVERSIONS
|
||||||
CURLcode res;
|
CURLcode result;
|
||||||
int length;
|
int length;
|
||||||
if(data->set.prefer_ascii) {
|
if(data->set.prefer_ascii) {
|
||||||
/* translate the protocol and data */
|
/* translate the protocol and data */
|
||||||
|
@ -213,10 +213,10 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
|
||||||
/* just translate the protocol portion */
|
/* just translate the protocol portion */
|
||||||
length = strlen(hexbuffer);
|
length = strlen(hexbuffer);
|
||||||
}
|
}
|
||||||
res = Curl_convert_to_network(data, data->req.upload_fromhere, length);
|
result = Curl_convert_to_network(data, data->req.upload_fromhere, length);
|
||||||
/* Curl_convert_to_network calls failf if unsuccessful */
|
/* Curl_convert_to_network calls failf if unsuccessful */
|
||||||
if(res)
|
if(result)
|
||||||
return(res);
|
return(result);
|
||||||
#endif /* CURL_DOES_CONVERSIONS */
|
#endif /* CURL_DOES_CONVERSIONS */
|
||||||
|
|
||||||
if((nread - hexlen) == 0)
|
if((nread - hexlen) == 0)
|
||||||
|
@ -227,11 +227,11 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
|
||||||
}
|
}
|
||||||
#ifdef CURL_DOES_CONVERSIONS
|
#ifdef CURL_DOES_CONVERSIONS
|
||||||
else if((data->set.prefer_ascii) && (!sending_http_headers)) {
|
else if((data->set.prefer_ascii) && (!sending_http_headers)) {
|
||||||
CURLcode res;
|
CURLcode result;
|
||||||
res = Curl_convert_to_network(data, data->req.upload_fromhere, nread);
|
result = Curl_convert_to_network(data, data->req.upload_fromhere, nread);
|
||||||
/* Curl_convert_to_network calls failf if unsuccessful */
|
/* Curl_convert_to_network calls failf if unsuccessful */
|
||||||
if(res != CURLE_OK)
|
if(result)
|
||||||
return(res);
|
return result;
|
||||||
}
|
}
|
||||||
#endif /* CURL_DOES_CONVERSIONS */
|
#endif /* CURL_DOES_CONVERSIONS */
|
||||||
|
|
||||||
|
@ -1278,7 +1278,7 @@ long Curl_sleep_time(curl_off_t rate_bps, curl_off_t cur_rate_bps,
|
||||||
*/
|
*/
|
||||||
CURLcode Curl_pretransfer(struct SessionHandle *data)
|
CURLcode Curl_pretransfer(struct SessionHandle *data)
|
||||||
{
|
{
|
||||||
CURLcode res;
|
CURLcode result;
|
||||||
if(!data->change.url) {
|
if(!data->change.url) {
|
||||||
/* we can't do anything without URL */
|
/* we can't do anything without URL */
|
||||||
failf(data, "No URL set!");
|
failf(data, "No URL set!");
|
||||||
|
@ -1288,9 +1288,9 @@ CURLcode Curl_pretransfer(struct SessionHandle *data)
|
||||||
/* Init the SSL session ID cache here. We do it here since we want to do it
|
/* Init the SSL session ID cache here. We do it here since we want to do it
|
||||||
after the *_setopt() calls (that could specify the size of the cache) but
|
after the *_setopt() calls (that could specify the size of the cache) but
|
||||||
before any transfer takes place. */
|
before any transfer takes place. */
|
||||||
res = Curl_ssl_initsessions(data, data->set.ssl.max_ssl_sessions);
|
result = Curl_ssl_initsessions(data, data->set.ssl.max_ssl_sessions);
|
||||||
if(res)
|
if(result)
|
||||||
return res;
|
return result;
|
||||||
|
|
||||||
data->set.followlocation=0; /* reset the location-follow counter */
|
data->set.followlocation=0; /* reset the location-follow counter */
|
||||||
data->state.this_is_a_follow = FALSE; /* reset this */
|
data->state.this_is_a_follow = FALSE; /* reset this */
|
||||||
|
@ -1311,9 +1311,9 @@ CURLcode Curl_pretransfer(struct SessionHandle *data)
|
||||||
|
|
||||||
/* If there is a list of host pairs to deal with */
|
/* If there is a list of host pairs to deal with */
|
||||||
if(data->change.resolve)
|
if(data->change.resolve)
|
||||||
res = Curl_loadhostpairs(data);
|
result = Curl_loadhostpairs(data);
|
||||||
|
|
||||||
if(!res) {
|
if(!result) {
|
||||||
/* Allow data->set.use_port to set which port to use. This needs to be
|
/* Allow data->set.use_port to set which port to use. This needs to be
|
||||||
* disabled for example when we follow Location: headers to URLs using
|
* disabled for example when we follow Location: headers to URLs using
|
||||||
* different ports! */
|
* different ports! */
|
||||||
|
@ -1343,7 +1343,7 @@ CURLcode Curl_pretransfer(struct SessionHandle *data)
|
||||||
data->state.authproxy.picked &= data->state.authproxy.want;
|
data->state.authproxy.picked &= data->state.authproxy.want;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1828,13 +1828,13 @@ Curl_reconnect_request(struct connectdata **connp)
|
||||||
* (again). Slight Lack of feedback in the report, but I don't think this
|
* (again). Slight Lack of feedback in the report, but I don't think this
|
||||||
* extra check can do much harm.
|
* extra check can do much harm.
|
||||||
*/
|
*/
|
||||||
if((CURLE_OK == result) || (CURLE_SEND_ERROR == result)) {
|
if(!result || (CURLE_SEND_ERROR == result)) {
|
||||||
bool async;
|
bool async;
|
||||||
bool protocol_done = TRUE;
|
bool protocol_done = TRUE;
|
||||||
|
|
||||||
/* Now, redo the connect and get a new connection */
|
/* Now, redo the connect and get a new connection */
|
||||||
result = Curl_connect(data, connp, &async, &protocol_done);
|
result = Curl_connect(data, connp, &async, &protocol_done);
|
||||||
if(CURLE_OK == result) {
|
if(!result) {
|
||||||
/* We have connected or sent away a name resolve query fine */
|
/* We have connected or sent away a name resolve query fine */
|
||||||
|
|
||||||
conn = *connp; /* setup conn to again point to something nice */
|
conn = *connp; /* setup conn to again point to something nice */
|
||||||
|
|
74
lib/url.c
74
lib/url.c
|
@ -345,7 +345,7 @@ static CURLcode setstropt_userpwd(char *option, char **userp, char **passwdp)
|
||||||
|
|
||||||
CURLcode Curl_dupset(struct SessionHandle *dst, struct SessionHandle *src)
|
CURLcode Curl_dupset(struct SessionHandle *dst, struct SessionHandle *src)
|
||||||
{
|
{
|
||||||
CURLcode r = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
enum dupstring i;
|
enum dupstring i;
|
||||||
|
|
||||||
/* Copy src->set into dst->set first, then deal with the strings
|
/* Copy src->set into dst->set first, then deal with the strings
|
||||||
|
@ -357,13 +357,13 @@ CURLcode Curl_dupset(struct SessionHandle *dst, struct SessionHandle *src)
|
||||||
|
|
||||||
/* duplicate all strings */
|
/* duplicate all strings */
|
||||||
for(i=(enum dupstring)0; i< STRING_LAST; i++) {
|
for(i=(enum dupstring)0; i< STRING_LAST; i++) {
|
||||||
r = setstropt(&dst->set.str[i], src->set.str[i]);
|
result = setstropt(&dst->set.str[i], src->set.str[i]);
|
||||||
if(r != CURLE_OK)
|
if(result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If a failure occurred, freeing has to be performed externally. */
|
/* If a failure occurred, freeing has to be performed externally. */
|
||||||
return r;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -474,7 +474,7 @@ CURLcode Curl_close(struct SessionHandle *data)
|
||||||
*/
|
*/
|
||||||
CURLcode Curl_init_userdefined(struct UserDefined *set)
|
CURLcode Curl_init_userdefined(struct UserDefined *set)
|
||||||
{
|
{
|
||||||
CURLcode res = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
|
|
||||||
set->out = stdout; /* default output to stdout */
|
set->out = stdout; /* default output to stdout */
|
||||||
set->in = stdin; /* default input from stdin */
|
set->in = stdin; /* default input from stdin */
|
||||||
|
@ -550,17 +550,17 @@ CURLcode Curl_init_userdefined(struct UserDefined *set)
|
||||||
*/
|
*/
|
||||||
set->socks5_gssapi_nec = FALSE;
|
set->socks5_gssapi_nec = FALSE;
|
||||||
/* set default GSS-API service name */
|
/* set default GSS-API service name */
|
||||||
res = setstropt(&set->str[STRING_SOCKS5_GSSAPI_SERVICE],
|
result = setstropt(&set->str[STRING_SOCKS5_GSSAPI_SERVICE],
|
||||||
(char *) CURL_DEFAULT_SOCKS5_GSSAPI_SERVICE);
|
(char *) CURL_DEFAULT_SOCKS5_GSSAPI_SERVICE);
|
||||||
if(res != CURLE_OK)
|
if(result)
|
||||||
return res;
|
return result;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This is our preferred CA cert bundle/path since install time */
|
/* This is our preferred CA cert bundle/path since install time */
|
||||||
#if defined(CURL_CA_BUNDLE)
|
#if defined(CURL_CA_BUNDLE)
|
||||||
res = setstropt(&set->str[STRING_SSL_CAFILE], (char *) CURL_CA_BUNDLE);
|
result = setstropt(&set->str[STRING_SSL_CAFILE], (char *) CURL_CA_BUNDLE);
|
||||||
#elif defined(CURL_CA_PATH)
|
#elif defined(CURL_CA_PATH)
|
||||||
res = setstropt(&set->str[STRING_SSL_CAPATH], (char *) CURL_CA_PATH);
|
result = setstropt(&set->str[STRING_SSL_CAPATH], (char *) CURL_CA_PATH);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
set->wildcardmatch = FALSE;
|
set->wildcardmatch = FALSE;
|
||||||
|
@ -578,7 +578,7 @@ CURLcode Curl_init_userdefined(struct UserDefined *set)
|
||||||
set->ssl_enable_alpn = TRUE;
|
set->ssl_enable_alpn = TRUE;
|
||||||
|
|
||||||
set->expect_100_timeout = 1000L; /* Wait for a second by default. */
|
set->expect_100_timeout = 1000L; /* Wait for a second by default. */
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -591,7 +591,7 @@ CURLcode Curl_init_userdefined(struct UserDefined *set)
|
||||||
|
|
||||||
CURLcode Curl_open(struct SessionHandle **curl)
|
CURLcode Curl_open(struct SessionHandle **curl)
|
||||||
{
|
{
|
||||||
CURLcode res = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
struct SessionHandle *data;
|
struct SessionHandle *data;
|
||||||
CURLcode status;
|
CURLcode status;
|
||||||
|
|
||||||
|
@ -617,10 +617,10 @@ CURLcode Curl_open(struct SessionHandle **curl)
|
||||||
data->state.headerbuff = 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;
|
result = CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res = Curl_init_userdefined(&data->set);
|
result = Curl_init_userdefined(&data->set);
|
||||||
|
|
||||||
data->state.headersize=HEADERSIZE;
|
data->state.headersize=HEADERSIZE;
|
||||||
|
|
||||||
|
@ -638,7 +638,7 @@ CURLcode Curl_open(struct SessionHandle **curl)
|
||||||
data->set.maxconnects = DEFAULT_CONNCACHE_SIZE; /* for easy handles */
|
data->set.maxconnects = DEFAULT_CONNCACHE_SIZE; /* for easy handles */
|
||||||
}
|
}
|
||||||
|
|
||||||
if(res) {
|
if(result) {
|
||||||
Curl_resolver_cleanup(data->state.resolver);
|
Curl_resolver_cleanup(data->state.resolver);
|
||||||
if(data->state.headerbuff)
|
if(data->state.headerbuff)
|
||||||
free(data->state.headerbuff);
|
free(data->state.headerbuff);
|
||||||
|
@ -649,7 +649,7 @@ CURLcode Curl_open(struct SessionHandle **curl)
|
||||||
else
|
else
|
||||||
*curl = data;
|
*curl = data;
|
||||||
|
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
|
CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
|
||||||
|
@ -4023,7 +4023,7 @@ static CURLcode parseurlandfillconn(struct SessionHandle *data,
|
||||||
* the host name
|
* the host name
|
||||||
*/
|
*/
|
||||||
result = parse_url_login(data, conn, userp, passwdp, optionsp);
|
result = parse_url_login(data, conn, userp, passwdp, optionsp);
|
||||||
if(result != CURLE_OK)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
if(conn->host.name[0] == '[') {
|
if(conn->host.name[0] == '[') {
|
||||||
|
@ -4173,7 +4173,7 @@ static CURLcode setup_connection_internals(struct connectdata *conn)
|
||||||
if(p->setup_connection) {
|
if(p->setup_connection) {
|
||||||
result = (*p->setup_connection)(conn);
|
result = (*p->setup_connection)(conn);
|
||||||
|
|
||||||
if(result != CURLE_OK)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
p = conn->handler; /* May have changed. */
|
p = conn->handler; /* May have changed. */
|
||||||
|
@ -4611,7 +4611,7 @@ static CURLcode parse_url_login(struct SessionHandle *data,
|
||||||
/* We could use the login information in the URL so extract it */
|
/* We could use the login information in the URL so extract it */
|
||||||
result = parse_login_details(login, ptr - login - 1,
|
result = parse_login_details(login, ptr - login - 1,
|
||||||
&userp, &passwdp, &optionsp);
|
&userp, &passwdp, &optionsp);
|
||||||
if(result != CURLE_OK)
|
if(result)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if(userp) {
|
if(userp) {
|
||||||
|
@ -5266,7 +5266,7 @@ static CURLcode create_conn(struct SessionHandle *data,
|
||||||
|
|
||||||
result = parseurlandfillconn(data, conn, &prot_missing, &user, &passwd,
|
result = parseurlandfillconn(data, conn, &prot_missing, &user, &passwd,
|
||||||
&options);
|
&options);
|
||||||
if(result != CURLE_OK)
|
if(result)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
|
@ -5326,7 +5326,7 @@ static CURLcode create_conn(struct SessionHandle *data,
|
||||||
*************************************************************/
|
*************************************************************/
|
||||||
if(conn->bits.proxy_user_passwd) {
|
if(conn->bits.proxy_user_passwd) {
|
||||||
result = parse_proxy_auth(data, conn);
|
result = parse_proxy_auth(data, conn);
|
||||||
if(result != CURLE_OK)
|
if(result)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5413,16 +5413,16 @@ static CURLcode create_conn(struct SessionHandle *data,
|
||||||
* Figure out the remote port number and fix it in the URL
|
* Figure out the remote port number and fix it in the URL
|
||||||
*************************************************************/
|
*************************************************************/
|
||||||
result = parse_remote_port(data, conn);
|
result = parse_remote_port(data, conn);
|
||||||
if(result != CURLE_OK)
|
if(result)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* Check for overridden login details and set them accordingly so they
|
/* Check for overridden login details and set them accordingly so they
|
||||||
they are known when protocol->setup_connection is called! */
|
they are known when protocol->setup_connection is called! */
|
||||||
result = override_login(data, conn, &user, &passwd, &options);
|
result = override_login(data, conn, &user, &passwd, &options);
|
||||||
if(result != CURLE_OK)
|
if(result)
|
||||||
goto out;
|
goto out;
|
||||||
result = set_login(conn, user, passwd, options);
|
result = set_login(conn, user, passwd, options);
|
||||||
if(result != CURLE_OK)
|
if(result)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
|
@ -5430,7 +5430,7 @@ static CURLcode create_conn(struct SessionHandle *data,
|
||||||
* we figured out what/if proxy to use.
|
* we figured out what/if proxy to use.
|
||||||
*************************************************************/
|
*************************************************************/
|
||||||
result = setup_connection_internals(conn);
|
result = setup_connection_internals(conn);
|
||||||
if(result != CURLE_OK)
|
if(result)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
conn->recv[FIRSTSOCKET] = Curl_recv_plain;
|
conn->recv[FIRSTSOCKET] = Curl_recv_plain;
|
||||||
|
@ -5450,7 +5450,7 @@ static CURLcode create_conn(struct SessionHandle *data,
|
||||||
result = conn->handler->connect_it(conn, &done);
|
result = conn->handler->connect_it(conn, &done);
|
||||||
|
|
||||||
/* Setup a "faked" transfer that'll do nothing */
|
/* Setup a "faked" transfer that'll do nothing */
|
||||||
if(CURLE_OK == result) {
|
if(!result) {
|
||||||
conn->data = data;
|
conn->data = data;
|
||||||
conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are "connected */
|
conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are "connected */
|
||||||
|
|
||||||
|
@ -5763,14 +5763,14 @@ CURLcode Curl_connect(struct SessionHandle *data,
|
||||||
bool *asyncp,
|
bool *asyncp,
|
||||||
bool *protocol_done)
|
bool *protocol_done)
|
||||||
{
|
{
|
||||||
CURLcode code;
|
CURLcode result;
|
||||||
|
|
||||||
*asyncp = FALSE; /* assume synchronous resolves by default */
|
*asyncp = FALSE; /* assume synchronous resolves by default */
|
||||||
|
|
||||||
/* call the stuff that needs to be called */
|
/* call the stuff that needs to be called */
|
||||||
code = create_conn(data, in_connect, asyncp);
|
result = create_conn(data, in_connect, asyncp);
|
||||||
|
|
||||||
if(CURLE_OK == code) {
|
if(!result) {
|
||||||
/* no error */
|
/* no error */
|
||||||
if((*in_connect)->send_pipe->size || (*in_connect)->recv_pipe->size)
|
if((*in_connect)->send_pipe->size || (*in_connect)->recv_pipe->size)
|
||||||
/* pipelining */
|
/* pipelining */
|
||||||
|
@ -5779,23 +5779,23 @@ CURLcode Curl_connect(struct SessionHandle *data,
|
||||||
/* DNS resolution is done: that's either because this is a reused
|
/* DNS resolution is done: that's either because this is a reused
|
||||||
connection, in which case DNS was unnecessary, or because DNS
|
connection, in which case DNS was unnecessary, or because DNS
|
||||||
really did finish already (synch resolver/fast async resolve) */
|
really did finish already (synch resolver/fast async resolve) */
|
||||||
code = Curl_setup_conn(*in_connect, protocol_done);
|
result = Curl_setup_conn(*in_connect, protocol_done);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(code == CURLE_NO_CONNECTION_AVAILABLE) {
|
if(result == CURLE_NO_CONNECTION_AVAILABLE) {
|
||||||
*in_connect = NULL;
|
*in_connect = NULL;
|
||||||
return code;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(code && *in_connect) {
|
if(result && *in_connect) {
|
||||||
/* We're not allowed to return failure with memory left allocated
|
/* We're not allowed to return failure with memory left allocated
|
||||||
in the connectdata struct, free those here */
|
in the connectdata struct, free those here */
|
||||||
Curl_disconnect(*in_connect, FALSE); /* close the connection */
|
Curl_disconnect(*in_connect, FALSE); /* close the connection */
|
||||||
*in_connect = NULL; /* return a NULL */
|
*in_connect = NULL; /* return a NULL */
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CURLcode Curl_done(struct connectdata **connp,
|
CURLcode Curl_done(struct connectdata **connp,
|
||||||
|
@ -6002,7 +6002,7 @@ CURLcode Curl_do(struct connectdata **connp, bool *done)
|
||||||
if(!data->multi) {
|
if(!data->multi) {
|
||||||
result = Curl_reconnect_request(connp);
|
result = Curl_reconnect_request(connp);
|
||||||
|
|
||||||
if(result == CURLE_OK) {
|
if(!result) {
|
||||||
/* ... finally back to actually retry the DO phase */
|
/* ... finally back to actually retry the DO phase */
|
||||||
conn = *connp; /* re-assign conn since Curl_reconnect_request
|
conn = *connp; /* re-assign conn since Curl_reconnect_request
|
||||||
creates a new connection */
|
creates a new connection */
|
||||||
|
@ -6013,7 +6013,7 @@ CURLcode Curl_do(struct connectdata **connp, bool *done)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((result == CURLE_OK) && *done)
|
if(!result && *done)
|
||||||
/* do_complete must be called after the protocol-specific DO function */
|
/* do_complete must be called after the protocol-specific DO function */
|
||||||
do_complete(conn);
|
do_complete(conn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,35 +279,35 @@ void Curl_ssl_cleanup(void)
|
||||||
CURLcode
|
CURLcode
|
||||||
Curl_ssl_connect(struct connectdata *conn, int sockindex)
|
Curl_ssl_connect(struct connectdata *conn, int sockindex)
|
||||||
{
|
{
|
||||||
CURLcode res;
|
CURLcode result;
|
||||||
/* mark this is being ssl-enabled from here on. */
|
/* mark this is being ssl-enabled from here on. */
|
||||||
conn->ssl[sockindex].use = TRUE;
|
conn->ssl[sockindex].use = TRUE;
|
||||||
conn->ssl[sockindex].state = ssl_connection_negotiating;
|
conn->ssl[sockindex].state = ssl_connection_negotiating;
|
||||||
|
|
||||||
res = curlssl_connect(conn, sockindex);
|
result = curlssl_connect(conn, sockindex);
|
||||||
|
|
||||||
if(!res)
|
if(!result)
|
||||||
Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSL is connected */
|
Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSL is connected */
|
||||||
|
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CURLcode
|
CURLcode
|
||||||
Curl_ssl_connect_nonblocking(struct connectdata *conn, int sockindex,
|
Curl_ssl_connect_nonblocking(struct connectdata *conn, int sockindex,
|
||||||
bool *done)
|
bool *done)
|
||||||
{
|
{
|
||||||
CURLcode res;
|
CURLcode result;
|
||||||
/* mark this is being ssl requested from here on. */
|
/* mark this is being ssl requested from here on. */
|
||||||
conn->ssl[sockindex].use = TRUE;
|
conn->ssl[sockindex].use = TRUE;
|
||||||
#ifdef curlssl_connect_nonblocking
|
#ifdef curlssl_connect_nonblocking
|
||||||
res = curlssl_connect_nonblocking(conn, sockindex, done);
|
result = curlssl_connect_nonblocking(conn, sockindex, done);
|
||||||
#else
|
#else
|
||||||
*done = TRUE; /* fallback to BLOCKING */
|
*done = TRUE; /* fallback to BLOCKING */
|
||||||
res = curlssl_connect(conn, sockindex);
|
result = curlssl_connect(conn, sockindex);
|
||||||
#endif /* non-blocking connect support */
|
#endif /* non-blocking connect support */
|
||||||
if(!res && *done)
|
if(!result && *done)
|
||||||
Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSL is connected */
|
Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSL is connected */
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -633,7 +633,7 @@ CURLcode Curl_ssl_push_certinfo_len(struct SessionHandle *data,
|
||||||
struct curl_certinfo * ci = &data->info.certs;
|
struct curl_certinfo * ci = &data->info.certs;
|
||||||
char * output;
|
char * output;
|
||||||
struct curl_slist * nl;
|
struct curl_slist * nl;
|
||||||
CURLcode res = CURLE_OK;
|
CURLcode result = CURLE_OK;
|
||||||
size_t labellen = strlen(label);
|
size_t labellen = strlen(label);
|
||||||
size_t outlen = labellen + 1 + valuelen + 1; /* label:value\0 */
|
size_t outlen = labellen + 1 + valuelen + 1; /* label:value\0 */
|
||||||
|
|
||||||
|
@ -654,11 +654,11 @@ CURLcode Curl_ssl_push_certinfo_len(struct SessionHandle *data,
|
||||||
if(!nl) {
|
if(!nl) {
|
||||||
free(output);
|
free(output);
|
||||||
curl_slist_free_all(ci->certinfo[certnum]);
|
curl_slist_free_all(ci->certinfo[certnum]);
|
||||||
res = CURLE_OUT_OF_MEMORY;
|
result = CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
ci->certinfo[certnum] = nl;
|
ci->certinfo[certnum] = nl;
|
||||||
return res;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -879,7 +879,7 @@ CURLcode Curl_extract_certinfo(struct connectdata * conn,
|
||||||
char * cp1;
|
char * cp1;
|
||||||
size_t cl1;
|
size_t cl1;
|
||||||
char * cp2;
|
char * cp2;
|
||||||
CURLcode cc;
|
CURLcode result;
|
||||||
unsigned long version;
|
unsigned long version;
|
||||||
size_t i;
|
size_t i;
|
||||||
size_t j;
|
size_t j;
|
||||||
|
@ -993,11 +993,11 @@ CURLcode Curl_extract_certinfo(struct connectdata * conn,
|
||||||
free((char *) ccp);
|
free((char *) ccp);
|
||||||
|
|
||||||
/* Generate PEM certificate. */
|
/* Generate PEM certificate. */
|
||||||
cc = Curl_base64_encode(data, cert.certificate.beg,
|
result = Curl_base64_encode(data, cert.certificate.beg,
|
||||||
cert.certificate.end - cert.certificate.beg,
|
cert.certificate.end - cert.certificate.beg,
|
||||||
&cp1, &cl1);
|
&cp1, &cl1);
|
||||||
if(cc != CURLE_OK)
|
if(result)
|
||||||
return cc;
|
return result;
|
||||||
/* Compute the number of characters in final certificate string. Format is:
|
/* Compute the number of characters in final certificate string. Format is:
|
||||||
-----BEGIN CERTIFICATE-----\n
|
-----BEGIN CERTIFICATE-----\n
|
||||||
<max 64 base64 characters>\n
|
<max 64 base64 characters>\n
|
||||||
|
|
Загрузка…
Ссылка в новой задаче