From 7bf2b07d1170ccfe0643b49b4d115d5ca5418c17 Mon Sep 17 00:00:00 2001 From: Joe Orton Date: Mon, 14 Feb 2022 15:33:44 +0000 Subject: 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 --- test/teststr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test') 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); } -- cgit v1.2.1