summaryrefslogtreecommitdiff
path: root/random
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 /random
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 'random')
-rw-r--r--random/unix/apr_random.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/random/unix/apr_random.c b/random/unix/apr_random.c
index b042b66bd..9aee3e989 100644
--- a/random/unix/apr_random.c
+++ b/random/unix/apr_random.c
@@ -238,7 +238,7 @@ APR_DECLARE(void) apr_random_add_entropy(apr_random_t *g,const void *entropy_,
if (p->pool_size < p->bytes+1) {
unsigned char *np = apr_palloc(g->apr_pool,(p->bytes+1)*2);
- memcpy(np,p->pool,p->bytes);
+ if (p->pool) memcpy(np,p->pool,p->bytes);
p->pool = np;
p->pool_size = (p->bytes+1)*2;
}