[PATCH] tail can't handle the /proc directory

Denys Vlasenko vda.linux at googlemail.com
Tue Oct 2 03:14:52 PDT 2007


On Tuesday 02 October 2007 10:52, Kazuo TAKADA wrote:
> Hi,
> 
> I found bug in busybox 1.7.2 and before.
> The tail command can't handle the /proc directory and doesn't return
> from a while loop.
> 
> For example:
> ----------------------------------------
> % ./busybox tail /proc/meminfo
> (It doesn't exit...)
> ----------------------------------------
> 
> The patch below can resolve this problem.
> 
> ----------------------------------------------------------------------
> --- coreutils/tail.c.orig	2007-09-03 20:48:40.000000000 +0900
> +++ coreutils/tail.c	2007-10-02 17:54:34.000000000 +0900
> @@ -51,7 +51,7 @@
>  	struct stat sbuf;
>  
>  	end = current = lseek(fd, 0, SEEK_CUR);
> -	if (!fstat(fd, &sbuf))
> +	if (!fstat(fd, &sbuf) && sbuf.st_size)
>  		end = sbuf.st_size;
>  	lseek(fd, end < current ? 0 : current, SEEK_SET);
>  	r = safe_read(fd, buf, count);
> ----------------------------------------------------------------------

I am applying this patch (see attached). Does it work for you?
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: busybox-1.7.2-tail.patch
Type: text/x-diff
Size: 1062 bytes
Desc: not available
Url : http://busybox.net/lists/busybox/attachments/20071002/eabd3c63/attachment.bin 


More information about the busybox mailing list