summaryrefslogtreecommitdiff
path: root/poll
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 /poll
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 'poll')
-rw-r--r--poll/unix/poll.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/poll/unix/poll.c b/poll/unix/poll.c
index e310004e0..8c890d983 100644
--- a/poll/unix/poll.c
+++ b/poll/unix/poll.c
@@ -75,7 +75,7 @@ APR_DECLARE(apr_status_t) apr_poll(apr_pollfd_t *aprset, apr_int32_t num,
int i, num_to_poll;
#ifdef HAVE_VLA
/* XXX: I trust that this is a segv when insufficient stack exists? */
- struct pollfd pollset[num];
+ struct pollfd pollset[num + 1]; /* +1 since allocating 0 is undefined behaviour */
#elif defined(HAVE_ALLOCA)
struct pollfd *pollset = alloca(sizeof(struct pollfd) * num);
if (!pollset)