diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libc/stdlib/lsearch.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/libc/stdlib/lsearch.c b/src/lib/libc/stdlib/lsearch.c index 8cad05f510..93e200e1bd 100644 --- a/src/lib/libc/stdlib/lsearch.c +++ b/src/lib/libc/stdlib/lsearch.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: lsearch.c,v 1.5 2014/07/18 04:16:09 matthew Exp $ */ | 1 | /* $OpenBSD: lsearch.c,v 1.6 2021/12/07 04:01:45 cheloha Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 1989, 1993 | 4 | * Copyright (c) 1989, 1993 |
@@ -79,6 +79,11 @@ linear_base(const void *key, const void *base, size_t *nelp, size_t width, | |||
79 | * manual. | 79 | * manual. |
80 | */ | 80 | */ |
81 | ++*nelp; | 81 | ++*nelp; |
82 | memcpy((void *)end, key, width); | 82 | |
83 | /* | ||
84 | * Use memmove(3) to ensure the key is copied cleanly into the | ||
85 | * array, even if the key overlaps with the end of the array. | ||
86 | */ | ||
87 | memmove((void *)end, key, width); | ||
83 | return((void *)end); | 88 | return((void *)end); |
84 | } | 89 | } |