1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

checksrc: warn for assignments within if() expressions

... they're already frowned upon in our source code style guide, this
now enforces the rule harder.
This commit is contained in:
Daniel Stenberg 2016-12-14 01:29:44 +01:00
parent b228d2952b
commit 1c3e8bbfed
86 changed files with 413 additions and 226 deletions

View File

@ -200,7 +200,8 @@ static int ssl_app_verify_callback(X509_STORE_CTX *ctx, void *arg)
if(p->verbose > 1) if(p->verbose > 1)
X509_print_ex(p->errorbio, ctx->cert, 0, 0); X509_print_ex(p->errorbio, ctx->cert, 0, 0);
if(accessinfo = my_get_ext(ctx->cert, p->accesstype, NID_sinfo_access)) { accessinfo = my_get_ext(ctx->cert, p->accesstype, NID_sinfo_access);
if(accessinfo) {
if(p->verbose) if(p->verbose)
BIO_printf(p->errorbio, "Setting URL from SIA to: %s\n", accessinfo); BIO_printf(p->errorbio, "Setting URL from SIA to: %s\n", accessinfo);
@ -355,7 +356,8 @@ int main(int argc, char **argv)
} }
else if(strcmp(*args, "-accesstype") == 0) { else if(strcmp(*args, "-accesstype") == 0) {
if(args[1]) { if(args[1]) {
if((p.accesstype = OBJ_obj2nid(OBJ_txt2obj(*++args, 0))) == 0) p.accesstype = OBJ_obj2nid(OBJ_txt2obj(*++args, 0));
if(p.accesstype == 0)
badarg=1; badarg=1;
} }
else else
@ -410,16 +412,19 @@ int main(int argc, char **argv)
p.errorbio = BIO_new_fp(stderr, BIO_NOCLOSE); p.errorbio = BIO_new_fp(stderr, BIO_NOCLOSE);
if(!(p.curl = curl_easy_init())) { p.curl = curl_easy_init();
if(!p.curl) {
BIO_printf(p.errorbio, "Cannot init curl lib\n"); BIO_printf(p.errorbio, "Cannot init curl lib\n");
goto err; goto err;
} }
if(!(p12bio = BIO_new_file(p.p12file, "rb"))) { p12bio = BIO_new_file(p.p12file, "rb");
if(!p12bio) {
BIO_printf(p.errorbio, "Error opening P12 file %s\n", p.p12file); BIO_printf(p.errorbio, "Error opening P12 file %s\n", p.p12file);
goto err; goto err;
} }
if(!(p.p12 = d2i_PKCS12_bio(p12bio, NULL))) { p.p12 = d2i_PKCS12_bio(p12bio, NULL);
if(!p.p12) {
BIO_printf(p.errorbio, "Cannot decode P12 structure %s\n", p.p12file); BIO_printf(p.errorbio, "Cannot decode P12 structure %s\n", p.p12file);
goto err; goto err;
} }
@ -447,16 +452,19 @@ int main(int argc, char **argv)
} }
else if(p.accesstype != 0) { /* see whether we can find an AIA or SIA for a else if(p.accesstype != 0) { /* see whether we can find an AIA or SIA for a
given access type */ given access type */
if(!(serverurl = my_get_ext(p.usercert, p.accesstype, NID_info_access))) { serverurl = my_get_ext(p.usercert, p.accesstype, NID_info_access);
if(!serverurl) {
int j=0; int j=0;
BIO_printf(p.errorbio, "no service URL in user cert " BIO_printf(p.errorbio, "no service URL in user cert "
"cherching in others certificats\n"); "cherching in others certificats\n");
for(j=0; j<sk_X509_num(p.ca); j++) { for(j=0; j<sk_X509_num(p.ca); j++) {
if((serverurl = my_get_ext(sk_X509_value(p.ca, j), p.accesstype, serverurl = my_get_ext(sk_X509_value(p.ca, j), p.accesstype,
NID_info_access))) NID_info_access);
if(serverurl)
break; break;
if((serverurl = my_get_ext(sk_X509_value(p.ca, j), p.accesstype, serverurl = my_get_ext(sk_X509_value(p.ca, j), p.accesstype,
NID_sinfo_access))) NID_sinfo_access);
if(serverurl)
break; break;
} }
} }

View File

@ -90,9 +90,8 @@ int main(void)
#ifdef WIN32 #ifdef WIN32
WSADATA wsaData; WSADATA wsaData;
int initwsa; int initwsa = WSAStartup(MAKEWORD(2, 0), &wsaData);
if(initwsa != 0) {
if((initwsa = WSAStartup(MAKEWORD(2, 0), &wsaData)) != 0) {
printf("WSAStartup failed: %d\n", initwsa); printf("WSAStartup failed: %d\n", initwsa);
return 1; return 1;
} }
@ -107,7 +106,8 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999"); curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999");
/* Create the socket "manually" */ /* Create the socket "manually" */
if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == CURL_SOCKET_BAD) { sockfd = socket(AF_INET, SOCK_STREAM, 0);
if(sockfd == CURL_SOCKET_BAD) {
printf("Error creating listening socket.\n"); printf("Error creating listening socket.\n");
return 3; return 3;
} }
@ -116,7 +116,8 @@ int main(void)
servaddr.sin_family = AF_INET; servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(PORTNUM); servaddr.sin_port = htons(PORTNUM);
if(INADDR_NONE == (servaddr.sin_addr.s_addr = inet_addr(IPADDR))) servaddr.sin_addr.s_addr = inet_addr(IPADDR);
if(INADDR_NONE == servaddr.sin_addr.s_addr)
return 2; return 2;
if(connect(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) == if(connect(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) ==

View File

@ -62,12 +62,14 @@ static int _getch(void)
/* error handling macros */ /* error handling macros */
#define my_curl_easy_setopt(A, B, C) \ #define my_curl_easy_setopt(A, B, C) \
if((res = curl_easy_setopt((A), (B), (C))) != CURLE_OK) \ res = curl_easy_setopt((A), (B), (C)); \
if(!res) \
fprintf(stderr, "curl_easy_setopt(%s, %s, %s) failed: %d\n", \ fprintf(stderr, "curl_easy_setopt(%s, %s, %s) failed: %d\n", \
#A, #B, #C, res); #A, #B, #C, res);
#define my_curl_easy_perform(A) \ #define my_curl_easy_perform(A) \
if((res = curl_easy_perform((A))) != CURLE_OK) \ res = curl_easy_perform(A); \
if(!res) \
fprintf(stderr, "curl_easy_perform(%s) failed: %d\n", #A, res); fprintf(stderr, "curl_easy_perform(%s) failed: %d\n", #A, res);

View File

@ -356,6 +356,14 @@ sub scanfile {
} }
} }
if($nostr =~ /^((.*)(if) *\()(.*)\)/) {
my $pos = length($1);
if($4 =~ / = /) {
checkwarn("ASSIGNWITHINCONDITION",
$line, $pos+1, $file, $l,
"assignment within conditional expression");
}
}
# check spaces after open parentheses # check spaces after open parentheses
if($l =~ /^(.*[a-z])\( /i) { if($l =~ /^(.*[a-z])\( /i) {
checkwarn("SPACEAFTERPAREN", checkwarn("SPACEAFTERPAREN",

View File

@ -798,8 +798,8 @@ Curl_cookie_add(struct Curl_easy *data,
/* Check if the domain is a Public Suffix and if yes, ignore the cookie. /* Check if the domain is a Public Suffix and if yes, ignore the cookie.
This needs a libpsl compiled with builtin data. */ This needs a libpsl compiled with builtin data. */
if(domain && co->domain && !isip(co->domain)) { if(domain && co->domain && !isip(co->domain)) {
if(((psl = psl_builtin()) != NULL) psl = psl_builtin();
&& !psl_is_cookie_domain_acceptable(psl, domain, co->domain)) { if(psl && !psl_is_cookie_domain_acceptable(psl, domain, co->domain)) {
infof(data, infof(data,
"cookie '%s' dropped, domain '%s' must not set cookies for '%s'\n", "cookie '%s' dropped, domain '%s' must not set cookies for '%s'\n",
co->name, domain, co->domain); co->name, domain, co->domain);

View File

@ -146,7 +146,8 @@ Curl_getaddrinfo_ex(const char *nodename,
if((size_t)ai->ai_addrlen < ss_size) if((size_t)ai->ai_addrlen < ss_size)
continue; continue;
if((ca = malloc(sizeof(Curl_addrinfo))) == NULL) { ca = malloc(sizeof(Curl_addrinfo));
if(!ca) {
error = EAI_MEMORY; error = EAI_MEMORY;
break; break;
} }
@ -163,7 +164,8 @@ Curl_getaddrinfo_ex(const char *nodename,
ca->ai_canonname = NULL; ca->ai_canonname = NULL;
ca->ai_next = NULL; ca->ai_next = NULL;
if((ca->ai_addr = malloc(ss_size)) == NULL) { ca->ai_addr = malloc(ss_size);
if(!ca->ai_addr) {
error = EAI_MEMORY; error = EAI_MEMORY;
free(ca); free(ca);
break; break;
@ -171,7 +173,8 @@ Curl_getaddrinfo_ex(const char *nodename,
memcpy(ca->ai_addr, ai->ai_addr, ss_size); memcpy(ca->ai_addr, ai->ai_addr, ss_size);
if(ai->ai_canonname != NULL) { if(ai->ai_canonname != NULL) {
if((ca->ai_canonname = strdup(ai->ai_canonname)) == NULL) { ca->ai_canonname = strdup(ai->ai_canonname);
if(!ca->ai_canonname) {
error = EAI_MEMORY; error = EAI_MEMORY;
free(ca->ai_addr); free(ca->ai_addr);
free(ca); free(ca);
@ -291,16 +294,19 @@ Curl_he2ai(const struct hostent *he, int port)
#endif #endif
ss_size = sizeof(struct sockaddr_in); ss_size = sizeof(struct sockaddr_in);
if((ai = calloc(1, sizeof(Curl_addrinfo))) == NULL) { ai = calloc(1, sizeof(Curl_addrinfo));
if(!ai) {
result = CURLE_OUT_OF_MEMORY; result = CURLE_OUT_OF_MEMORY;
break; break;
} }
if((ai->ai_canonname = strdup(he->h_name)) == NULL) { ai->ai_canonname = strdup(he->h_name);
if(!ai->ai_canonname) {
result = CURLE_OUT_OF_MEMORY; result = CURLE_OUT_OF_MEMORY;
free(ai); free(ai);
break; break;
} }
if((ai->ai_addr = calloc(1, ss_size)) == NULL) { ai->ai_addr = calloc(1, ss_size);
if(!ai->ai_addr) {
result = CURLE_OUT_OF_MEMORY; result = CURLE_OUT_OF_MEMORY;
free(ai->ai_canonname); free(ai->ai_canonname);
free(ai); free(ai);
@ -475,8 +481,9 @@ Curl_addrinfo *Curl_str2addr(char *address, int port)
/** /**
* Given a path to a Unix domain socket, return a newly allocated Curl_addrinfo * Given a path to a Unix domain socket, return a newly allocated Curl_addrinfo
* struct initialized with this path. * struct initialized with this path.
* Set '*longpath' to TRUE if the error is a too long path.
*/ */
Curl_addrinfo *Curl_unix2addr(const char *path) Curl_addrinfo *Curl_unix2addr(const char *path, int *longpath)
{ {
Curl_addrinfo *ai; Curl_addrinfo *ai;
struct sockaddr_un *sa_un; struct sockaddr_un *sa_un;
@ -485,8 +492,10 @@ Curl_addrinfo *Curl_unix2addr(const char *path)
ai = calloc(1, sizeof(Curl_addrinfo)); ai = calloc(1, sizeof(Curl_addrinfo));
if(!ai) if(!ai)
return NULL; return NULL;
if((ai->ai_addr = calloc(1, sizeof(struct sockaddr_un))) == NULL) { ai->ai_addr = calloc(1, sizeof(struct sockaddr_un));
if(!ai->ai_addr) {
free(ai); free(ai);
*longpath = FALSE;
return NULL; return NULL;
} }
/* sun_path must be able to store the NUL-terminated path */ /* sun_path must be able to store the NUL-terminated path */
@ -494,6 +503,7 @@ Curl_addrinfo *Curl_unix2addr(const char *path)
if(path_len >= sizeof(sa_un->sun_path)) { if(path_len >= sizeof(sa_un->sun_path)) {
free(ai->ai_addr); free(ai->ai_addr);
free(ai); free(ai);
*longpath = TRUE;
return NULL; return NULL;
} }

View File

@ -80,7 +80,7 @@ Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port);
Curl_addrinfo *Curl_str2addr(char *dotted, int port); Curl_addrinfo *Curl_str2addr(char *dotted, int port);
#ifdef USE_UNIX_SOCKETS #ifdef USE_UNIX_SOCKETS
Curl_addrinfo *Curl_unix2addr(const char *path); Curl_addrinfo *Curl_unix2addr(const char *path, int *longpath);
#endif #endif
#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \ #if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \

View File

@ -157,7 +157,8 @@ static CURLcode ntlm_wb_init(struct connectdata *conn, const char *userp)
} }
slash = strpbrk(username, "\\/"); slash = strpbrk(username, "\\/");
if(slash) { if(slash) {
if((domain = strdup(username)) == NULL) domain = strdup(username);
if(!domain)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
slash = domain + (slash - username); slash = domain + (slash - username);
*slash = '\0'; *slash = '\0';

View File

@ -949,8 +949,8 @@ void Curl_formclean(struct FormData **form_ptr)
if(form->type <= FORM_CONTENT) if(form->type <= FORM_CONTENT)
free(form->line); /* free the line */ free(form->line); /* free the line */
free(form); /* free the struct */ free(form); /* free the struct */
form = next;
} while((form = next) != NULL); /* continue */ } while(form); /* continue */
*form_ptr = NULL; *form_ptr = NULL;
} }
@ -1031,8 +1031,8 @@ void curl_formfree(struct curl_httppost *form)
free(form->contenttype); /* free the content type */ free(form->contenttype); /* free the content type */
free(form->showfilename); /* free the faked file name */ free(form->showfilename); /* free the faked file name */
free(form); /* free the struct */ free(form); /* free the struct */
form = next;
} while((form = next) != NULL); /* continue */ } while(form); /* continue */
} }
#ifndef HAVE_BASENAME #ifndef HAVE_BASENAME
@ -1374,8 +1374,8 @@ CURLcode Curl_getformdata(struct Curl_easy *data,
if(result) if(result)
break; break;
} }
post = post->next;
} while((post = post->next) != NULL); /* for each field */ } while(post); /* for each field */
/* end-boundary for everything */ /* end-boundary for everything */
if(!result) if(!result)

View File

@ -1035,7 +1035,8 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
if(*string_ftpport == '[') { if(*string_ftpport == '[') {
/* [ipv6]:port(-range) */ /* [ipv6]:port(-range) */
ip_start = string_ftpport + 1; ip_start = string_ftpport + 1;
if((ip_end = strchr(string_ftpport, ']')) != NULL) ip_end = strchr(string_ftpport, ']');
if(ip_end)
strncpy(addr, ip_start, ip_end - ip_start); strncpy(addr, ip_start, ip_end - ip_start);
} }
else else
@ -1044,7 +1045,9 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
/* :port */ /* :port */
ip_end = string_ftpport; ip_end = string_ftpport;
} }
else if((ip_end = strchr(string_ftpport, ':')) != NULL) { else {
ip_end = strchr(string_ftpport, ':');
if(ip_end) {
/* either ipv6 or (ipv4|domain|interface):port(-range) */ /* either ipv6 or (ipv4|domain|interface):port(-range) */
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
if(Curl_inet_pton(AF_INET6, string_ftpport, sa6) == 1) { if(Curl_inet_pton(AF_INET6, string_ftpport, sa6) == 1) {
@ -1061,12 +1064,15 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
else else
/* ipv4|interface */ /* ipv4|interface */
strcpy(addr, string_ftpport); strcpy(addr, string_ftpport);
}
/* parse the port */ /* parse the port */
if(ip_end != NULL) { if(ip_end != NULL) {
if((port_start = strchr(ip_end, ':')) != NULL) { port_start = strchr(ip_end, ':');
if(port_start) {
port_min = curlx_ultous(strtoul(port_start+1, NULL, 10)); port_min = curlx_ultous(strtoul(port_start+1, NULL, 10));
if((port_sep = strchr(port_start, '-')) != NULL) { port_sep = strchr(port_start, '-');
if(port_sep) {
port_max = curlx_ultous(strtoul(port_sep + 1, NULL, 10)); port_max = curlx_ultous(strtoul(port_sep + 1, NULL, 10));
} }
else else

View File

@ -840,11 +840,13 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy,
auth += strlen("NTLM"); auth += strlen("NTLM");
while(*auth && ISSPACE(*auth)) while(*auth && ISSPACE(*auth))
auth++; auth++;
if(*auth) if(*auth) {
if((conn->challenge_header = strdup(auth)) == NULL) conn->challenge_header = strdup(auth);
if(!conn->challenge_header)
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
} }
}
#endif #endif
} }
else { else {

View File

@ -75,7 +75,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
CURLcode result; CURLcode result;
struct Curl_easy *data = conn->data; struct Curl_easy *data = conn->data;
unsigned char *path; unsigned char *path;
char *tmp; char *tmp = NULL;
char *response; char *response;
size_t len; size_t len;
bool have_chlg; bool have_chlg;
@ -140,12 +140,14 @@ CURLcode Curl_output_digest(struct connectdata *conn,
http://www.fngtps.com/2006/09/http-authentication http://www.fngtps.com/2006/09/http-authentication
*/ */
if(authp->iestyle && ((tmp = strchr((char *)uripath, '?')) != NULL)) { if(authp->iestyle) {
tmp = strchr((char *)uripath, '?');
if(tmp) {
size_t urilen = tmp - (char *)uripath; size_t urilen = tmp - (char *)uripath;
path = (unsigned char *) aprintf("%.*s", urilen, uripath); path = (unsigned char *) aprintf("%.*s", urilen, uripath);
} }
else }
if(!tmp)
path = (unsigned char *) strdup((char *) uripath); path = (unsigned char *) strdup((char *) uripath);
if(!path) if(!path)

View File

@ -103,7 +103,8 @@ inet_pton4(const char *src, unsigned char *dst)
while((ch = *src++) != '\0') { while((ch = *src++) != '\0') {
const char *pch; const char *pch;
if((pch = strchr(digits, ch)) != NULL) { pch = strchr(digits, ch);
if(pch) {
unsigned int val = *tp * 10 + (unsigned int)(pch - digits); unsigned int val = *tp * 10 + (unsigned int)(pch - digits);
if(saw_digit && *tp == 0) if(saw_digit && *tp == 0)
@ -169,7 +170,8 @@ inet_pton6(const char *src, unsigned char *dst)
while((ch = *src++) != '\0') { while((ch = *src++) != '\0') {
const char *pch; const char *pch;
if((pch = strchr((xdigits = xdigits_l), ch)) == NULL) pch = strchr((xdigits = xdigits_l), ch);
if(!pch)
pch = strchr((xdigits = xdigits_u), ch); pch = strchr((xdigits = xdigits_u), ch);
if(pch != NULL) { if(pch != NULL) {
val <<= 4; val <<= 4;

View File

@ -213,7 +213,8 @@ static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
unsigned long used, available; unsigned long used, available;
saved_lo = ctx->lo; saved_lo = ctx->lo;
if((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) ctx->lo = (saved_lo + size) & 0x1fffffff;
if(ctx->lo < saved_lo)
ctx->hi++; ctx->hi++;
ctx->hi += (MD4_u32plus)size >> 29; ctx->hi += (MD4_u32plus)size >> 29;

View File

@ -402,7 +402,8 @@ static void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
unsigned long used, available; unsigned long used, available;
saved_lo = ctx->lo; saved_lo = ctx->lo;
if((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) ctx->lo = (saved_lo + size) & 0x1fffffff;
if(ctx->lo < saved_lo)
ctx->hi++; ctx->hi++;
ctx->hi += (MD5_u32plus)size >> 29; ctx->hi += (MD5_u32plus)size >> 29;

View File

@ -184,7 +184,8 @@ int GetOrSetUpData(int id, libdata_t **appData,
*/ */
NXLock(gLibLock); NXLock(gLibLock);
if(!(app_data = (libdata_t *) get_app_data(id))) { app_data = (libdata_t *) get_app_data(id);
if(!app_data) {
app_data = malloc(sizeof(libdata_t)); app_data = malloc(sizeof(libdata_t));
if(app_data) { if(app_data) {
@ -259,7 +260,8 @@ int GetOrSetUpData(int id, libdata_t **appData,
err = ENOMEM; err = ENOMEM;
} }
if((err = NXKeySetValue(key, thread_data))) { err = NXKeySetValue(key, thread_data);
if(err) {
free(thread_data->twentybytes); free(thread_data->twentybytes);
free(thread_data); free(thread_data);
thread_data = (libthreaddata_t *) NULL; thread_data = (libthreaddata_t *) NULL;

View File

@ -782,14 +782,14 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
state(conn, SSH_AUTH_DONE); state(conn, SSH_AUTH_DONE);
break; break;
} }
else if((err = libssh2_session_last_errno(sshc->ssh_session)) == else {
LIBSSH2_ERROR_EAGAIN) { err = libssh2_session_last_errno(sshc->ssh_session);
if(err == LIBSSH2_ERROR_EAGAIN)
rc = LIBSSH2_ERROR_EAGAIN; rc = LIBSSH2_ERROR_EAGAIN;
break;
}
else { else {
state(conn, SSH_SESSION_FREE); state(conn, SSH_SESSION_FREE);
sshc->actualcode = libssh2_session_error_to_CURLE(err); sshc->actualcode = libssh2_session_error_to_CURLE(err);
}
break; break;
} }
} }
@ -1987,12 +1987,14 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break; break;
} }
} }
if((sshc->readdir_filename = malloc(PATH_MAX+1)) == NULL) { sshc->readdir_filename = malloc(PATH_MAX+1);
if(!sshc->readdir_filename) {
state(conn, SSH_SFTP_CLOSE); state(conn, SSH_SFTP_CLOSE);
sshc->actualcode = CURLE_OUT_OF_MEMORY; sshc->actualcode = CURLE_OUT_OF_MEMORY;
break; break;
} }
if((sshc->readdir_longentry = malloc(PATH_MAX+1)) == NULL) { sshc->readdir_longentry = malloc(PATH_MAX+1);
if(!sshc->readdir_longentry) {
Curl_safefree(sshc->readdir_filename); Curl_safefree(sshc->readdir_filename);
state(conn, SSH_SFTP_CLOSE); state(conn, SSH_SFTP_CLOSE);
sshc->actualcode = CURLE_OUT_OF_MEMORY; sshc->actualcode = CURLE_OUT_OF_MEMORY;
@ -2789,13 +2791,16 @@ static int ssh_getsock(struct connectdata *conn,
static void ssh_block2waitfor(struct connectdata *conn, bool block) static void ssh_block2waitfor(struct connectdata *conn, bool block)
{ {
struct ssh_conn *sshc = &conn->proto.sshc; struct ssh_conn *sshc = &conn->proto.sshc;
int dir; int dir = 0;
if(block && (dir = libssh2_session_block_directions(sshc->ssh_session))) { if(block) {
dir = libssh2_session_block_directions(sshc->ssh_session);
if(dir) {
/* translate the libssh2 define bits into our own bit defines */ /* translate the libssh2 define bits into our own bit defines */
conn->waitfor = ((dir&LIBSSH2_SESSION_BLOCK_INBOUND)?KEEP_RECV:0) | conn->waitfor = ((dir&LIBSSH2_SESSION_BLOCK_INBOUND)?KEEP_RECV:0) |
((dir&LIBSSH2_SESSION_BLOCK_OUTBOUND)?KEEP_SEND:0); ((dir&LIBSSH2_SESSION_BLOCK_OUTBOUND)?KEEP_SEND:0);
} }
else }
if(!dir)
/* It didn't block or libssh2 didn't reveal in which direction, put back /* It didn't block or libssh2 didn't reveal in which direction, put back
the original set */ the original set */
conn->waitfor = sshc->orig_waitfor; conn->waitfor = sshc->orig_waitfor;

View File

@ -715,9 +715,11 @@ const char *Curl_strerror(struct connectdata *conn, int err)
buf[max] = '\0'; /* make sure the string is zero terminated */ buf[max] = '\0'; /* make sure the string is zero terminated */
/* strip trailing '\r\n' or '\n'. */ /* strip trailing '\r\n' or '\n'. */
if((p = strrchr(buf, '\n')) != NULL && (p - buf) >= 2) p = strrchr(buf, '\n');
if(p && (p - buf) >= 2)
*p = '\0'; *p = '\0';
if((p = strrchr(buf, '\r')) != NULL && (p - buf) >= 1) p = strrchr(buf, '\r');
if(p && (p - buf) >= 1)
*p = '\0'; *p = '\0';
if(old_errno != ERRNO) if(old_errno != ERRNO)
@ -1035,9 +1037,11 @@ const char *Curl_sspi_strerror (struct connectdata *conn, int err)
if(msg_formatted) { if(msg_formatted) {
msgbuf[sizeof(msgbuf)-1] = '\0'; msgbuf[sizeof(msgbuf)-1] = '\0';
/* strip trailing '\r\n' or '\n' */ /* strip trailing '\r\n' or '\n' */
if((p = strrchr(msgbuf, '\n')) != NULL && (p - msgbuf) >= 2) p = strrchr(msgbuf, '\n');
if(p && (p - msgbuf) >= 2)
*p = '\0'; *p = '\0';
if((p = strrchr(msgbuf, '\r')) != NULL && (p - msgbuf) >= 1) p = strrchr(msgbuf, '\r');
if(p && (p - msgbuf) >= 1)
*p = '\0'; *p = '\0';
msg = msgbuf; msg = msgbuf;
} }

View File

@ -1489,7 +1489,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
events.lNetworkEvents = 0; events.lNetworkEvents = 0;
if(SOCKET_ERROR == enum_netevents_func(sockfd, event_handle, &events)) { if(SOCKET_ERROR == enum_netevents_func(sockfd, event_handle, &events)) {
if((err = SOCKERRNO) != EINPROGRESS) { err = SOCKERRNO;
if(err != EINPROGRESS) {
infof(data, "WSAEnumNetworkEvents failed (%d)", err); infof(data, "WSAEnumNetworkEvents failed (%d)", err);
keepon = FALSE; keepon = FALSE;
result = CURLE_READ_ERROR; result = CURLE_READ_ERROR;

View File

@ -5822,11 +5822,14 @@ static CURLcode resolve_server(struct Curl_easy *data,
hostaddr = calloc(1, sizeof(struct Curl_dns_entry)); hostaddr = calloc(1, sizeof(struct Curl_dns_entry));
if(!hostaddr) if(!hostaddr)
result = CURLE_OUT_OF_MEMORY; result = CURLE_OUT_OF_MEMORY;
else if((hostaddr->addr = Curl_unix2addr(path)) != NULL) else {
int longpath=0;
hostaddr->addr = Curl_unix2addr(path, &longpath);
if(hostaddr->addr)
hostaddr->inuse++; hostaddr->inuse++;
else { else {
/* Long paths are not supported for now */ /* Long paths are not supported for now */
if(strlen(path) >= sizeof(((struct sockaddr_un *)0)->sun_path)) { if(longpath) {
failf(data, "Unix socket path too long: '%s'", path); failf(data, "Unix socket path too long: '%s'", path);
result = CURLE_COULDNT_RESOLVE_HOST; result = CURLE_COULDNT_RESOLVE_HOST;
} }
@ -5836,6 +5839,7 @@ static CURLcode resolve_server(struct Curl_easy *data,
hostaddr = NULL; hostaddr = NULL;
} }
} }
}
else else
#endif #endif
if(!conn->bits.proxy) { if(!conn->bits.proxy) {

View File

@ -242,7 +242,8 @@ static gnutls_datum_t load_file(const char *file)
long filelen; long filelen;
void *ptr; void *ptr;
if(!(f = fopen(file, "rb"))) f = fopen(file, "rb");
if(!f)
return loaded_file; return loaded_file;
if(fseek(f, 0, SEEK_END) != 0 if(fseek(f, 0, SEEK_END) != 0
|| (filelen = ftell(f)) < 0 || (filelen = ftell(f)) < 0

View File

@ -254,7 +254,8 @@ static SECStatus set_ciphers(struct Curl_easy *data, PRFileDesc * model,
while((*cipher) && (ISSPACE(*cipher))) while((*cipher) && (ISSPACE(*cipher)))
++cipher; ++cipher;
if((cipher_list = strchr(cipher, ','))) { cipher_list = strchr(cipher, ',');
if(cipher_list) {
*cipher_list++ = '\0'; *cipher_list++ = '\0';
} }

View File

@ -2336,7 +2336,8 @@ static int asn1_object_dump(ASN1_OBJECT *a, char *buf, size_t len)
{ {
int i, ilen; int i, ilen;
if((ilen = (int)len) < 0) ilen = (int)len;
if(ilen < 0)
return 1; /* buffer too big */ return 1; /* buffer too big */
i = i2t_ASN1_OBJECT(buf, ilen, a); i = i2t_ASN1_OBJECT(buf, ilen, a);

View File

@ -757,7 +757,11 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
case '@': /* the URL! */ case '@': /* the URL! */
{ {
struct getout *url; struct getout *url;
if(config->url_get || ((config->url_get = config->url_list) != NULL)) {
if(!config->url_get)
config->url_get = config->url_list;
if(config->url_get) {
/* there's a node here, if it already is filled-in continue to find /* there's a node here, if it already is filled-in continue to find
an "empty" node */ an "empty" node */
while(config->url_get && (config->url_get->flags & GETOUT_URL)) while(config->url_get && (config->url_get->flags & GETOUT_URL))
@ -1687,7 +1691,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
/* output file */ /* output file */
{ {
struct getout *url; struct getout *url;
if(config->url_out || ((config->url_out = config->url_list) != NULL)) { if(!config->url_out)
config->url_out = config->url_list;
if(config->url_out) {
/* there's a node here, if it already is filled-in continue to find /* there's a node here, if it already is filled-in continue to find
an "empty" node */ an "empty" node */
while(config->url_out && (config->url_out->flags & GETOUT_OUTFILE)) while(config->url_out && (config->url_out->flags & GETOUT_OUTFILE))
@ -1824,7 +1830,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
/* we are uploading */ /* we are uploading */
{ {
struct getout *url; struct getout *url;
if(config->url_out || ((config->url_out = config->url_list) != NULL)) { if(!config->url_out)
config->url_out = config->url_list;
if(config->url_out) {
/* there's a node here, if it already is filled-in continue to find /* there's a node here, if it already is filled-in continue to find
an "empty" node */ an "empty" node */
while(config->url_out && (config->url_out->flags & GETOUT_UPLOAD)) while(config->url_out && (config->url_out->flags & GETOUT_UPLOAD))

View File

@ -66,12 +66,15 @@ ParameterError file2string(char **bufp, FILE *file)
if(file) { if(file) {
while(fgets(buffer, sizeof(buffer), file)) { while(fgets(buffer, sizeof(buffer), file)) {
if((ptr = strchr(buffer, '\r')) != NULL) ptr = strchr(buffer, '\r');
if(ptr)
*ptr = '\0'; *ptr = '\0';
if((ptr = strchr(buffer, '\n')) != NULL) ptr = strchr(buffer, '\n');
if(ptr)
*ptr = '\0'; *ptr = '\0';
buflen = strlen(buffer); buflen = strlen(buffer);
if((ptr = realloc(string, stringlen+buflen+1)) == NULL) { ptr = realloc(string, stringlen+buflen+1);
if(!ptr) {
Curl_safefree(string); Curl_safefree(string);
return PARAM_NO_MEM; return PARAM_NO_MEM;
} }
@ -102,7 +105,8 @@ ParameterError file2memory(char **bufp, size_t *size, FILE *file)
} }
alloc *= 2; alloc *= 2;
/* allocate an extra char, reserved space, for null termination */ /* allocate an extra char, reserved space, for null termination */
if((newbuf = realloc(buffer, alloc+1)) == NULL) { newbuf = realloc(buffer, alloc+1);
if(!newbuf) {
Curl_safefree(buffer); Curl_safefree(buffer);
return PARAM_NO_MEM; return PARAM_NO_MEM;
} }
@ -115,7 +119,8 @@ ParameterError file2memory(char **bufp, size_t *size, FILE *file)
buffer[nused] = '\0'; buffer[nused] = '\0';
/* free trailing slack space, if possible */ /* free trailing slack space, if possible */
if(alloc != nused) { if(alloc != nused) {
if((newbuf = realloc(buffer, nused+1)) == NULL) { newbuf = realloc(buffer, nused+1);
if(!newbuf) {
Curl_safefree(buffer); Curl_safefree(buffer);
return PARAM_NO_MEM; return PARAM_NO_MEM;
} }

View File

@ -124,9 +124,14 @@ void ourWriteOut(CURL *curl, struct OutStruct *outs, const char *writeinfo)
char *end; char *end;
char keepit; char keepit;
int i; int i;
if(('{' == ptr[1]) && ((end = strchr(ptr, '}')) != NULL)) { if('{' == ptr[1]) {
bool match = FALSE; bool match = FALSE;
end = strchr(ptr, '}');
ptr += 2; /* pass the % and the { */ ptr += 2; /* pass the % and the { */
if(!end) {
fputs("%{", stream);
continue;
}
keepit = *end; keepit = *end;
*end = 0; /* zero terminate */ *end = 0; /* zero terminate */
for(i = 0; replacements[i].name; i++) { for(i = 0; replacements[i].name; i++) {

View File

@ -136,7 +136,8 @@ int test(char *URL)
"http://testserver.example.com:%s/%s%04d", port, path, i); "http://testserver.example.com:%s/%s%04d", port, path, i);
/* second request must succeed like the first one */ /* second request must succeed like the first one */
if((res = do_one_request(multi, target_url, dns_entry))) res = do_one_request(multi, target_url, dns_entry);
if(res)
goto test_cleanup; goto test_cleanup;
if(i < count) if(i < count)

View File

@ -81,7 +81,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -56,7 +56,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -54,7 +54,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -55,7 +55,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -37,7 +37,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
@ -36,7 +36,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____| * \___|\___/|_| \_\_____|
* *
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2016, 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
@ -46,7 +46,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -136,7 +136,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(curl == NULL) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -68,7 +68,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -35,7 +35,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -195,7 +195,8 @@ int test(char *URL)
/* prepare share */ /* prepare share */
printf("SHARE_INIT\n"); printf("SHARE_INIT\n");
if((share = curl_share_init()) == NULL) { share = curl_share_init();
if(!share) {
fprintf(stderr, "curl_share_init() failed\n"); fprintf(stderr, "curl_share_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
@ -230,7 +231,8 @@ int test(char *URL)
} }
/* initial cookie manipulation */ /* initial cookie manipulation */
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share); curl_share_cleanup(share);
curl_global_cleanup(); curl_global_cleanup();
@ -275,7 +277,8 @@ int test(char *URL)
/* fetch a another one and save cookies */ /* fetch a another one and save cookies */
printf("*** run %d\n", i); printf("*** run %d\n", i);
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share); curl_share_cleanup(share);
curl_global_cleanup(); curl_global_cleanup();
@ -302,7 +305,8 @@ int test(char *URL)
curl_slist_free_all(headers); curl_slist_free_all(headers);
/* load cookies */ /* load cookies */
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share); curl_share_cleanup(share);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -62,7 +62,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -122,7 +122,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -68,7 +68,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -33,7 +33,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -42,7 +42,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -33,7 +33,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -33,7 +33,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -33,7 +33,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -489,7 +489,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
close_file_descriptors(); close_file_descriptors();
curl_global_cleanup(); curl_global_cleanup();

View File

@ -33,7 +33,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -33,7 +33,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -33,7 +33,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -33,7 +33,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -33,7 +33,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -491,7 +491,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
close_file_descriptors(); close_file_descriptors();
curl_global_cleanup(); curl_global_cleanup();

View File

@ -35,7 +35,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -79,7 +79,8 @@ int test(char *URL)
} }
/* get a curl handle */ /* get a curl handle */
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
fclose(hd_src); fclose(hd_src);

View File

@ -42,7 +42,8 @@ int test(char *URL)
} }
/* get a curl handle */ /* get a curl handle */
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -36,7 +36,8 @@ int test(char *URL)
char *s; char *s;
(void)URL; (void)URL;
if((easy = curl_easy_init()) == NULL) { easy = curl_easy_init();
if(!easy) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }

View File

@ -47,7 +47,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -90,7 +90,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -38,7 +38,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -172,7 +172,8 @@ int test(char *URL)
config.trace_ascii = 1; /* enable ascii tracing */ config.trace_ascii = 1; /* enable ascii tracing */
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -67,7 +67,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -162,7 +162,8 @@ static int once(char *URL, bool oldstyle)
if(formrc) if(formrc)
printf("curl_formadd(4) = %d\n", (int)formrc); printf("curl_formadd(4) = %d\n", (int)formrc);
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_formfree(formpost); curl_formfree(formpost);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -45,7 +45,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -46,7 +46,8 @@ int test(char *URL)
} }
/* get a curl handle */ /* get a curl handle */
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -35,7 +35,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -37,7 +37,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -55,7 +55,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
@ -66,7 +67,8 @@ int test(char *URL)
test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }
@ -100,7 +102,8 @@ int test(char *URL)
sdpf = NULL; sdpf = NULL;
/* Make sure we can do a normal request now */ /* Make sure we can do a normal request now */
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }
@ -115,7 +118,8 @@ int test(char *URL)
/* Now do a POST style one */ /* Now do a POST style one */
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }
@ -144,7 +148,8 @@ int test(char *URL)
custom_headers = NULL; custom_headers = NULL;
/* Make sure we can do a normal request now */ /* Make sure we can do a normal request now */
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }

View File

@ -53,7 +53,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
fclose(idfile); fclose(idfile);
@ -77,7 +78,8 @@ int test(char *URL)
/* Go through the various Session IDs */ /* Go through the various Session IDs */
for(i = 0; i < 3; i++) { for(i = 0; i < 3; i++) {
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }
@ -96,7 +98,8 @@ int test(char *URL)
fprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id); fprintf(idfile, "Got Session ID: [%s]\n", rtsp_session_id);
rtsp_session_id = NULL; rtsp_session_id = NULL;
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }

View File

@ -40,7 +40,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
@ -54,7 +55,8 @@ int test(char *URL)
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS); test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }
@ -74,7 +76,8 @@ int test(char *URL)
"RAW/RAW/UDP;unicast;client_port=3056-3057"); "RAW/RAW/UDP;unicast;client_port=3056-3057");
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }
@ -88,7 +91,8 @@ int test(char *URL)
test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY); test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }

View File

@ -118,7 +118,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
fclose(protofile); fclose(protofile);
curl_global_cleanup(); curl_global_cleanup();
@ -126,7 +127,8 @@ int test(char *URL)
} }
test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }
@ -147,7 +149,8 @@ int test(char *URL)
goto test_cleanup; goto test_cleanup;
/* This PLAY starts the interleave */ /* This PLAY starts the interleave */
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }
@ -161,7 +164,8 @@ int test(char *URL)
goto test_cleanup; goto test_cleanup;
/* The DESCRIBE request will try to consume data after the Content */ /* The DESCRIBE request will try to consume data after the Content */
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }
@ -174,7 +178,8 @@ int test(char *URL)
if(res) if(res)
goto test_cleanup; goto test_cleanup;
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }

View File

@ -55,7 +55,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
@ -69,7 +70,8 @@ int test(char *URL)
test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_URL, URL);
/* SETUP */ /* SETUP */
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }
@ -83,7 +85,8 @@ int test(char *URL)
if(res) if(res)
goto test_cleanup; goto test_cleanup;
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }
@ -117,7 +120,8 @@ int test(char *URL)
paramsf = NULL; paramsf = NULL;
/* Heartbeat GET_PARAMETERS */ /* Heartbeat GET_PARAMETERS */
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }
@ -131,7 +135,8 @@ int test(char *URL)
/* POST GET_PARAMETERS */ /* POST GET_PARAMETERS */
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }
@ -149,7 +154,8 @@ int test(char *URL)
test_setopt(curl, CURLOPT_POSTFIELDS, NULL); test_setopt(curl, CURLOPT_POSTFIELDS, NULL);
/* Make sure we can do a normal request now */ /* Make sure we can do a normal request now */
if((stream_uri = suburl(URL, request++)) == NULL) { stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD; res = TEST_ERR_MAJOR_BAD;
goto test_cleanup; goto test_cleanup;
} }

View File

@ -40,7 +40,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -58,7 +58,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -97,7 +97,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -101,7 +101,8 @@ static void *fire(void *ptr)
CURL *curl; CURL *curl;
int i=0; int i=0;
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
return NULL; return NULL;
} }
@ -148,7 +149,8 @@ int test(char *URL)
/* prepare share */ /* prepare share */
printf("SHARE_INIT\n"); printf("SHARE_INIT\n");
if((share = curl_share_init()) == NULL) { share = curl_share_init();
if(!share) {
fprintf(stderr, "curl_share_init() failed\n"); fprintf(stderr, "curl_share_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
@ -197,7 +199,8 @@ int test(char *URL)
/* fetch a another one */ /* fetch a another one */
printf("*** run %d\n", i); printf("*** run %d\n", i);
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_share_cleanup(share); curl_share_cleanup(share);
curl_global_cleanup(); curl_global_cleanup();

View File

@ -46,7 +46,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -33,7 +33,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -50,7 +50,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
} }
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -101,7 +101,8 @@ int test(char *url)
/* Send wrong password, then right password */ /* Send wrong password, then right password */
if((curl = curl_easy_init()) == NULL) { curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;
@ -120,8 +121,8 @@ int test(char *url)
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
/* Send wrong password twice, then right password */ /* Send wrong password twice, then right password */
curl = curl_easy_init();
if((curl = curl_easy_init()) == NULL) { if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n"); fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup(); curl_global_cleanup();
return TEST_ERR_MAJOR_BAD; return TEST_ERR_MAJOR_BAD;

View File

@ -309,7 +309,8 @@ int getpart(char **outbuf, size_t *outlen,
ptr++; ptr++;
end = ptr; end = ptr;
EAT_WORD(end); EAT_WORD(end);
if((len.sig = end - ptr) > MAX_TAG_LEN) { len.sig = end - ptr;
if(len.sig > MAX_TAG_LEN) {
error = GPE_NO_BUFFER_SPACE; error = GPE_NO_BUFFER_SPACE;
break; break;
} }
@ -370,7 +371,8 @@ int getpart(char **outbuf, size_t *outlen,
/* get potential tag */ /* get potential tag */
end = ptr; end = ptr;
EAT_WORD(end); EAT_WORD(end);
if((len.sig = end - ptr) > MAX_TAG_LEN) { len.sig = end - ptr;
if(len.sig > MAX_TAG_LEN) {
error = GPE_NO_BUFFER_SPACE; error = GPE_NO_BUFFER_SPACE;
break; break;
} }
@ -389,7 +391,8 @@ int getpart(char **outbuf, size_t *outlen,
end = ptr; end = ptr;
while(*end && ('>' != *end)) while(*end && ('>' != *end))
end++; end++;
if((len.sig = end - ptr) > MAX_TAG_LEN) { len.sig = end - ptr;
if(len.sig > MAX_TAG_LEN) {
error = GPE_NO_BUFFER_SPACE; error = GPE_NO_BUFFER_SPACE;
break; break;
} }

View File

@ -260,36 +260,42 @@ static void install_signal_handlers(void)
{ {
#ifdef SIGHUP #ifdef SIGHUP
/* ignore SIGHUP signal */ /* ignore SIGHUP signal */
if((old_sighup_handler = signal(SIGHUP, SIG_IGN)) == SIG_ERR) old_sighup_handler = signal(SIGHUP, SIG_IGN);
if(old_sighup_handler == SIG_ERR)
logmsg("cannot install SIGHUP handler: %s", strerror(errno)); logmsg("cannot install SIGHUP handler: %s", strerror(errno));
#endif #endif
#ifdef SIGPIPE #ifdef SIGPIPE
/* ignore SIGPIPE signal */ /* ignore SIGPIPE signal */
if((old_sigpipe_handler = signal(SIGPIPE, SIG_IGN)) == SIG_ERR) old_sigpipe_handler = signal(SIGPIPE, SIG_IGN);
if(old_sigpipe_handler == SIG_ERR)
logmsg("cannot install SIGPIPE handler: %s", strerror(errno)); logmsg("cannot install SIGPIPE handler: %s", strerror(errno));
#endif #endif
#ifdef SIGALRM #ifdef SIGALRM
/* ignore SIGALRM signal */ /* ignore SIGALRM signal */
if((old_sigalrm_handler = signal(SIGALRM, SIG_IGN)) == SIG_ERR) old_sigalrm_handler = signal(SIGALRM, SIG_IGN);
if(old_sigalrm_handler == SIG_ERR)
logmsg("cannot install SIGALRM handler: %s", strerror(errno)); logmsg("cannot install SIGALRM handler: %s", strerror(errno));
#endif #endif
#ifdef SIGINT #ifdef SIGINT
/* handle SIGINT signal with our exit_signal_handler */ /* handle SIGINT signal with our exit_signal_handler */
if((old_sigint_handler = signal(SIGINT, exit_signal_handler)) == SIG_ERR) old_sigint_handler = signal(SIGINT, exit_signal_handler);
if(old_sigint_handler == SIG_ERR)
logmsg("cannot install SIGINT handler: %s", strerror(errno)); logmsg("cannot install SIGINT handler: %s", strerror(errno));
else else
siginterrupt(SIGINT, 1); siginterrupt(SIGINT, 1);
#endif #endif
#ifdef SIGTERM #ifdef SIGTERM
/* handle SIGTERM signal with our exit_signal_handler */ /* handle SIGTERM signal with our exit_signal_handler */
if((old_sigterm_handler = signal(SIGTERM, exit_signal_handler)) == SIG_ERR) old_sigterm_handler = signal(SIGTERM, exit_signal_handler);
if(old_sigterm_handler == SIG_ERR)
logmsg("cannot install SIGTERM handler: %s", strerror(errno)); logmsg("cannot install SIGTERM handler: %s", strerror(errno));
else else
siginterrupt(SIGTERM, 1); siginterrupt(SIGTERM, 1);
#endif #endif
#if defined(SIGBREAK) && defined(WIN32) #if defined(SIGBREAK) && defined(WIN32)
/* handle SIGBREAK signal with our exit_signal_handler */ /* handle SIGBREAK signal with our exit_signal_handler */
if((old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler)) == SIG_ERR) old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler);
if(old_sigbreak_handler == SIG_ERR)
logmsg("cannot install SIGBREAK handler: %s", strerror(errno)); logmsg("cannot install SIGBREAK handler: %s", strerror(errno));
else else
siginterrupt(SIGBREAK, 1); siginterrupt(SIGBREAK, 1);

View File

@ -206,36 +206,42 @@ static void install_signal_handlers(void)
{ {
#ifdef SIGHUP #ifdef SIGHUP
/* ignore SIGHUP signal */ /* ignore SIGHUP signal */
if((old_sighup_handler = signal(SIGHUP, SIG_IGN)) == SIG_ERR) old_sighup_handler = signal(SIGHUP, SIG_IGN);
if(old_sighup_handler == SIG_ERR)
logmsg("cannot install SIGHUP handler: %s", strerror(errno)); logmsg("cannot install SIGHUP handler: %s", strerror(errno));
#endif #endif
#ifdef SIGPIPE #ifdef SIGPIPE
/* ignore SIGPIPE signal */ /* ignore SIGPIPE signal */
if((old_sigpipe_handler = signal(SIGPIPE, SIG_IGN)) == SIG_ERR) old_sigpipe_handler = signal(SIGPIPE, SIG_IGN);
if(old_sigpipe_handler == SIG_ERR)
logmsg("cannot install SIGPIPE handler: %s", strerror(errno)); logmsg("cannot install SIGPIPE handler: %s", strerror(errno));
#endif #endif
#ifdef SIGALRM #ifdef SIGALRM
/* ignore SIGALRM signal */ /* ignore SIGALRM signal */
if((old_sigalrm_handler = signal(SIGALRM, SIG_IGN)) == SIG_ERR) old_sigalrm_handler = signal(SIGALRM, SIG_IGN);
if(old_sigalrm_handler == SIG_ERR)
logmsg("cannot install SIGALRM handler: %s", strerror(errno)); logmsg("cannot install SIGALRM handler: %s", strerror(errno));
#endif #endif
#ifdef SIGINT #ifdef SIGINT
/* handle SIGINT signal with our exit_signal_handler */ /* handle SIGINT signal with our exit_signal_handler */
if((old_sigint_handler = signal(SIGINT, exit_signal_handler)) == SIG_ERR) old_sigint_handler = signal(SIGINT, exit_signal_handler);
if(old_sigint_handler == SIG_ERR)
logmsg("cannot install SIGINT handler: %s", strerror(errno)); logmsg("cannot install SIGINT handler: %s", strerror(errno));
else else
siginterrupt(SIGINT, 1); siginterrupt(SIGINT, 1);
#endif #endif
#ifdef SIGTERM #ifdef SIGTERM
/* handle SIGTERM signal with our exit_signal_handler */ /* handle SIGTERM signal with our exit_signal_handler */
if((old_sigterm_handler = signal(SIGTERM, exit_signal_handler)) == SIG_ERR) old_sigterm_handler = signal(SIGTERM, exit_signal_handler);
if(old_sigterm_handler == SIG_ERR)
logmsg("cannot install SIGTERM handler: %s", strerror(errno)); logmsg("cannot install SIGTERM handler: %s", strerror(errno));
else else
siginterrupt(SIGTERM, 1); siginterrupt(SIGTERM, 1);
#endif #endif
#if defined(SIGBREAK) && defined(WIN32) #if defined(SIGBREAK) && defined(WIN32)
/* handle SIGBREAK signal with our exit_signal_handler */ /* handle SIGBREAK signal with our exit_signal_handler */
if((old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler)) == SIG_ERR) old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler);
if(old_sigbreak_handler == SIG_ERR)
logmsg("cannot install SIGBREAK handler: %s", strerror(errno)); logmsg("cannot install SIGBREAK handler: %s", strerror(errno));
else else
siginterrupt(SIGBREAK, 1); siginterrupt(SIGBREAK, 1);

View File

@ -265,36 +265,42 @@ static void install_signal_handlers(void)
{ {
#ifdef SIGHUP #ifdef SIGHUP
/* ignore SIGHUP signal */ /* ignore SIGHUP signal */
if((old_sighup_handler = signal(SIGHUP, SIG_IGN)) == SIG_ERR) old_sighup_handler = signal(SIGHUP, SIG_IGN);
if(old_sighup_handler == SIG_ERR)
logmsg("cannot install SIGHUP handler: %s", strerror(errno)); logmsg("cannot install SIGHUP handler: %s", strerror(errno));
#endif #endif
#ifdef SIGPIPE #ifdef SIGPIPE
/* ignore SIGPIPE signal */ /* ignore SIGPIPE signal */
if((old_sigpipe_handler = signal(SIGPIPE, SIG_IGN)) == SIG_ERR) old_sigpipe_handler = signal(SIGPIPE, SIG_IGN);
if(old_sigpipe_handler == SIG_ERR)
logmsg("cannot install SIGPIPE handler: %s", strerror(errno)); logmsg("cannot install SIGPIPE handler: %s", strerror(errno));
#endif #endif
#ifdef SIGALRM #ifdef SIGALRM
/* ignore SIGALRM signal */ /* ignore SIGALRM signal */
if((old_sigalrm_handler = signal(SIGALRM, SIG_IGN)) == SIG_ERR) old_sigalrm_handler = signal(SIGALRM, SIG_IGN);
if(old_sigalrm_handler == SIG_ERR)
logmsg("cannot install SIGALRM handler: %s", strerror(errno)); logmsg("cannot install SIGALRM handler: %s", strerror(errno));
#endif #endif
#ifdef SIGINT #ifdef SIGINT
/* handle SIGINT signal with our exit_signal_handler */ /* handle SIGINT signal with our exit_signal_handler */
if((old_sigint_handler = signal(SIGINT, exit_signal_handler)) == SIG_ERR) old_sigint_handler = signal(SIGINT, exit_signal_handler);
if(old_sigint_handler == SIG_ERR)
logmsg("cannot install SIGINT handler: %s", strerror(errno)); logmsg("cannot install SIGINT handler: %s", strerror(errno));
else else
siginterrupt(SIGINT, 1); siginterrupt(SIGINT, 1);
#endif #endif
#ifdef SIGTERM #ifdef SIGTERM
/* handle SIGTERM signal with our exit_signal_handler */ /* handle SIGTERM signal with our exit_signal_handler */
if((old_sigterm_handler = signal(SIGTERM, exit_signal_handler)) == SIG_ERR) old_sigterm_handler = signal(SIGTERM, exit_signal_handler);
if(old_sigterm_handler == SIG_ERR)
logmsg("cannot install SIGTERM handler: %s", strerror(errno)); logmsg("cannot install SIGTERM handler: %s", strerror(errno));
else else
siginterrupt(SIGTERM, 1); siginterrupt(SIGTERM, 1);
#endif #endif
#if defined(SIGBREAK) && defined(WIN32) #if defined(SIGBREAK) && defined(WIN32)
/* handle SIGBREAK signal with our exit_signal_handler */ /* handle SIGBREAK signal with our exit_signal_handler */
if((old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler)) == SIG_ERR) old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler);
if(old_sigbreak_handler == SIG_ERR)
logmsg("cannot install SIGBREAK handler: %s", strerror(errno)); logmsg("cannot install SIGBREAK handler: %s", strerror(errno));
else else
siginterrupt(SIGBREAK, 1); siginterrupt(SIGBREAK, 1);

View File

@ -367,31 +367,36 @@ static void install_signal_handlers(void)
{ {
#ifdef SIGHUP #ifdef SIGHUP
/* ignore SIGHUP signal */ /* ignore SIGHUP signal */
if((old_sighup_handler = signal(SIGHUP, SIG_IGN)) == SIG_ERR) old_sighup_handler = signal(SIGHUP, SIG_IGN);
if(old_sighup_handler == SIG_ERR)
logmsg("cannot install SIGHUP handler: %s", strerror(errno)); logmsg("cannot install SIGHUP handler: %s", strerror(errno));
#endif #endif
#ifdef SIGPIPE #ifdef SIGPIPE
/* ignore SIGPIPE signal */ /* ignore SIGPIPE signal */
if((old_sigpipe_handler = signal(SIGPIPE, SIG_IGN)) == SIG_ERR) old_sigpipe_handler = signal(SIGPIPE, SIG_IGN);
if(old_sigpipe_handler == SIG_ERR)
logmsg("cannot install SIGPIPE handler: %s", strerror(errno)); logmsg("cannot install SIGPIPE handler: %s", strerror(errno));
#endif #endif
#ifdef SIGINT #ifdef SIGINT
/* handle SIGINT signal with our exit_signal_handler */ /* handle SIGINT signal with our exit_signal_handler */
if((old_sigint_handler = signal(SIGINT, exit_signal_handler)) == SIG_ERR) old_sigint_handler = signal(SIGINT, exit_signal_handler);
if(old_sigint_handler == SIG_ERR)
logmsg("cannot install SIGINT handler: %s", strerror(errno)); logmsg("cannot install SIGINT handler: %s", strerror(errno));
else else
siginterrupt(SIGINT, 1); siginterrupt(SIGINT, 1);
#endif #endif
#ifdef SIGTERM #ifdef SIGTERM
/* handle SIGTERM signal with our exit_signal_handler */ /* handle SIGTERM signal with our exit_signal_handler */
if((old_sigterm_handler = signal(SIGTERM, exit_signal_handler)) == SIG_ERR) old_sigterm_handler = signal(SIGTERM, exit_signal_handler);
if(old_sigterm_handler == SIG_ERR)
logmsg("cannot install SIGTERM handler: %s", strerror(errno)); logmsg("cannot install SIGTERM handler: %s", strerror(errno));
else else
siginterrupt(SIGTERM, 1); siginterrupt(SIGTERM, 1);
#endif #endif
#if defined(SIGBREAK) && defined(WIN32) #if defined(SIGBREAK) && defined(WIN32)
/* handle SIGBREAK signal with our exit_signal_handler */ /* handle SIGBREAK signal with our exit_signal_handler */
if((old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler)) == SIG_ERR) old_sigbreak_handler = signal(SIGBREAK, exit_signal_handler);
if(old_sigbreak_handler == SIG_ERR)
logmsg("cannot install SIGBREAK handler: %s", strerror(errno)); logmsg("cannot install SIGBREAK handler: %s", strerror(errno));
else else
siginterrupt(SIGBREAK, 1); siginterrupt(SIGBREAK, 1);

View File

@ -80,15 +80,18 @@ static Curl_addrinfo *fake_ai(void)
ss_size = sizeof(struct sockaddr_in); ss_size = sizeof(struct sockaddr_in);
if((ai = calloc(1, sizeof(Curl_addrinfo))) == NULL) ai = calloc(1, sizeof(Curl_addrinfo));
if(!ai)
return NULL; return NULL;
if((ai->ai_canonname = strdup("dummy")) == NULL) { ai->ai_canonname = strdup("dummy");
if(!ai->ai_canonname) {
free(ai); free(ai);
return NULL; return NULL;
} }
if((ai->ai_addr = calloc(1, ss_size)) == NULL) { ai->ai_addr = calloc(1, ss_size);
if(!ai->ai_addr) {
free(ai->ai_canonname); free(ai->ai_canonname);
free(ai); free(ai);
return NULL; return NULL;