git://git.exim.org
/
users
/
heiko
/
exim.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d1af835
)
Tidying: Issues detected by gcc --fsanitize=undefined
author
Jeremy Harris
<jgh146exb@wizmail.org>
Fri, 26 Feb 2016 16:14:04 +0000
(16:14 +0000)
committer
Jeremy Harris
<jgh146exb@wizmail.org>
Wed, 2 Mar 2016 22:04:32 +0000
(22:04 +0000)
doc/doc-txt/ChangeLog
patch
|
blob
|
history
src/src/auths/sha1.c
patch
|
blob
|
history
src/src/expand.c
patch
|
blob
|
history
src/src/host.c
patch
|
blob
|
history
src/src/readconf.c
patch
|
blob
|
history
src/src/transports/autoreply.c
patch
|
blob
|
history
diff --git
a/doc/doc-txt/ChangeLog
b/doc/doc-txt/ChangeLog
index 7f8a6254678ea190febad54e0b9f20847a0a2331..a3911ac18819d6af636a2d36039fdfecb0795f17 100644
(file)
--- a/
doc/doc-txt/ChangeLog
+++ b/
doc/doc-txt/ChangeLog
@@
-175,6
+175,11
@@
JH/42 Bug 1796: Fix error logged on a malware scanner connection failure.
HS/04 Add support for keep_environment and add_environment options.
HS/04 Add support for keep_environment and add_environment options.
+JH/43 Tidy coding issues detected by gcc --fsanitize=undefined. Some remain;
+ either intentional arithmetic overflow during PRNG, or testing config-
+ induced overflows.
+
+
Exim version 4.86
-----------------
Exim version 4.86
-----------------
diff --git
a/src/src/auths/sha1.c
b/src/src/auths/sha1.c
index 67a11912e407645596f94aa07dafcad32bff54a0..a92bb71d150a102b414b237cf3a5552dfe4c6d62 100644
(file)
--- a/
src/src/auths/sha1.c
+++ b/
src/src/auths/sha1.c
@@
-62,15
+62,15
@@
Returns: nothing
void
sha1_mid(sha1 *base, const uschar *text)
{
void
sha1_mid(sha1 *base, const uschar *text)
{
-
register
int i;
-u
nsigned
int A, B, C, D, E;
-u
nsigned
int W[80];
+int i;
+uint A, B, C, D, E;
+uint W[80];
base->length += 64;
for (i = 0; i < 16; i++)
{
base->length += 64;
for (i = 0; i < 16; i++)
{
- W[i] = (text[0] << 24) | (text[1] << 16) | (text[2] << 8) | text[3];
+ W[i] = (
(uint)
text[0] << 24) | (text[1] << 16) | (text[2] << 8) | text[3];
text += 4;
}
text += 4;
}
diff --git
a/src/src/expand.c
b/src/src/expand.c
index 66172f378c76d49431d4abe36cce708faa75065f..b4cc79d4b46a7eee0aa387c2424732bef3d1de39 100644
(file)
--- a/
src/src/expand.c
+++ b/
src/src/expand.c
@@
-1073,6
+1073,8
@@
return s;
Returns: a pointer to the character after the last digit
*/
Returns: a pointer to the character after the last digit
*/
+/*XXX consider expanding to int_eximarith_t. But the test for
+"overbig numbers" in 0002 still needs to overflow it. */
static uschar *
read_number(int *n, uschar *s)
static uschar *
read_number(int *n, uschar *s)
diff --git
a/src/src/host.c
b/src/src/host.c
index 90ba852d806d6feff93e14a2c1560fe2cba435a5..6a6e7abf8bcb061c4b326f44e9f622198332a181 100644
(file)
--- a/
src/src/host.c
+++ b/
src/src/host.c
@@
-1067,7
+1067,7
@@
if (Ustrchr(address, ':') != NULL)
/* Handle IPv4 address */
(void)sscanf(CS address, "%d.%d.%d.%d", x, x+1, x+2, x+3);
/* Handle IPv4 address */
(void)sscanf(CS address, "%d.%d.%d.%d", x, x+1, x+2, x+3);
-bin[v4offset] = (x[0] << 24) + (x[1] << 16) + (x[2] << 8) + x[3];
+bin[v4offset] = (
(uint)
x[0] << 24) + (x[1] << 16) + (x[2] << 8) + x[3];
return v4offset+1;
}
return v4offset+1;
}
@@
-1098,7
+1098,7
@@
for (i = 0; i < count; i++)
if (mask == 0) wordmask = 0;
else if (mask < 32)
{
if (mask == 0) wordmask = 0;
else if (mask < 32)
{
- wordmask = (-1) << (32 - mask);
+ wordmask = (
uint)(
-1) << (32 - mask);
mask = 0;
}
else
mask = 0;
}
else
@@
-1321,7
+1321,7
@@
for (i = 0; i < size; i++)
if (mlen == 0) mask = 0;
else if (mlen < 32)
{
if (mlen == 0) mask = 0;
else if (mlen < 32)
{
- mask = (-1) << (32 - mlen);
+ mask = (
uint)(
-1) << (32 - mlen);
mlen = 0;
}
else
mlen = 0;
}
else
diff --git
a/src/src/readconf.c
b/src/src/readconf.c
index ead74c1d039c41a0811b06b111183b16ff6619b5..3654f19d1b4c1609be408425156de73d3db82e81 100644
(file)
--- a/
src/src/readconf.c
+++ b/
src/src/readconf.c
@@
-2039,6
+2039,7
@@
switch (type)
/* Integer held in K: again, allow octal and hex formats, and suffixes K and
M. */
/* Integer held in K: again, allow octal and hex formats, and suffixes K and
M. */
+ /*XXX consider moving to int_eximarith_t (but mind the overflow test 0415) */
case opt_Kint:
{
case opt_Kint:
{
diff --git
a/src/src/transports/autoreply.c
b/src/src/transports/autoreply.c
index d2aad542a1a855ab98ac571f65611f34abd6bc7d..e93267e4876d4d67862e3a77df852ab2ef33f325 100644
(file)
--- a/
src/src/transports/autoreply.c
+++ b/
src/src/transports/autoreply.c
@@
-267,7
+267,6
@@
autoreply_transport_entry(
{
int fd, pid, rc;
int cache_fd = -1;
{
int fd, pid, rc;
int cache_fd = -1;
-int log_fd = -1;
int cache_size = 0;
int add_size = 0;
EXIM_DB *dbm_file = NULL;
int cache_size = 0;
int add_size = 0;
EXIM_DB *dbm_file = NULL;
@@
-522,9
+521,10
@@
if (oncelog != NULL && *oncelog != 0 && to != NULL)
if (then != 0 && (once_repeat_sec <= 0 || now - then < once_repeat_sec))
{
if (then != 0 && (once_repeat_sec <= 0 || now - then < once_repeat_sec))
{
+ int log_fd;
DEBUG(D_transport) debug_printf("message previously sent to %s%s\n", to,
(once_repeat_sec > 0)? " and repeat time not reached" : "");
DEBUG(D_transport) debug_printf("message previously sent to %s%s\n", to,
(once_repeat_sec > 0)? " and repeat time not reached" : "");
- log_fd =
Uopen(logfile, O_WRONLY|O_APPEND|O_CREAT, ob->mode)
;
+ log_fd =
logfile ? Uopen(logfile, O_WRONLY|O_APPEND|O_CREAT, ob->mode) : -1
;
if (log_fd >= 0)
{
uschar *ptr = log_buffer;
if (log_fd >= 0)
{
uschar *ptr = log_buffer;