[LTP] [PATCH v5 4/4] syscalls: lchown03: Merge into lchown02

Cyril Hrubis chrubis@suse.cz
Tue Sep 2 16:27:04 CEST 2025


Hi!
>  static void run(unsigned int i)
> @@ -70,8 +77,14 @@ static void setup(void)
>  {
>  	bad_addr = tst_get_bad_addr(NULL);
>  
> -	memset(longpath, 'a', LONGPATHSIZE - 1);
> -	longpath[LONGPATHSIZE-1] = 0;
> +	memset(maxpath, 'a', MAXPATH - 1);
> +	maxpath[MAXPATH-1] = 0;
> +
> +	snprintf(longpath, sizeof(longpath), ".");
> +	SAFE_MKDIR("longpath", 0755);
> +	SAFE_SYMLINK("../longpath", "longpath/longpath");
> +	for (int i = 0; i < 43; i++)
> +		strcat(longpath, "/longpath");

There is much more easier way how to get ELOOP, just create two symlinks
pointing to each other.

	SAFE_SYMLINK("infinte_loop_a", "infinite_loop_b");
	SAFE_SYMLINK("infinte_loop_b", "infinite_loop_a");

Trying to resolve either of these ends up in ELOOP.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list