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)
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)
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) {
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;
}
else
@ -410,16 +412,19 @@ int main(int argc, char **argv)
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");
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);
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);
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
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;
BIO_printf(p.errorbio, "no service URL in user cert "
"cherching in others certificats\n");
for(j=0; j<sk_X509_num(p.ca); j++) {
if((serverurl = my_get_ext(sk_X509_value(p.ca, j), p.accesstype,
NID_info_access)))
serverurl = my_get_ext(sk_X509_value(p.ca, j), p.accesstype,
NID_info_access);
if(serverurl)
break;
if((serverurl = my_get_ext(sk_X509_value(p.ca, j), p.accesstype,
NID_sinfo_access)))
serverurl = my_get_ext(sk_X509_value(p.ca, j), p.accesstype,
NID_sinfo_access);
if(serverurl)
break;
}
}

View File

@ -90,9 +90,8 @@ int main(void)
#ifdef WIN32
WSADATA wsaData;
int initwsa;
if((initwsa = WSAStartup(MAKEWORD(2, 0), &wsaData)) != 0) {
int initwsa = WSAStartup(MAKEWORD(2, 0), &wsaData);
if(initwsa != 0) {
printf("WSAStartup failed: %d\n", initwsa);
return 1;
}
@ -107,7 +106,8 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_URL, "http://99.99.99.99:9999");
/* 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");
return 3;
}
@ -116,7 +116,8 @@ int main(void)
servaddr.sin_family = AF_INET;
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;
if(connect(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) ==

View File

@ -61,13 +61,15 @@ static int _getch(void)
#define VERSION_STR "V1.0"
/* error handling macros */
#define my_curl_easy_setopt(A, B, C) \
if((res = curl_easy_setopt((A), (B), (C))) != CURLE_OK) \
#define my_curl_easy_setopt(A, B, C) \
res = curl_easy_setopt((A), (B), (C)); \
if(!res) \
fprintf(stderr, "curl_easy_setopt(%s, %s, %s) failed: %d\n", \
#A, #B, #C, res);
#define my_curl_easy_perform(A) \
if((res = curl_easy_perform((A))) != CURLE_OK) \
#define my_curl_easy_perform(A) \
res = curl_easy_perform(A); \
if(!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
if($l =~ /^(.*[a-z])\( /i) {
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.
This needs a libpsl compiled with builtin data. */
if(domain && co->domain && !isip(co->domain)) {
if(((psl = psl_builtin()) != NULL)
&& !psl_is_cookie_domain_acceptable(psl, domain, co->domain)) {
psl = psl_builtin();
if(psl && !psl_is_cookie_domain_acceptable(psl, domain, co->domain)) {
infof(data,
"cookie '%s' dropped, domain '%s' must not set cookies for '%s'\n",
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)
continue;
if((ca = malloc(sizeof(Curl_addrinfo))) == NULL) {
ca = malloc(sizeof(Curl_addrinfo));
if(!ca) {
error = EAI_MEMORY;
break;
}
@ -163,7 +164,8 @@ Curl_getaddrinfo_ex(const char *nodename,
ca->ai_canonname = 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;
free(ca);
break;
@ -171,7 +173,8 @@ Curl_getaddrinfo_ex(const char *nodename,
memcpy(ca->ai_addr, ai->ai_addr, ss_size);
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;
free(ca->ai_addr);
free(ca);
@ -291,16 +294,19 @@ Curl_he2ai(const struct hostent *he, int port)
#endif
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;
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;
free(ai);
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;
free(ai->ai_canonname);
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
* 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;
struct sockaddr_un *sa_un;
@ -485,8 +492,10 @@ Curl_addrinfo *Curl_unix2addr(const char *path)
ai = calloc(1, sizeof(Curl_addrinfo));
if(!ai)
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);
*longpath = FALSE;
return NULL;
}
/* 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)) {
free(ai->ai_addr);
free(ai);
*longpath = TRUE;
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);
#ifdef USE_UNIX_SOCKETS
Curl_addrinfo *Curl_unix2addr(const char *path);
Curl_addrinfo *Curl_unix2addr(const char *path, int *longpath);
#endif
#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, "\\/");
if(slash) {
if((domain = strdup(username)) == NULL)
domain = strdup(username);
if(!domain)
return CURLE_OUT_OF_MEMORY;
slash = domain + (slash - username);
*slash = '\0';

View File

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

View File

@ -1035,7 +1035,8 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
if(*string_ftpport == '[') {
/* [ipv6]:port(-range) */
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);
}
else
@ -1043,30 +1044,35 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
if(*string_ftpport == ':') {
/* :port */
ip_end = string_ftpport;
}
else if((ip_end = strchr(string_ftpport, ':')) != NULL) {
/* either ipv6 or (ipv4|domain|interface):port(-range) */
#ifdef ENABLE_IPV6
if(Curl_inet_pton(AF_INET6, string_ftpport, sa6) == 1) {
/* ipv6 */
port_min = port_max = 0;
strcpy(addr, string_ftpport);
ip_end = NULL; /* this got no port ! */
}
else
else {
ip_end = strchr(string_ftpport, ':');
if(ip_end) {
/* either ipv6 or (ipv4|domain|interface):port(-range) */
#ifdef ENABLE_IPV6
if(Curl_inet_pton(AF_INET6, string_ftpport, sa6) == 1) {
/* ipv6 */
port_min = port_max = 0;
strcpy(addr, string_ftpport);
ip_end = NULL; /* this got no port ! */
}
else
#endif
/* (ipv4|domain|interface):port(-range) */
strncpy(addr, string_ftpport, ip_end - ip_start);
}
else
/* ipv4|interface */
strcpy(addr, string_ftpport);
/* (ipv4|domain|interface):port(-range) */
strncpy(addr, string_ftpport, ip_end - ip_start);
}
else
/* ipv4|interface */
strcpy(addr, string_ftpport);
}
/* parse the port */
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));
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));
}
else

View File

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

View File

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

View File

@ -103,7 +103,8 @@ inet_pton4(const char *src, unsigned char *dst)
while((ch = *src++) != '\0') {
const char *pch;
if((pch = strchr(digits, ch)) != NULL) {
pch = strchr(digits, ch);
if(pch) {
unsigned int val = *tp * 10 + (unsigned int)(pch - digits);
if(saw_digit && *tp == 0)
@ -169,7 +170,8 @@ inet_pton6(const char *src, unsigned char *dst)
while((ch = *src++) != '\0') {
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);
if(pch != NULL) {
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;
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 += (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;
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 += (MD5_u32plus)size >> 29;

View File

@ -184,7 +184,8 @@ int GetOrSetUpData(int id, libdata_t **appData,
*/
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));
if(app_data) {
@ -259,7 +260,8 @@ int GetOrSetUpData(int id, libdata_t **appData,
err = ENOMEM;
}
if((err = NXKeySetValue(key, thread_data))) {
err = NXKeySetValue(key, thread_data);
if(err) {
free(thread_data->twentybytes);
free(thread_data);
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);
break;
}
else if((err = libssh2_session_last_errno(sshc->ssh_session)) ==
LIBSSH2_ERROR_EAGAIN) {
rc = LIBSSH2_ERROR_EAGAIN;
break;
}
else {
state(conn, SSH_SESSION_FREE);
sshc->actualcode = libssh2_session_error_to_CURLE(err);
err = libssh2_session_last_errno(sshc->ssh_session);
if(err == LIBSSH2_ERROR_EAGAIN)
rc = LIBSSH2_ERROR_EAGAIN;
else {
state(conn, SSH_SESSION_FREE);
sshc->actualcode = libssh2_session_error_to_CURLE(err);
}
break;
}
}
@ -1987,12 +1987,14 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
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);
sshc->actualcode = CURLE_OUT_OF_MEMORY;
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);
state(conn, SSH_SFTP_CLOSE);
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)
{
struct ssh_conn *sshc = &conn->proto.sshc;
int dir;
if(block && (dir = libssh2_session_block_directions(sshc->ssh_session))) {
/* translate the libssh2 define bits into our own bit defines */
conn->waitfor = ((dir&LIBSSH2_SESSION_BLOCK_INBOUND)?KEEP_RECV:0) |
((dir&LIBSSH2_SESSION_BLOCK_OUTBOUND)?KEEP_SEND:0);
int dir = 0;
if(block) {
dir = libssh2_session_block_directions(sshc->ssh_session);
if(dir) {
/* translate the libssh2 define bits into our own bit defines */
conn->waitfor = ((dir&LIBSSH2_SESSION_BLOCK_INBOUND)?KEEP_RECV: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
the original set */
conn->waitfor = sshc->orig_waitfor;

View File

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

View File

@ -1489,7 +1489,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
events.lNetworkEvents = 0;
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);
keepon = FALSE;
result = CURLE_READ_ERROR;

View File

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

View File

@ -242,7 +242,8 @@ static gnutls_datum_t load_file(const char *file)
long filelen;
void *ptr;
if(!(f = fopen(file, "rb")))
f = fopen(file, "rb");
if(!f)
return loaded_file;
if(fseek(f, 0, SEEK_END) != 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)))
++cipher;
if((cipher_list = strchr(cipher, ','))) {
cipher_list = strchr(cipher, ',');
if(cipher_list) {
*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;
if((ilen = (int)len) < 0)
ilen = (int)len;
if(ilen < 0)
return 1; /* buffer too big */
i = i2t_ASN1_OBJECT(buf, ilen, a);

View File

@ -757,7 +757,11 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
case '@': /* the 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
an "empty" node */
while(config->url_get && (config->url_get->flags & GETOUT_URL))
@ -1687,7 +1691,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
/* output file */
{
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
an "empty" node */
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 */
{
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
an "empty" node */
while(config->url_out && (config->url_out->flags & GETOUT_UPLOAD))

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -37,7 +37,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
if((curl = curl_easy_init()) == NULL) {
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
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
* you should have received as part of this distribution. The terms
@ -36,7 +36,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
if((curl = curl_easy_init()) == NULL) {
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
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
* you should have received as part of this distribution. The terms
@ -46,7 +46,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
if((curl = curl_easy_init()) == NULL) {
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;

View File

@ -136,7 +136,8 @@ int test(char *URL)
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");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -172,7 +172,8 @@ int test(char *URL)
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");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;

View File

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

View File

@ -162,7 +162,8 @@ static int once(char *URL, bool oldstyle)
if(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");
curl_formfree(formpost);
curl_global_cleanup();

View File

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

View File

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

View File

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

View File

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

View File

@ -55,7 +55,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
if((curl = curl_easy_init()) == NULL) {
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
@ -66,7 +67,8 @@ int test(char *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;
goto test_cleanup;
}
@ -100,7 +102,8 @@ int test(char *URL)
sdpf = NULL;
/* 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;
goto test_cleanup;
}
@ -115,7 +118,8 @@ int test(char *URL)
/* 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;
goto test_cleanup;
}
@ -144,7 +148,8 @@ int test(char *URL)
custom_headers = NULL;
/* 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;
goto test_cleanup;
}

View File

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

View File

@ -40,7 +40,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
if((curl = curl_easy_init()) == NULL) {
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
@ -54,7 +55,8 @@ int test(char *URL)
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;
goto test_cleanup;
}
@ -74,7 +76,8 @@ int test(char *URL)
"RAW/RAW/UDP;unicast;client_port=3056-3057");
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;
goto test_cleanup;
}
@ -88,7 +91,8 @@ int test(char *URL)
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;
goto test_cleanup;
}

View File

@ -118,7 +118,8 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
if((curl = curl_easy_init()) == NULL) {
curl = curl_easy_init();
if(!curl) {
fprintf(stderr, "curl_easy_init() failed\n");
fclose(protofile);
curl_global_cleanup();
@ -126,7 +127,8 @@ int test(char *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;
goto test_cleanup;
}
@ -147,7 +149,8 @@ int test(char *URL)
goto test_cleanup;
/* 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;
goto test_cleanup;
}
@ -161,7 +164,8 @@ int test(char *URL)
goto test_cleanup;
/* 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;
goto test_cleanup;
}
@ -174,7 +178,8 @@ int test(char *URL)
if(res)
goto test_cleanup;
if((stream_uri = suburl(URL, request++)) == NULL) {
stream_uri = suburl(URL, request++);
if(!stream_uri) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -309,7 +309,8 @@ int getpart(char **outbuf, size_t *outlen,
ptr++;
end = ptr;
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;
break;
}
@ -370,7 +371,8 @@ int getpart(char **outbuf, size_t *outlen,
/* get potential tag */
end = ptr;
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;
break;
}
@ -389,7 +391,8 @@ int getpart(char **outbuf, size_t *outlen,
end = ptr;
while(*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;
break;
}

View File

@ -260,36 +260,42 @@ static void install_signal_handlers(void)
{
#ifdef SIGHUP
/* 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));
#endif
#ifdef SIGPIPE
/* 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));
#endif
#ifdef SIGALRM
/* 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));
#endif
#ifdef SIGINT
/* 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));
else
siginterrupt(SIGINT, 1);
#endif
#ifdef SIGTERM
/* 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));
else
siginterrupt(SIGTERM, 1);
#endif
#if defined(SIGBREAK) && defined(WIN32)
/* 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));
else
siginterrupt(SIGBREAK, 1);

View File

@ -206,36 +206,42 @@ static void install_signal_handlers(void)
{
#ifdef SIGHUP
/* 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));
#endif
#ifdef SIGPIPE
/* 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));
#endif
#ifdef SIGALRM
/* 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));
#endif
#ifdef SIGINT
/* 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));
else
siginterrupt(SIGINT, 1);
#endif
#ifdef SIGTERM
/* 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));
else
siginterrupt(SIGTERM, 1);
#endif
#if defined(SIGBREAK) && defined(WIN32)
/* 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));
else
siginterrupt(SIGBREAK, 1);

View File

@ -265,36 +265,42 @@ static void install_signal_handlers(void)
{
#ifdef SIGHUP
/* 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));
#endif
#ifdef SIGPIPE
/* 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));
#endif
#ifdef SIGALRM
/* 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));
#endif
#ifdef SIGINT
/* 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));
else
siginterrupt(SIGINT, 1);
#endif
#ifdef SIGTERM
/* 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));
else
siginterrupt(SIGTERM, 1);
#endif
#if defined(SIGBREAK) && defined(WIN32)
/* 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));
else
siginterrupt(SIGBREAK, 1);

View File

@ -367,31 +367,36 @@ static void install_signal_handlers(void)
{
#ifdef SIGHUP
/* 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));
#endif
#ifdef SIGPIPE
/* 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));
#endif
#ifdef SIGINT
/* 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));
else
siginterrupt(SIGINT, 1);
#endif
#ifdef SIGTERM
/* 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));
else
siginterrupt(SIGTERM, 1);
#endif
#if defined(SIGBREAK) && defined(WIN32)
/* 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));
else
siginterrupt(SIGBREAK, 1);

View File

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