diff options
Diffstat (limited to 'src/lib/libc/string/strstr.c')
| -rw-r--r-- | src/lib/libc/string/strstr.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/libc/string/strstr.c b/src/lib/libc/string/strstr.c index 241a080e7a..f5f460a251 100644 --- a/src/lib/libc/string/strstr.c +++ b/src/lib/libc/string/strstr.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: strstr.c,v 1.9 2020/04/16 12:37:52 claudio Exp $ */ | 1 | /* $OpenBSD: strstr.c,v 1.11 2026/06/23 13:10:40 tim Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2005-2018 Rich Felker | 4 | * Copyright (c) 2005-2018 Rich Felker |
| @@ -37,8 +37,8 @@ twobyte_strstr(const unsigned char *h, const unsigned char *n) | |||
| 37 | static char * | 37 | static char * |
| 38 | threebyte_strstr(const unsigned char *h, const unsigned char *n) | 38 | threebyte_strstr(const unsigned char *h, const unsigned char *n) |
| 39 | { | 39 | { |
| 40 | uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8; | 40 | uint32_t nw = (uint32_t)n[0]<<24 | n[1]<<16 | n[2]<<8; |
| 41 | uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8; | 41 | uint32_t hw = (uint32_t)h[0]<<24 | h[1]<<16 | h[2]<<8; |
| 42 | for (h+=2; *h && hw != nw; hw = (hw|*++h)<<8); | 42 | for (h+=2; *h && hw != nw; hw = (hw|*++h)<<8); |
| 43 | return *h ? (char *)h-2 : 0; | 43 | return *h ? (char *)h-2 : 0; |
| 44 | } | 44 | } |
| @@ -46,8 +46,8 @@ threebyte_strstr(const unsigned char *h, const unsigned char *n) | |||
| 46 | static char * | 46 | static char * |
| 47 | fourbyte_strstr(const unsigned char *h, const unsigned char *n) | 47 | fourbyte_strstr(const unsigned char *h, const unsigned char *n) |
| 48 | { | 48 | { |
| 49 | uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3]; | 49 | uint32_t nw = (uint32_t)n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3]; |
| 50 | uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3]; | 50 | uint32_t hw = (uint32_t)h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3]; |
| 51 | for (h+=3; *h && hw != nw; hw = hw<<8 | *++h); | 51 | for (h+=3; *h && hw != nw; hw = hw<<8 | *++h); |
| 52 | return *h ? (char *)h-3 : 0; | 52 | return *h ? (char *)h-3 : 0; |
| 53 | } | 53 | } |
| @@ -129,7 +129,7 @@ twoway_strstr(const unsigned char *h, const unsigned char *n) | |||
| 129 | for (;;) { | 129 | for (;;) { |
| 130 | /* Update incremental end-of-haystack pointer */ | 130 | /* Update incremental end-of-haystack pointer */ |
| 131 | if (z-h < l) { | 131 | if (z-h < l) { |
| 132 | /* Fast estimate for MIN(l,63) */ | 132 | /* Fast estimate for MAX(l,63) */ |
| 133 | size_t grow = l | 63; | 133 | size_t grow = l | 63; |
| 134 | const unsigned char *z2 = memchr(z, 0, grow); | 134 | const unsigned char *z2 = memchr(z, 0, grow); |
| 135 | if (z2) { | 135 | if (z2) { |
