[net.news.b] bug in 2.10.3 4.3bsd-beta

mkg@lzwi.UUCP (M.GOSNELL) (10/17/85)

There's a bug in rfuncs.c that can, if conditions are right, cause
readnews and vnews to constantly core dump.  The problem is that the
BITMAPSIZE is one too small and, depending on the value, can cause bitmap
to be one character too small.

The fix is that BITMAPSIZE should be high - low + 1 to include both ends
of the article id range rather than just high - low.  Below is a context
diff of my fix.
   Marsh Gosnell


*** orfuncs.c	Tue Jun 11 17:53:16 1985
--- rfuncs.c	Mon Oct 14 19:25:46 1985
***************
*** 171,177
   * holes), and so we assume the newsrc file is properly ordered, the way
   * we write it out.
   */
! 	if ((ngsize-minartno) > BITMAPSIZE) {
  		/* This should never happen */
  		(void) xerror(" Bitmap not large enough for newsgroup %s", groupdir);
  	}

--- 171,177 -----
   * holes), and so we assume the newsrc file is properly ordered, the way
   * we write it out.
   */
! 	if ((ngsize-minartno) >= BITMAPSIZE) {
  		/* This should never happen */
  		(void) xerror(" Bitmap not large enough for newsgroup %s", groupdir);
  	}
***************
*** 670,675
  #endif /* SORTACTIVE */
  	}
  	(void) fclose(afp);
  	BITMAPSIZE =  8 * ((BITMAPSIZE+7) / 8);
  	bitmap = malloc((unsigned)BITMAPSIZE/8);
  	if (bitmap == NULL)

--- 670,676 -----
  #endif /* SORTACTIVE */
  	}
  	(void) fclose(afp);
+ 	BITMAPSIZE++;	/* remember that size includes both ends */
  	BITMAPSIZE =  8 * ((BITMAPSIZE+7) / 8);
  	bitmap = malloc((unsigned)BITMAPSIZE/8);
  	if (bitmap == NULL)