summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2016-03-05 16:04:57 +0000
committerJeremy Harris <jgh146exb@wizmail.org>2016-03-05 16:04:57 +0000
commitd4ff61d1edff4054497632be7f36ede86bb8ebec (patch)
treee64e81d3046c0381eeeeccaa20efa7c925277495
parent968178ac56100bcd7418b2dfc7e9224f977bb039 (diff)
tidying: coverity issues
-rw-r--r--src/src/auths/tls.c2
-rw-r--r--src/src/daemon.c9
-rw-r--r--src/src/exim_dbutil.c5
-rw-r--r--src/src/expand.c4
-rw-r--r--src/src/lookups/ldap.c2
-rw-r--r--src/src/mime.c3
-rw-r--r--src/src/readconf.c39
-rw-r--r--src/src/receive.c2
-rw-r--r--src/src/sieve.c6
-rw-r--r--src/src/smtp_in.c5
-rw-r--r--src/src/smtp_out.c4
-rw-r--r--src/src/spam.c7
-rw-r--r--src/src/spool_out.c3
-rw-r--r--src/src/string.c2
-rw-r--r--src/src/tlscert-openssl.c4
-rw-r--r--src/src/transport.c5
-rw-r--r--src/src/verify.c6
17 files changed, 51 insertions, 57 deletions
diff --git a/src/src/auths/tls.c b/src/src/auths/tls.c
index 51c096cd0..2a995125e 100644
--- a/src/src/auths/tls.c
+++ b/src/src/auths/tls.c
@@ -71,7 +71,7 @@ if (ob->server_param1)
auth_vars[expand_nmax++] = expand_string(ob->server_param1);
if (ob->server_param2)
auth_vars[expand_nmax++] = expand_string(ob->server_param2);
-if (ob->server_param2)
+if (ob->server_param3)
auth_vars[expand_nmax++] = expand_string(ob->server_param3);
return auth_check_serv_cond(ablock);
}
diff --git a/src/src/daemon.c b/src/src/daemon.c
index 24874c374..ac09e2a64 100644
--- a/src/src/daemon.c
+++ b/src/src/daemon.c
@@ -930,10 +930,9 @@ if (inetd_wait_mode)
listen_sockets = store_get(sizeof(int *));
(void) close(3);
if (dup2(0, 3) == -1)
- {
log_write(0, LOG_MAIN|LOG_PANIC_DIE,
"failed to dup inetd socket safely away: %s", strerror(errno));
- }
+
listen_sockets[0] = 3;
(void) close(0);
(void) close(1);
@@ -957,8 +956,10 @@ if (inetd_wait_mode)
/* As per below, when creating sockets ourselves, we handle tcp_nodelay for
our own buffering; we assume though that inetd set the socket REUSEADDR. */
- if (tcp_nodelay) setsockopt(3, IPPROTO_TCP, TCP_NODELAY,
- (uschar *)(&on), sizeof(on));
+ if (tcp_nodelay)
+ if (setsockopt(3, IPPROTO_TCP, TCP_NODELAY, US &on, sizeof(on)))
+ log_write(0, LOG_MAIN|LOG_PANIC_DIE, "failed to set socket NODELAY: %s",
+ strerror(errno));
}
diff --git a/src/src/exim_dbutil.c b/src/src/exim_dbutil.c
index 262e39044..4dd143fea 100644
--- a/src/src/exim_dbutil.c
+++ b/src/src/exim_dbutil.c
@@ -285,8 +285,9 @@ if (sigalrm_seen) errno = ETIMEDOUT;
if (rc < 0)
{
printf("** Failed to get %s lock for %s: %s",
- ((flags & O_RDONLY) != 0)? "read" : "write", buffer,
- (errno == ETIMEDOUT)? "timed out" : strerror(errno));
+ flags & O_WRONLY ? "write" : "read",
+ buffer,
+ errno == ETIMEDOUT ? "timed out" : strerror(errno));
(void)close(dbblock->lockfd);
return NULL;
}
diff --git a/src/src/expand.c b/src/src/expand.c
index b4cc79d4b..5bb9df1b6 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -1851,7 +1851,9 @@ switch (vp->type)
start_offset = SPOOL_DATA_START_OFFSET;
}
}
- lseek(deliver_datafile, start_offset, SEEK_SET);
+ if (lseek(deliver_datafile, start_offset, SEEK_SET) < 0)
+ log_write(0, LOG_MAIN|LOG_PANIC_DIE, "deliver_datafile lseek: %s",
+ strerror(errno));
len = read(deliver_datafile, body, len);
if (len > 0)
{
diff --git a/src/src/lookups/ldap.c b/src/src/lookups/ldap.c
index fe67e7f0a..0f78a9452 100644
--- a/src/src/lookups/ldap.c
+++ b/src/src/lookups/ldap.c
@@ -847,12 +847,10 @@ while ((rc = ldap_result(lcp->ld, msgid, 0, timeoutptr, &result)) ==
{
int j;
for (j = 0; j < len; j++)
- {
if (value[j] == ',')
data = string_cat(data, &size, &ptr, US",,", 2);
else
data = string_cat(data, &size, &ptr, value+j, 1);
- }
}
diff --git a/src/src/mime.c b/src/src/mime.c
index 6a64b26b1..bf140ccfb 100644
--- a/src/src/mime.c
+++ b/src/src/mime.c
@@ -304,7 +304,8 @@ decode_function =
size_counter = decode_function(mime_stream, decode_file, mime_current_boundary);
clearerr(mime_stream);
-fseek(mime_stream, f_pos, SEEK_SET);
+if (fseek(mime_stream, f_pos, SEEK_SET))
+ return DEFER;
if (fclose(decode_file) != 0 || size_counter < 0)
return DEFER;
diff --git a/src/src/readconf.c b/src/src/readconf.c
index 7396c8bd9..3a4a4c3bf 100644
--- a/src/src/readconf.c
+++ b/src/src/readconf.c
@@ -3618,9 +3618,9 @@ while ((buffer = get_config_line()) != NULL)
if (isupper(*name) && *s == '=')
{
- if (d != NULL)
+ if (d)
{
- if (d->driver_name == NULL)
+ if (!d->driver_name)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"no driver defined for %s \"%s\"", class, d->name);
(d->info->init)(d);
@@ -3640,9 +3640,9 @@ while ((buffer = get_config_line()) != NULL)
/* Finish off initializing the previous driver. */
- if (d != NULL)
+ if (d)
{
- if (d->driver_name == NULL)
+ if (!d->driver_name)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"no driver defined for %s \"%s\"", class, d->name);
(d->info->init)(d);
@@ -3650,7 +3650,7 @@ while ((buffer = get_config_line()) != NULL)
/* Check that we haven't already got a driver of this name */
- for (d = *anchor; d != NULL; d = d->next)
+ for (d = *anchor; d; d = d->next)
if (Ustrcmp(name, d->name) == 0)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"there are two %ss called \"%s\"", class, name);
@@ -3661,7 +3661,7 @@ while ((buffer = get_config_line()) != NULL)
d = store_get(instance_size);
memcpy(d, instance_default, instance_size);
*p = d;
- p = &(d->next);
+ p = &d->next;
d->name = string_copy(name);
/* Clear out the "set" bits in the generic options */
@@ -3679,8 +3679,8 @@ while ((buffer = get_config_line()) != NULL)
/* Not the start of a new driver. Give an error if we have not set up a
current driver yet. */
- if (d == NULL) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
- "%s name missing", class);
+ if (!d)
+ log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "%s name missing", class);
/* First look to see if this is a generic option; if it is "driver",
initialize the driver. If is it not a generic option, we can look for a
@@ -3689,7 +3689,7 @@ while ((buffer = get_config_line()) != NULL)
if (readconf_handle_option(buffer, driver_optionlist,
driver_optionlist_count, d, NULL))
{
- if (d->info == NULL && d->driver_name != NULL)
+ if (!d->info && d->driver_name)
init_driver(d, drivers_available, size_of_info, class);
}
@@ -3697,11 +3697,9 @@ while ((buffer = get_config_line()) != NULL)
live therein. A flag with each option indicates if it is in the public
block. */
- else if (d->info != NULL)
- {
+ else if (d->info)
readconf_handle_option(buffer, d->info->options,
*(d->info->options_count), d, US"option \"%s\" unknown");
- }
/* The option is not generic and the driver name has not yet been given. */
@@ -3711,9 +3709,9 @@ while ((buffer = get_config_line()) != NULL)
/* Run the initialization function for the final driver. */
-if (d != NULL)
+if (d)
{
- if (d->driver_name == NULL)
+ if (!d->driver_name)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"no driver defined for %s \"%s\"", class, d->name);
(d->info->init)(d);
@@ -4072,22 +4070,19 @@ readconf_driver_init(US"authenticator",
optionlist_auths, /* generic options */
optionlist_auths_size);
-for (au = auths; au != NULL; au = au->next)
+for (au = auths; au; au = au->next)
{
- if (au->public_name == NULL)
+ if (!au->public_name)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG, "no public name specified for "
"the %s authenticator", au->name);
- for (bu = au->next; bu != NULL; bu = bu->next)
- {
+
+ for (bu = au->next; bu; bu = bu->next)
if (strcmpic(au->public_name, bu->public_name) == 0)
- {
if ((au->client && bu->client) || (au->server && bu->server))
log_write(0, LOG_PANIC_DIE|LOG_CONFIG, "two %s authenticators "
"(%s and %s) have the same public name (%s)",
- (au->client)? US"client" : US"server", au->name, bu->name,
+ au->client ? US"client" : US"server", au->name, bu->name,
au->public_name);
- }
- }
}
}
diff --git a/src/src/receive.c b/src/src/receive.c
index a479e12cd..f047392b7 100644
--- a/src/src/receive.c
+++ b/src/src/receive.c
@@ -1316,7 +1316,7 @@ if (recipients_count == 1) received_for = recipients_list[0].address;
received = expand_string(received_header_text);
received_for = NULL;
-if (received == NULL)
+if (!received)
{
if(spool_name[0] != 0)
Uunlink(spool_name); /* Lose the data file */
diff --git a/src/src/sieve.c b/src/src/sieve.c
index 3d7e99b27..8edb0b8b7 100644
--- a/src/src/sieve.c
+++ b/src/src/sieve.c
@@ -433,7 +433,7 @@ if (*uri && *uri!='?')
if (uri>start)
{
capacity=0;
- to.character=(uschar*)0;
+ to.character= NULL;
to.length=0;
to.character=string_cat(to.character,&capacity,&to.length,start,uri-start);
to.character[to.length]='\0';
@@ -467,7 +467,7 @@ if (*uri=='?')
if (uri>start)
{
capacity=0;
- hname.character=(uschar*)0;
+ hname.character= NULL;
hname.length=0;
hname.character=string_cat(hname.character,&capacity,&hname.length,start,uri-start);
hname.character[hname.length]='\0';
@@ -490,7 +490,7 @@ if (*uri=='?')
if (uri>start)
{
capacity=0;
- hvalue.character=(uschar*)0;
+ hvalue.character= NULL;
hvalue.length=0;
hvalue.character=string_cat(hvalue.character,&capacity,&hvalue.length,start,uri-start);
hvalue.character[hvalue.length]='\0';
diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c
index 202fcf1bb..98968f95d 100644
--- a/src/src/smtp_in.c
+++ b/src/src/smtp_in.c
@@ -2353,10 +2353,9 @@ code = US"220"; /* Default status code */
esc = US""; /* Default extended status code */
esclen = 0; /* Length of esc */
-if (user_msg == NULL)
+if (!user_msg)
{
- s = expand_string(smtp_banner);
- if (s == NULL)
+ if (!(s = expand_string(smtp_banner)))
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "Expansion of \"%s\" (smtp_banner) "
"failed: %s", smtp_banner, expand_string_message);
}
diff --git a/src/src/smtp_out.c b/src/src/smtp_out.c
index c55b29254..06bc1dfd3 100644
--- a/src/src/smtp_out.c
+++ b/src/src/smtp_out.c
@@ -165,7 +165,9 @@ if ((sock = ip_socket(SOCK_STREAM, host_af)) < 0) return -1;
/* Set TCP_NODELAY; Exim does its own buffering. */
-setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (uschar *)(&on), sizeof(on));
+if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, US &on, sizeof(on)))
+ HDEBUG(D_transport|D_acl|D_v)
+ debug_printf("failed to set NODELAY: %s ", strerror(errno));
/* Set DSCP value, if we can. For now, if we fail to set the value, we don't
bomb out, just log it and continue in default traffic class. */
diff --git a/src/src/spam.c b/src/src/spam.c
index 51ae88f50..1159d3687 100644
--- a/src/src/spam.c
+++ b/src/src/spam.c
@@ -367,13 +367,6 @@ start = time(NULL);
}
}
-if (spamd_sock == -1)
- {
- log_write(0, LOG_MAIN|LOG_PANIC,
- "programming fault, spamd_sock unexpectedly unset");
- goto defer;
- }
-
(void)fcntl(spamd_sock, F_SETFL, O_NONBLOCK);
/* now we are connected to spamd on spamd_sock */
if (sd->is_rspamd)
diff --git a/src/src/spool_out.c b/src/src/spool_out.c
index 8d0ee7c71..62909915f 100644
--- a/src/src/spool_out.c
+++ b/src/src/spool_out.c
@@ -329,7 +329,8 @@ if (EXIMfsync(fileno(f)) < 0)
/* Get the size of the file, and close it. */
-fstat(fd, &statbuf);
+if (fstat(fd, &statbuf) != 0)
+ return spool_write_error(where, errmsg, US"fstat", temp_name, NULL);
if (fclose(f) != 0)
return spool_write_error(where, errmsg, US"close", temp_name, NULL);
diff --git a/src/src/string.c b/src/src/string.c
index b559a9f19..28d578015 100644
--- a/src/src/string.c
+++ b/src/src/string.c
@@ -913,7 +913,7 @@ sep_is_special = iscntrl(sep);
if (buffer != NULL)
{
- register int p = 0;
+ int p = 0;
for (; *s != 0; s++)
{
if (*s == sep && (*(++s) != sep || sep_is_special)) break;
diff --git a/src/src/tlscert-openssl.c b/src/src/tlscert-openssl.c
index 29fe293c1..82f04955e 100644
--- a/src/src/tlscert-openssl.c
+++ b/src/src/tlscert-openssl.c
@@ -123,7 +123,7 @@ int len;
if (!bp)
return badalloc();
len = ASN1_TIME_print(bp, asntime);
-len = len > 0 ? (int) BIO_get_mem_data(bp, &s) : 0;
+len = len > 0 ? (int) BIO_get_mem_data(bp, CSS &s) : 0;
if (mod && Ustrcmp(mod, "raw") == 0) /* native ASN */
s = string_copyn(s, len);
@@ -141,7 +141,7 @@ else
/*XXX %Z might be glibc-specific? Solaris has it, at least*/
/*XXX should we switch to POSIX locale for this? */
tm.tm_isdst = 0;
- if (!strptime(CCS s, "%b %e %T %Y %Z", &tm))
+ if (!len || !strptime(CCS s, "%b %e %T %Y %Z", &tm))
expand_string_message = US"failed time conversion";
else
diff --git a/src/src/transport.c b/src/src/transport.c
index c14b60f4e..6b72521e5 100644
--- a/src/src/transport.c
+++ b/src/src/transport.c
@@ -655,7 +655,7 @@ for (h = header_list; h != NULL; h = h->next) if (h->type != htype_old)
errno = ERRNO_CHHEADER_FAIL;
return FALSE;
}
- len = Ustrlen(s);
+ len = s ? Ustrlen(s) : 0;
if (strncmpic(h->text, s, len) != 0) continue;
ss = h->text + len;
while (*ss == ' ' || *ss == '\t') ss++;
@@ -933,7 +933,8 @@ if ((options & topt_no_body) == 0)
{
nl_check_length = abs(nl_check_length);
nl_partial_match = 0;
- lseek(deliver_datafile, SPOOL_DATA_START_OFFSET, SEEK_SET);
+ if (lseek(deliver_datafile, SPOOL_DATA_START_OFFSET, SEEK_SET) < 0)
+ return FALSE;
while ((len = read(deliver_datafile, deliver_in_buffer,
DELIVER_IN_BUFFER_SIZE)) > 0)
{
diff --git a/src/src/verify.c b/src/src/verify.c
index 3d4f88550..6c36be371 100644
--- a/src/src/verify.c
+++ b/src/src/verify.c
@@ -3191,9 +3191,9 @@ if (iplookup)
/* Now do the actual lookup; note that there is no search_close() because
of the caching arrangements. */
- handle = search_open(filename, search_type, 0, NULL, NULL);
- if (handle == NULL) log_write(0, LOG_MAIN|LOG_PANIC_DIE, "%s",
- search_error_message);
+ if (!(handle = search_open(filename, search_type, 0, NULL, NULL)))
+ log_write(0, LOG_MAIN|LOG_PANIC_DIE, "%s", search_error_message);
+
result = search_find(handle, filename, key, -1, NULL, 0, 0, NULL);
if (valueptr != NULL) *valueptr = result;
return (result != NULL)? OK : search_find_defer? DEFER: FAIL;