Both functions cast void * to int * and dereference, reading 4 bytes as an
integer instead of a single byte. This is passed to memchr() which expects a
byte value. On unaligned addresses this causes crashes on ARM/mips etc, and
search for the wrong byte on big endian platforms. Fixed to cast to
const unsigned char * and dereference a single byte. This is marked as
minor because these functions were added in 2.2 by commit
5eb96cbcbc
("MINOR: standard: Add my_memspn and my_memcspn") and have not been used
since then.
{
size_t ret = 0;
- while (ret < len && memchr(accept, *((int *)str), acceptlen)) {
+ while (ret < len && memchr(accept, *((const unsigned char *)str), acceptlen)) {
str++;
ret++;
}
size_t ret = 0;
while (ret < len) {
- if(memchr(reject, *((int *)str), rejectlen))
+ if (memchr(reject, *((const unsigned char *)str), rejectlen))
return ret;
str++;
ret++;