[Skiboot] [PATCH 2/2] libc/memmove: Correct the buffer overlap condition

Neelesh Gupta neelegup at linux.vnet.ibm.com
Thu Feb 5 15:01:13 AEDT 2015


On 02/05/2015 06:18 AM, Stewart Smith wrote:
> 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?

Definitely, in my TODO list. Planning to send them in a separate series
sometime later..

Neelesh.




More information about the Skiboot mailing list