You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by wr...@apache.org on 2022/05/06 16:55:34 UTC
svn commit: r1900635 - in /apr/apr-util/branches/1.7.x: ./ buckets/apr_brigade.c
Author: wrowe
Date: Fri May 6 16:55:34 2022
New Revision: 1900635
URL: http://svn.apache.org/viewvc?rev=1900635&view=rev
Log:
Fix pointer arithmetic for 'void *'
Authored-by: mturk
Backports: 1895464
Modified:
apr/apr-util/branches/1.7.x/ (props changed)
apr/apr-util/branches/1.7.x/buckets/apr_brigade.c
Propchange: apr/apr-util/branches/1.7.x/
------------------------------------------------------------------------------
Merged /apr/apr/trunk:r1895464
Modified: apr/apr-util/branches/1.7.x/buckets/apr_brigade.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.7.x/buckets/apr_brigade.c?rev=1900635&r1=1900634&r2=1900635&view=diff
==============================================================================
--- apr/apr-util/branches/1.7.x/buckets/apr_brigade.c (original)
+++ apr/apr-util/branches/1.7.x/buckets/apr_brigade.c Fri May 6 16:55:34 2022
@@ -356,19 +356,18 @@ APU_DECLARE(apr_status_t) apr_brigade_sp
#if !APU_HAVE_MEMMEM
static const void *
-memmem(const void *hay, size_t hay_len, const void *needle, size_t needle_len)
+memmem(const void *_hay, size_t hay_len, const void *needle, size_t needle_len)
{
-
if (hay_len < needle_len || !needle_len || !hay_len) {
return NULL;
}
else {
-
apr_size_t len = hay_len - needle_len + 1;
- const void *end = hay + hay_len;
+ const apr_byte_t *hay = (apr_byte_t *)_hay;
+ const apr_byte_t *end = hay + hay_len;
while ((hay = memchr(hay, *(char *)needle, len))) {
- len = end - hay - needle_len + 1;
+ len = (apr_size_t)(end - hay) - needle_len + 1;
if (memcmp(hay, needle, needle_len) == 0 ) {
break;