svn commit: trunk/busybox: include libbb

Denys Vlasenko vda.linux at googlemail.com
Thu Nov 8 12:09:40 PST 2007


On Thursday 08 November 2007 13:00, pgf at busybox.net wrote:
>  	while (1) {

imagine that looping == 1 here

> -		if (!--looping) {
> -			free(linkpath);
> -			free(buf);
> -			return NULL;
> -		}
> +
>  		linkpath = xmalloc_readlink(buf);

Say we succeed here...

>  		if (!linkpath) {
> -			if (errno == EINVAL) /* not a symlink */
> +			/* not a symlink, or doesn't exist */
> +			if (errno == EINVAL || errno == ENOENT)
>  				return buf;
>  			free(buf);
>  			return NULL;
>  		}
> -		if (linkpath[0] != '/') {
> +

but here we reach 0 and bail out. What was the point in doing
last xmalloc_readlink then?

> +		if (!--looping) {
> +			free(linkpath);
> +			free(buf);
> +			return NULL;
> +		}

That's why I moved this check before readlink in the first place.

It's mostly theoretical anyway, since MAXSYMLINKS is 20 or 30 iirc -
much bigger than any reasonable case (and bigger than kernel's limit).
--
vda



More information about the busybox mailing list