home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume15 / pcmail2 / patch03 next >
Encoding:
Text File  |  1990-12-16  |  7.5 KB  |  285 lines

  1. Newsgroups: comp.sources.misc
  2. X-UNIX-From: mcsun!info.win.tue.nl!news
  3. subject: v15i098: pc-mail release 2 patch 3
  4. from: wswietse@svbs01.bs.win.tue.nl (Wietse Venema)
  5. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  6.  
  7. Posting-number: Volume 15, Issue 98
  8. Submitted-by: wswietse@svbs01.bs.win.tue.nl (Wietse Venema)
  9. Archive-name: pcmail2/patch03
  10.  
  11. This is the third patch for the pc-mail release 2 package that appeared
  12. in comp.sources.misc january 1990. 
  13.  
  14. Sources and earlier patches can be obtained via anonymous ftp from the
  15. comp.sources.misc archives at uunet.uu.net, or from the author's
  16. machine at ftp.win.tue.nl (internet address 131.155.2.8). The latter
  17. host also has a directory tree with up-to-date MS-DOS binaries.
  18.  
  19. The following four problems are taken care of by this patch:
  20.  
  21. 1 - Allow UUCP control messages (S, H, etc.) to span more than one packet.
  22.     The problem would manifest itself as garbage appearing at the
  23.     beginning of incoming e-mail messages, but only if the g protocol
  24.     was being used. Thanks to Jim OBrien (JEO01@albnydh2.bitnet) for
  25.     providing the information that led to the resolution of the problem.
  26.  
  27. 2 - The sscanf(3) implementations with Microsoft C and Turbo C behave 
  28.     different from the UNIX versions that I tested the programs with. 
  29.     This caused the displayed numbers of (new, out, in or sent) messages 
  30.     to be wrong. The program no longer uses sscanf(3) to parse file names. 
  31.  
  32. 3 - Turbo C thrashes memory when it is freed. The program no longer
  33.     tries to access members of data structures that have been freed.
  34.     Thanks to Richard Brittain (richard@calvin.spp.cornell.edu) for
  35.     pointing out the problem and its solution.
  36.  
  37. 4 - After the protocol negotiation has completed, the program now allows 
  38.     the remote host some time to change its tty mode settings. The problem 
  39.     would sometimes result in the loss of the first packet sent by the PC, 
  40.     and could cause 'g' protocol initialization failures. Thanks to Richard
  41.     Brittain (richard@calvin.spp.cornell.edu) for reporting the problem.
  42.  
  43. The patches are in the form of context diffs: for each block of changed
  44. text, the old one appears first, followed by the corrected one.  The
  45. nature of the changes is indicated in the first column:  replacements
  46. are indicated with a `!' character, additions with  `+', and deletions
  47. with `-'. If you don't have the patch program it should not be too hard
  48. to apply the corrections by hand.
  49.  
  50. *** protomsg.c-    Mon Jan 22 13:04:33 1990
  51. --- protomsg.c    Sat Oct 13 19:33:48 1990
  52. ***************
  53. *** 45,53 ****
  54.   /* CREATION DATE
  55.   /*      Thu Mar 26 16:14:57 GMT+1:00 1987
  56.   /* LAST MODIFICATION
  57. ! /*    90/01/22 13:02:28
  58.   /* VERSION/RELEASE
  59. ! /*    2.1
  60.   /*--*/
  61.   
  62.   #include "defs.h"
  63. --- 45,53 ----
  64.   /* CREATION DATE
  65.   /*      Thu Mar 26 16:14:57 GMT+1:00 1987
  66.   /* LAST MODIFICATION
  67. ! /*    90/10/13 19:33:46
  68.   /* VERSION/RELEASE
  69. ! /*    2.3
  70.   /*--*/
  71.   
  72.   #include "defs.h"
  73. ***************
  74. *** 90,99 ****
  75.   public char *hear()
  76.   {
  77.       register int nread;
  78.   
  79. !     if ((nread = CALL(Read)(ttfd,msgin,MSGBUF)) < 0)
  80. !     trap(E_LOST,"FAILED (link lost)");
  81. !     msgin[nread] = '\0';
  82.       debug(4)("got \"%s\"\n",msgin);
  83.       return(msgin);
  84.   }
  85. --- 90,108 ----
  86.   public char *hear()
  87.   {
  88.       register int nread;
  89. +     register int bufpos = 0;
  90.   
  91. !     /* Allow a message to span multiple packets ... */
  92. !     for (;;) {
  93. !     if ((nread = CALL(Read)(ttfd,msgin+bufpos,MSGBUF-bufpos)) <= 0)
  94. !         trap(E_LOST,"FAILED (link lost)");
  95. !     if ((bufpos += nread) >= MSGBUF)
  96. !         trap(E_LOST,"FAILED (message buffer overflow)");
  97. !     msgin[bufpos] = '\0';
  98. !     if (strlen(msgin) < bufpos)
  99. !         break;
  100. !     }
  101.       debug(4)("got \"%s\"\n",msgin);
  102.       return(msgin);
  103.   }
  104. *** newseqno.c-    Mon Jan 29 15:50:48 1990
  105. --- newseqno.c    Sat Oct 13 18:47:33 1990
  106. ***************
  107. *** 30,40 ****
  108.   /* CREATION DATE
  109.   /*      Sat Mar 28 18:10:53 GMT+1:00 1987
  110.   /* LAST MODIFICATION
  111. ! /*    90/01/29 15:50:46
  112.   /* VERSION/RELEASE
  113. ! /*    2.2
  114.   /*--*/
  115.   
  116.   #include "defs.h"
  117.   #include "path.h"
  118.   #include "ndir.h"
  119. --- 30,42 ----
  120.   /* CREATION DATE
  121.   /*      Sat Mar 28 18:10:53 GMT+1:00 1987
  122.   /* LAST MODIFICATION
  123. ! /*    90/10/13 18:47:32
  124.   /* VERSION/RELEASE
  125. ! /*    2.4
  126.   /*--*/
  127.   
  128. + #include <ctype.h>
  129.   #include "defs.h"
  130.   #include "path.h"
  131.   #include "ndir.h"
  132. ***************
  133. *** 72,85 ****
  134.   public unsigned seqno(s)
  135.   char   *s;
  136.   {
  137. !     unsigned seq;
  138. !     char    junk = 0;
  139.   
  140. !     /* MicroSoft C sscanf() does not terminate if assignment to seq fails */
  141.   
  142. !     if (strlen(s) == NAMELEN && sscanf(s + 1, "%u%c", &seq, &junk) == 1
  143. !     && junk == 0)
  144. !     return (seq);
  145.       else
  146.       return (0);
  147.   }
  148. --- 74,104 ----
  149.   public unsigned seqno(s)
  150.   char   *s;
  151.   {
  152. !     long    atol();
  153.   
  154. !     /*
  155. !      * Originally, we used sscanf() to parse the string:
  156. !      * 
  157. !      * sscanf(s, "%u%c", &seq, &junk) == 1
  158. !      * 
  159. !      * but that caused problems with Microsoft C (%c conversion is done even
  160. !      * if the %u conversion fails) and Turbo C (assigment to junk even if no
  161. !      * %c conversion is performed). Remedy: do not try to parse the string with
  162. !      * sscanf().
  163. !      */
  164.   
  165. !     if (strlen(s) == NAMELEN && isalpha(*s) && alldig(s+1))
  166. !     return ((unsigned int) atol(s+1));
  167.       else
  168.       return (0);
  169. + }
  170. + /* alldig - does string contain digits only? */
  171. + hidden int alldig(s)
  172. + register char *s;
  173. + {
  174. +     while (*s && isascii(*s) && isdigit(*s))
  175. +     s++;
  176. +     return (*s == 0);
  177.   }
  178. *** pager.c-    Tue Apr 17 11:41:39 1990
  179. --- pager.c    Tue Apr 17 11:45:53 1990
  180. ***************
  181. *** 142,150 ****
  182.   /* CREATION DATE
  183.   /*      Fri Apr  3 22:06:00 GMT+1:00 1987
  184.   /* LAST MODIFICATION
  185. ! /*    90/01/22 13:02:21
  186.   /* VERSION/RELEASE
  187. ! /*    2.1
  188.   /*--*/
  189.   
  190.   #include <stdio.h>
  191. --- 142,150 ----
  192.   /* CREATION DATE
  193.   /*      Fri Apr  3 22:06:00 GMT+1:00 1987
  194.   /* LAST MODIFICATION
  195. ! /*    90/04/17 11:45:48
  196.   /* VERSION/RELEASE
  197. ! /*    2.2
  198.   /*--*/
  199.   
  200.   #include <stdio.h>
  201. ***************
  202. *** 171,183 ****
  203.   /* close_pager - release memory in a pager file */
  204.   
  205.   public void close_pager(p)
  206. ! register File *p;
  207.   {
  208.       register Line *q;
  209.   
  210.       if (p) {
  211. !     for (q = p->head; q; q = q->next)    /* release lines */
  212.           free((char *) q);
  213.       if (curfile == p)            /* unset current file */
  214.           curfile = 0;
  215.       free((char *) p);            /* release header */
  216. --- 171,186 ----
  217.   /* close_pager - release memory in a pager file */
  218.   
  219.   public void close_pager(p)
  220. ! File   *p;
  221.   {
  222.       register Line *q;
  223. +     register Line *next;
  224.   
  225.       if (p) {
  226. !     for (q = p->head; q; q = next) {    /* release lines */
  227. !         next = q->next;            /* avoid using freed block */
  228.           free((char *) q);
  229. +     }
  230.       if (curfile == p)            /* unset current file */
  231.           curfile = 0;
  232.       free((char *) p);            /* release header */
  233. *** startup.c-    Mon Jan 22 13:04:38 1990
  234. --- startup.c    Sat Oct 13 19:01:39 1990
  235. ***************
  236. *** 40,48 ****
  237.   /* CREATION DATE
  238.   /*      Fri Mar 27 13:43:00 GMT+1:00 1987
  239.   /* LAST MODIFICATION
  240. ! /*    90/01/22 13:02:41
  241.   /* VERSION/RELEASE
  242. ! /*    2.1
  243.   /*--*/
  244.   
  245.   #include <stdio.h>
  246. --- 40,48 ----
  247.   /* CREATION DATE
  248.   /*      Fri Mar 27 13:43:00 GMT+1:00 1987
  249.   /* LAST MODIFICATION
  250. ! /*    90/10/13 19:01:38
  251.   /* VERSION/RELEASE
  252. ! /*    2.2
  253.   /*--*/
  254.   
  255.   #include <stdio.h>
  256. ***************
  257. *** 129,134 ****
  258. --- 129,138 ----
  259.   
  260.       log("OK (startup)");
  261.       systrap = savetrap;                /* get here if expect wins */
  262. +     /* Give remote host some time to switch tty modes... */
  263. +     sleep(1);
  264.       return (0);
  265.   }
  266.   
  267. ***************
  268. *** 136,143 ****
  269.   
  270.   public  endproto()
  271.   {
  272. -     int    *savetrap = systrap;            /* save exception handler */
  273. -     jmp_buf mytrap;
  274.       int     status;
  275.   
  276.       if (Close)                    /* check there is one */
  277. --- 140,145 ----
  278.  
  279.