diff options
Diffstat (limited to 'src/lib/libc/string/memmem.c')
| -rw-r--r-- | src/lib/libc/string/memmem.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/libc/string/memmem.c b/src/lib/libc/string/memmem.c index 3b180b4a62..e87c7be37a 100644 --- a/src/lib/libc/string/memmem.c +++ b/src/lib/libc/string/memmem.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: memmem.c,v 1.5 2020/04/16 12:39:28 claudio Exp $ */ | 1 | /* $OpenBSD: memmem.c,v 1.6 2026/06/23 13:09:11 tim Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2005-2020 Rich Felker, et al. | 4 | * Copyright (c) 2005-2020 Rich Felker, et al. |
| @@ -38,8 +38,8 @@ twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) | |||
| 38 | static char * | 38 | static char * |
| 39 | threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) | 39 | threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) |
| 40 | { | 40 | { |
| 41 | uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8; | 41 | uint32_t nw = (uint32_t)n[0]<<24 | n[1]<<16 | n[2]<<8; |
| 42 | uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8; | 42 | uint32_t hw = (uint32_t)h[0]<<24 | h[1]<<16 | h[2]<<8; |
| 43 | for (h+=3, k-=3; k; k--, hw = (hw|*h++)<<8) | 43 | for (h+=3, k-=3; k; k--, hw = (hw|*h++)<<8) |
| 44 | if (hw == nw) return (char *)h-3; | 44 | if (hw == nw) return (char *)h-3; |
| 45 | return hw == nw ? (char *)h-3 : 0; | 45 | return hw == nw ? (char *)h-3 : 0; |
| @@ -48,8 +48,8 @@ threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) | |||
| 48 | static char * | 48 | static char * |
| 49 | fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) | 49 | fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) |
| 50 | { | 50 | { |
| 51 | uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3]; | 51 | uint32_t nw = (uint32_t)n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3]; |
| 52 | uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3]; | 52 | uint32_t hw = (uint32_t)h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3]; |
| 53 | for (h+=4, k-=4; k; k--, hw = hw<<8 | *h++) | 53 | for (h+=4, k-=4; k; k--, hw = hw<<8 | *h++) |
| 54 | if (hw == nw) return (char *)h-4; | 54 | if (hw == nw) return (char *)h-4; |
| 55 | return hw == nw ? (char *)h-4 : 0; | 55 | return hw == nw ? (char *)h-4 : 0; |
