[comp.bugs.4bsd] Cu dereferences null pointers for baud rate. +Fix

gww@marduk.UUCP (Gary Winiger) (09/05/87)

Subject: Cu dereferneces null pointers for baud rate. +Fix
Index:	usr.bin/tip/cu.c 4.3BSD +Fix

Description:
	Cu will dereference null pointers if -s option is passed without
	a following parameter, or if no baud rate is specified.
Repeat-By:
	By inspection of the code.
Fix:
	The attached code solves this problem at Elxsi.

Gary..
{ucbvax!sun,lll-lcc!lll-tis,amdahl!altos86,bridge2}!elxsi!gww
--------- cut --------- snip --------- :.,$w diff -------------
*** /tmp/,RCSt1001225	Fri Jul  3 14:59:51 1987
--- cu.c	Fri Jul  3 14:59:32 1987
***************
*** 1,5 ****
--- 1,8 ----
  /*
   * $Log:	cu.c,v $
+  * Revision 1.2  87/07/03  14:59:16  gww
+  * Correct null pointer dereferences.
+  * 
   * Revision 1.1  87/07/02  17:21:47  gww
   * Initial revision
   * 
***************
*** 11,17 ****
   */
  
  #ifndef lint
! static char *ERcsId = "$Header: cu.c,v 1.1 87/07/02 17:21:47 gww Exp $ ENIX BSD";
  static char sccsid[] = "@(#)cu.c	5.2 (Berkeley) 1/13/86";
  #endif not lint
  
--- 14,20 ----
   */
  
  #ifndef lint
! static char *ERcsId = "$Header: cu.c,v 1.2 87/07/03 14:59:16 gww Exp $ ENIX BSD";
  static char sccsid[] = "@(#)cu.c	5.2 (Berkeley) 1/13/86";
  #endif not lint
  
***************
*** 34,39 ****
--- 37,43 ----
  		exit(8);
  	}
  	CU = DV = NOSTR;
+ 	BR = DEFBR;
  	for (; argc > 1; argv++, argc--) {
  		if (argv[1][0] != '-')
  			PN = argv[1];
***************
*** 49,55 ****
  			break;
  
  		case 's':
! 			if (speed(atoi(argv[2])) == 0) {
  				fprintf(stderr, "cu: unsupported speed %s\n",
  					argv[2]);
  				exit(3);
--- 53,59 ----
  			break;
  
  		case 's':
! 			if ((argc < 3) || (speed(atoi(argv[2])) == 0)) {
  				fprintf(stderr, "cu: unsupported speed %s\n",
  					argv[2]);
  				exit(3);