[PATCH] aarch64: Revert "aarch64: Optimized implementation of strnlen" [BZ #25825]

zhuyan (M) zhuyan34@huawei.com
Wed Apr 15 14:17:46 GMT 2020


On Apr 15 2020, Andreas wrote:
>On Apr 15 2020, Florian Weimer via Libc-alpha wrote:
>
>> * zhuyan:
>>
>>> After commit 2911cb68ed3d6c515ad1979237e74e1fefab3674("aarch64:
>>> Optimized implementation of strnlen"), there is a problem when 
>>> calling the strnlen interface to handle the string length of 9 or 
>>> more
>>>
>>> This reverts commit 2911cb68ed3d6c515ad1979237e74e1fefab3674.
>>
>> Do you have a test case for this bug?  Or is it already caught by the 
>> test suite?
>
>https://build.opensuse.org/package/live_build_log/home:Andreas_Schwab:glibc/glibc:testsuite/a/aarch64
>has no related failures.

There is a testcase.

#include <stdio.h>
#include <string.h>

void init_base(char *base, int len)
{
	int i;
	for (i = 0; i < len; i++) {
		base[i] = 'x';
	}
	base[len] = '\0';
}

int main(int argc, char *argv[])
{
	int i;
	char base[1000];
	char buff[1000];
	size_t n;
	
	for (i = 1; i < 1000; i++) {
		memset(buff, 0, 1000);
		init_base(base, i);		
		n = strnlen(base, 1000);      
		if ( i == n )
			printf("size=%d is equel\n", i);
		else
			printf("size=%d is not equel%s\n", i);
	}

    return 0;
}


The execution log is as follows:

arm64be /tmp # ./arm64be-test_strnlen
size=1 is equel
size=2 is equel
size=3 is equel
size=4 is equel
size=5 is equel
size=6 is equel
size=7 is equel
size=8 is equel
size=9 is not equel
size=10 is not equel
size=11 is not equel
size=12 is not equel
size=13 is not equel


Thanks,
Yan Zhu


More information about the Libc-alpha mailing list