[BusyBox-cvs] busybox/libbb get_terminal_width_height.c,1.2,1.3

Erik Andersen andersen at busybox.net
Tue Mar 23 23:15:38 UTC 2004


Update of /var/cvs/busybox/libbb
In directory nail:/tmp/cvs-serv10887/libbb

Modified Files:
	get_terminal_width_height.c 
Log Message:
Brian Pomerantz writes:

I've noticed a bug in the "autowidth" feature more, and is probably in
others.  The call to the function get_terminal_width_height() passes
in a file descriptor but that file descriptor is never used, instead
the ioctl() is called with 0.  In more_main() the call to
get_terminal_width_height() passes 0 as the file descriptor instead of
fileno(cin).  This isn't a problem when you more a file (e.g. "more
/etc/passwd") but when you pipe a file to it (e.g. "cat /etc/passwd |
more") the size of the terminal cannot be determined because file
descriptor 0 is not a terminal.  The fix is simple, I've attached a
patch for more.c and get_terminal_width_height.c.


BAPper



Index: get_terminal_width_height.c
===================================================================
RCS file: /var/cvs/busybox/libbb/get_terminal_width_height.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- a/get_terminal_width_height.c	15 Mar 2004 08:28:42 -0000	1.2
+++ b/get_terminal_width_height.c	23 Mar 2004 23:15:35 -0000	1.3
@@ -36,7 +36,7 @@
 {
 	struct winsize win = { 0, 0, 0, 0 };
 #ifdef CONFIG_FEATURE_AUTOWIDTH
-	if (ioctl(0, TIOCGWINSZ, &win) != 0) {
+	if (ioctl(fd, TIOCGWINSZ, &win) != 0) {
 		win.ws_row = 24;
 		win.ws_col = 80;
 	}




More information about the busybox-cvs mailing list