OSSP CVS Repository

ossp - Difference in ossp-pkg/lmtp2nntp/lmtp.c versions 1.18 and 1.19
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

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