On 07/03/2013 01:56:46 PM, Felix Janda wrote:
Rob Landley wrote:
> Tail has a double free somewhere. (Aboriginal's more/buildall.sh is
> complaining, that uses toybox in host-tools.) Haven't had time to
track
> it down yet, wondering if anybody else could spot it.
>
> From the behavior it's looking like it's on file close...
[...]
It seems reproducible when using tail on non-seekable files which are
bigger
than count*sizeof(toybuf) and contain no newlines.
Count is initialized in a for loop and starts at 0 on line 164 so I
dunno what this means...
~/toybox tail -f /dev/zero
Ok, that shouldn't return immediately.
Ah, cat the android sdk | ./toybox tail -f does indeed segfault.
Reproducible!
The following seems to fix it. I don't really understand the code
though.
It started life as an external submission meaning I could easily have
missed something while cleaning it up.
In fact this command has todo items in it (comments at the end of
tail_main() and do_tail() about -f support). Apparently I was in the
middle of working on it and lost track under the flood of new commands
I don't get to write because I'm cleaning up submissions.
diff -r f8db1f6ec4ab toys/posix/tail.c
--- a/toys/posix/tail.c Tue Jul 02 00:16:16 2013 -0500
+++ b/toys/posix/tail.c Wed Jul 03 20:54:24 2013 +0200
@@ -168,7 +168,7 @@
}
if (lines) {
- if(try[count] != '\n' && count != len-1) continue;
+ if(try[count] != '\n') continue;
Hmmm, I believe that's related to getting the line count right when the
last line doesn't end with a newline? But I don't remember the
details...
Poking at it...
Rob
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net