Subject: bin/1459: split -l bug
To: None <gnats-bugs@gnats.netbsd.org>
From: Simon J. Gerraty <sjg@zen.void.oz.au>
List: netbsd-bugs
Date: 09/13/1995 22:49:12
>Number:         1459
>Category:       bin
>Synopsis:       split -l does not work
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Sep 13 10:05:02 1995
>Last-Modified:
>Originator:     Simon J. Gerraty
>Organization:
Zen Programming...
>Release:        95-08-18
>Environment:
	
System: NetBSD zen.void.oz.au 1.0A NetBSD 1.0A (ZEN) #0: Fri Aug 18 18:59:14 EST 1995 root@zen.void.oz.au:/f1/usr.src/sys/arch/i386/compile/ZEN i386


>Description:

split -l5 gets an error message about 5 being illegal.  

In fact the error is from dereferencing a random pointer. 
	
>How-To-Repeat:
split -l5 < /etc/motd
split: 5: illegal line count.

>Fix:
	
Index: split.c
===================================================================
RCS file: /local/src/master/usr.src/usr.bin/split/split.c,v
retrieving revision 1.1.1.1
diff -c -b -r1.1.1.1 split.c
*** split.c	1995/04/11 08:52:20	1.1.1.1
--- split.c	1995/09/13 12:43:19
***************
*** 115,121 ****
  		case 'l':		/* Line count. */
  			if (numlines != 0)
  				usage();
! 			if ((numlines = strtol(optarg, &ep, 10)) <= 0 || *p)
  				errx(1, "%s: illegal line count.", optarg);
  			break;
  		default:
--- 115,121 ----
  		case 'l':		/* Line count. */
  			if (numlines != 0)
  				usage();
! 			if ((numlines = strtol(optarg, &ep, 10)) <= 0)
  				errx(1, "%s: illegal line count.", optarg);
  			break;
  		default:
>Audit-Trail:
>Unformatted: