OSSP CVS Repository

ossp - Check-in [803]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 803
Date: 2001-Aug-30 15:38:04 (local)
2001-Aug-30 13:38:04 (UTC)
User:thl
Branch:
Comment: lmtp_response() no longer segfaults when a physical line ('\n' terminated) of the logical line input exceeds LMTP_LINE_MAXLEN but wraps the line by cutting it off; manpage header issue was no problem when using pod in Makefile; 00TODO updated;
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/00TODO      1.23 -> 1.24     1 inserted, 3 deleted
ossp-pkg/lmtp2nntp/lmtp.c      1.18 -> 1.19     9 inserted, 1 deleted

ossp-pkg/lmtp2nntp/00TODO 1.23 -> 1.24

--- 00TODO       2001/08/30 08:58:19     1.23
+++ 00TODO       2001/08/30 13:38:04     1.24
@@ -1,8 +1,6 @@
 
 whatsup draufleiten
-ID logging problem, RFC1891 ENVID, 6.2
-lmtp_response segfaults when a physical line ('\n' terminated) of the logical line input exceeds LMTP_LINE_MAXLEN.
-manpage header reads "User Contributed Perl Documentation" - Perl!?
+ID logging, RFC1891 ENVID, 6.2
 
     **** LMTP REDESIGN ****
 


ossp-pkg/lmtp2nntp/lmtp.c 1.18 -> 1.19

--- lmtp.c       2001/08/29 14:58:21     1.18
+++ lmtp.c       2001/08/30 13:38:04     1.19
@@ -346,15 +346,23 @@
             len = sprintf(formatbuf, "%3.3s%c%5.5s ", res->statuscode, dash ? '-' : ' ', res->dsncode);
         else
             len = sprintf(formatbuf, "%3.3s%c", res->statuscode, dash ? '-' : ' ');
+        if ((len + cpE - cpS + 2) > sizeof(formatbuf)) { /* status + line + '\r\n' does not fit into formatbuf */
+            dash = 1;
+            if ((cpE = cpS + sizeof(formatbuf) - 2 - len) <= cpS) /* no space for line at all */
+                return LMTP_ERR_ARG;
+        }
         strncpy(formatbuf+len, cpS, cpE-cpS);
         len += (cpE-cpS);
+        formatbuf[len++] = '\r';
         formatbuf[len++] = '\n';
         do {
             rv = lmtp->io.write(lmtp->wfd, formatbuf, len);
         } while (rv == -1 && errno == EINTR);
         if (rv == -1)
             return LMTP_ERR_SYSTEM;
-        cpS = cpE+1;
+        cpS = cpE;
+        if (*cpS == '\n')
+            cpS++;
     }
     return rc;
 }

CVSTrac 2.0.1