[Skiboot] [PATCH 2/2] libc/memmove: Correct the buffer overlap condition
Stewart Smith
stewart at linux.vnet.ibm.com
Thu Feb 5 11:48:38 AEDT 2015
Neelesh Gupta <neelegup at linux.vnet.ibm.com> writes:
> diff --git a/libc/string/memmove.c b/libc/string/memmove.c
> index 3acf1a9..844f300 100644
> --- a/libc/string/memmove.c
> +++ b/libc/string/memmove.c
> @@ -21,15 +21,14 @@ memmove(void *dest, const void *src, size_t n)
> int i;
>
> /* Do the buffers overlap in a bad way? */
> - if (src < dest && src + n >= dest) {
> + if (src < dest && src + n - 1 >= dest) {
> /* Copy from end to start */
> cdest = dest + n - 1;
> csrc = src + n - 1;
> for (i = 0; i < n; i++) {
> *cdest-- = *csrc--;
> }
> - }
> - else {
> + } else {
Have a test to add?
More information about the Skiboot
mailing list