home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / minix / 4318 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  1.6 KB

  1. Path: sparky!uunet!mcsun!sun4nl!tuegate.tue.nl!svin02!wzv!wietse
  2. From: wietse@wzv.win.tue.nl (Wietse Venema)
  3. Newsgroups: comp.os.minix
  4. Subject: newgpkt.c V1.6 fix for off-by-one error
  5. Message-ID: <3818@wzv.win.tue.nl>
  6. Date: 26 Aug 92 16:12:35 GMT
  7. Organization: Eindhoven University of Technology, The Netherlands
  8. Lines: 39
  9.  
  10. I found an off-by-one error in the gwrmsg() routine, that caused the g
  11. protocol driver to send an extraneous packet in case of a message that
  12. "exactly fits". A "<" operator was used instead of a "<=" operator.
  13.  
  14. The problem showed up with messages such as:
  15.  
  16.     S D.hackticS2528 D.hackticS2528 root - D.hackticS2528 0666 root
  17.  
  18. The message, including terminating null byte, fits exactly in
  19. a 64-byte packet. However, the gwrmsg() routine would send two
  20. packets, the second one being filled with 64 null bytes.
  21.  
  22. The extraneous packet would then be interpreted as the first data of
  23. the file to be transmitted, causing havoc with the unbatching of news
  24. batches.
  25.  
  26.     Wietse Venema
  27.     Eindhoven University of Technology
  28.     The Netherlands
  29.  
  30. *** newgpkt.c-    Mon Aug 24 23:26:20 1992
  31. --- newgpkt.c    Tue Aug 25 18:30:07 1992
  32. ***************
  33. *** 293,299 ****
  34.     len = strlen(message) + 1;        /* total length including '\0' */
  35.     while (TRUE) {
  36.       if (gsendpkt(message, len, TRUE) < 0) return(FAILED);
  37. !     if (len < rpktsize) return(OK);    /* end of string */
  38.       message += rpktsize;
  39.       len -= rpktsize;
  40.     }
  41. --- 293,299 ----
  42.     len = strlen(message) + 1;        /* total length including '\0' */
  43.     while (TRUE) {
  44.       if (gsendpkt(message, len, TRUE) < 0) return(FAILED);
  45. !     if (len <= rpktsize) return(OK);/* end of string */
  46.       message += rpktsize;
  47.       len -= rpktsize;
  48.     }
  49.