[BusyBox] bug#1106: BusyBox] ln bug!

Matt Kraai kraai at alumni.carnegiemellon.edu
Wed Feb 14 05:01:26 UTC 2001


On Tue, Feb 13, 2001 at 03:14:51PM -0600, Kenneth Chalmers wrote:
> --- utility.c.original	Tue Feb 13 15:02:43 2001
> +++ utility.c	Tue Feb 13 15:03:50 2001
> @@ -1621,7 +1621,7 @@
>  #endif
>  
>  #if defined BB_BASENAME || defined BB_LN || defined BB_SH || defined BB_INIT || \
                              ^^^^^^^^^^^^^
> -	! defined BB_FEATURE_USE_DEVPS_PATCH || defined BB_WGET
> +	! defined BB_FEATURE_USE_DEVPS_PATCH || defined BB_WGET || defined BB_LN
                                                                   ^^^^^^^^^^^^^
Once is probably enough :)

>  char *get_last_path_component(char *path)
>  {
>  	char *s=path+strlen(path)-1;

> --- ln.c.original	Tue Feb 13 14:51:02 2001
> +++ ln.c	Tue Feb 13 15:05:13 2001
> @@ -63,8 +63,15 @@
>  		srcIsDir = is_directory(srcName, FALSE, NULL);	
>  	
>  	if ((srcIsDir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) {
> +		char* srcDirName;
> +		
> +		srcDirName = (char *) malloc(strlen(link_DestName) + 1);
                                      ^^^^^^
Please use xmalloc (and, while you're at it, change the other
malloc call to an xmalloc as well).

> +		strcpy(srcDirName, link_DestName);
> +		
>  		strcat(srcName, "/");
> -		strcat(srcName, link_DestName);
> +		strcat(srcName, get_last_path_component(srcDirName));
> +
> +		free(srcDirName);
>  	}
>  	
>  	if (flag&LN_FORCE)


Regarding your second message, busybox ln has gross behavior if
(a) it is given no arguments or (b) it is given only one argument.

Matt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20010213/ef3b5d2f/attachment.pgp 


More information about the busybox mailing list