[comp.org.usenix] Fix to Utilities/Zonk on the Usenix '87 software tape

kwlalonde@watmath.waterloo.edu (Ken Lalonde) (03/03/88)

The version of "zonk" I posted to net.sources in September of '85
contained a serious bug.  I posted a fix to net.sources some time
later.  The version of zonk on the Usenix '87 tape still has the bug.
The patch below fixes the bug, and works for 4.3BSD as well as 4.2.

*** sys_zonk.c.old	Wed Mar  2 18:52:39 1988
--- sys_zonk.c	Wed Mar  2 18:58:13 1988
***************
*** 21,31 ****
  		u.u_error = EINVAL;
  		return;
  	}
! 	for (count = 0, p = proc; p < procNPROC; p++)
  		if (p->p_uid == uid) {
  			count++;
  			if (sig)
  				psignal(p, sig);
  		}
  	u.u_r.r_val1 = count;
  }
--- 21,39 ----
  		u.u_error = EINVAL;
  		return;
  	}
! 	count = 0;
! #ifdef BSD4_3
! 	for (p = allproc; p != NULL; p = p->p_nxt) {
! #else
! 	for (p = proc; p < procNPROC; p++) {
! 		if (p->p_stat == NULL)
! 			continue;
! #endif
  		if (p->p_uid == uid) {
  			count++;
  			if (sig)
  				psignal(p, sig);
  		}
+ 	}
  	u.u_r.r_val1 = count;
  }