[net.sources.bugs] rn 4.3 patch #37

lwall@sdcrdcf.UUCP (Larry Wall) (11/17/86)

System: rn version 4.3
Patch #: 37
Priority: depends
Subject: Rn dumps core on appending line to .newsrc
From: mn-at1!alan (Alan Klietz)

Description:
	Rn dumps core on adding a new newsgroup to the
	.newsrc file.
	
Repeat by:
	Create a new newsgroup and then run rn.
	It may dump core depending on your machine type.

Fix:
	The writelast() procedure in last.c does not check
	the ngname string before before flushing out the last
	line of the .newsrc file.  In certain circumstances
	the ngname string is NULL.  On machines which do
	not have *(char *)0 mapped into the address space
	rn will halt with a segment violation error.

	The fix is to check the string before doing the write.

	From rn, say "| patch -d DIR", where DIR is your rn source directory.
	Outside of rn, say "cd DIR; patch <thisarticle".  If you don't have
	the patch program, apply the following by hand, or get patch.

	If patch indicates that patchlevel is the wrong version, you may need
	to apply one or more previous patches, or the patch may already
	have been applied.  See the patchlevel file to find out what has or
	has not been applied.  In any event, don't continue with the patch.

	[Note, I cannot test this patch because rn is being rewritten--law]

	If you are missing previous patches they can be obtained from me:

	Larry Wall
	{allegra,burdvax,cbosgd,hplabs,ihnp4,sdcsvax}!sdcrdcf!lwall

	If you send a mail message of the following form it will greatly speed
	processing:

	Subject: Command
	@SH mailpatch PATH rn 4.3 LIST

	where PATH is a return path FROM ME TO YOU in bang notation, and LIST
	is a list of one or more patches you need, separated by spaces, commas
	and/or hyphens.

Index: patchlevel
Prereq: 36
1c1
< Patch #: 36
---
> Patch #: 37

Index: last.c
Prereq: 
*** last.c.orig	Sun Nov  9 23:11:11 1986
--- last.c	Tue Nov 11 17:09:40 1986
***************
*** 44,50
  writelast()
  {
      if ((tmpfp = fopen(lastname,"w")) != Nullfp) {
! 	fprintf(tmpfp,"%s\n%ld\n%ld\n",ngname,(long)lasttime,(long)lastactsiz);
  	fclose(tmpfp);
      }
      else

--- 44,52 -----
  writelast()
  {
      if ((tmpfp = fopen(lastname,"w")) != Nullfp) {
! 	if (ngname != Nullch)
! 		fprintf(tmpfp,"%s\n%ld\n%ld\n",
! 			ngname,(long)lasttime,(long)lastactsiz);
  	fclose(tmpfp);
      }
      else