[comp.sources.bugs] PC-MAIL release 2, Patch 1

wietse@wzv.win.tue.nl (Wietse Z. Venema) (02/11/90)

This is a re-post of a patch posted earlier. Apparently, it never
made it out of our country; every now and then there seems to be
a major lossage of news at our national or continental backbone.

This patch takes care of a bug in some MicroSoft C implementations of
the sscanf() library function that causes the pc-mail programs to
believe there is more unread mail than there actually is. This problem
definitely does not occur on the UNIX systems that I tried the software
on (SunOS 4.0.3 and MicroPort System-V/AT 2.3).

In order to apply the patch, cd to the `main' subdirectory and feed
this article to the patch command. If you do not have the patch program,
the changes are quite straightforward and can easily be applied by hand.

*** newseqno.c-	Mon Jan 22 13:04:30 1990
--- newseqno.c	Mon Jan 29 15:50:48 1990
***************
*** 30,38 ****
  /* CREATION DATE
  /*      Sat Mar 28 18:10:53 GMT+1:00 1987
  /* LAST MODIFICATION
! /*	90/01/22 13:02:19
  /* VERSION/RELEASE
! /*	2.1
  /*--*/
  
  #include "defs.h"
--- 30,38 ----
  /* CREATION DATE
  /*      Sat Mar 28 18:10:53 GMT+1:00 1987
  /* LAST MODIFICATION
! /*	90/01/29 15:50:46
  /* VERSION/RELEASE
! /*	2.2
  /*--*/
  
  #include "defs.h"
***************
*** 72,81 ****
  public unsigned seqno(s)
  char   *s;
  {
!     int     seq;
!     char    junk;
  
!     if (strlen(s) == NAMELEN && sscanf(s + 1, "%u%c", &seq, &junk) == 1)
  	return (seq);
      else
  	return (0);
--- 72,84 ----
  public unsigned seqno(s)
  char   *s;
  {
!     unsigned seq;
!     char    junk = 0;
  
!     /* MicroSoft C sscanf() does not terminate if assignment to seq fails */
! 
!     if (strlen(s) == NAMELEN && sscanf(s + 1, "%u%c", &seq, &junk) == 1
!     && junk == 0)
  	return (seq);
      else
  	return (0);