minor buglet in ls.c w/ serial console

Denton Gentry denny at dominetsystems.com
Fri Mar 9 04:35:14 UTC 2001


Package: busybox
Version: 0.49
Severity: normal

  There is a minor buglet in ls.c if BB_FEATURE_AUTOWIDTH is
defined. The variable terminal_width is uninitialized, and
expects to be set by either the -w argument or by the TIOCGWINSZ
ioctl issued in ls_main. If the system is using a serial console
TIOCGWINSZ will set win.ws_row = win.ws_col = 0 because it hasn't
a clue how big the terminal is. This leads to a divide by zero error
in showfiles().

  The fix is to initialize terminal_width to a default value, in case
TIOCGWINSZ returns a bogus value. I also changed TERMINAL_WIDTH,
COLUMN_WIDTH and COLUMN_GAP to #defines because they are used as such
(and gcc 2.95.2 complains about non-constant initializers if I leave
them as const ints).

diff -r1.1.1.1 ls.c
44,46c44,46
< static const int TERMINAL_WIDTH = 80;		/* use 79 if your terminal has
linefold bug */
< static const int COLUMN_WIDTH = 14;		/* default if AUTOWIDTH not
defined */
< static const int COLUMN_GAP = 2;			/* includes the file type char, if
present */
---
> #define	TERMINAL_WIDTH	80	/* use 79 if your terminal has linefold bug */
> #define COLUMN_WIDTH	14	/* default if AUTOWIDTH not defined */
> #define COLUMN_GAP		2	/* includes the file type char, if present */
176c176
< static unsigned short terminal_width;
---
> static unsigned short terminal_width = TERMINAL_WIDTH;

---------------------------------------
Received: (at 1127-done) by bugs.lineo.com; 9 Mar 2001 22:29:33 +0000


More information about the busybox mailing list