summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJoe Orton <jorton@apache.org>2022-02-14 15:33:44 +0000
committerJoe Orton <jorton@apache.org>2022-02-14 15:33:44 +0000
commit7bf2b07d1170ccfe0643b49b4d115d5ca5418c17 (patch)
tree19dd6099b154022436c5d80a1ac209f0ce5a5654 /test
parent9bd2e5b1154f6446c713fbc457d41c1e6c9089e6 (diff)
downloadapr-7bf2b07d1170ccfe0643b49b4d115d5ca5418c17.tar.gz
Fix various harmless cases of undefined behaviour, and add a Travis
job testing under UBSan. * poll/unix/poll.c (apr_poll): For the on-stack array allocation use num+1 since allocating a 0-length array is undefined behaviour. * tables/apr_skiplist.c (get_b_rand): Use unsigned integers to avoid signed integer overflow in the left shift. (skiplist_qpush): Avoid calling memcpy(,NULL,0). * random/unix/apr_random.c (apr_random_add_entropy): Avoid calling memcpy(,NULL,0). * test/teststr.c (overflow_strfsize): Avoid signed integer overflow. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1898076 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r--test/teststr.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/test/teststr.c b/test/teststr.c
index 1a1d8fa01..432fb6b21 100644
--- a/test/teststr.c
+++ b/test/teststr.c
@@ -309,7 +309,8 @@ static void overflow_strfsize(abts_case *tc, void *data)
}
for (off = LONG_MAX; off > 1; off /= 2) {
apr_strfsize(off, buf);
- apr_strfsize(off + 1, buf);
+ if (sizeof(apr_off_t) > sizeof(long) || off < LONG_MAX)
+ apr_strfsize(off + 1, buf);
apr_strfsize(off - 1, buf);
}