OSSP CVS Repository

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

Check-in Number: 1340
Date: 2001-Nov-14 15:22:25 (local)
2001-Nov-14 14:22:25 (UTC)
User:thl
Branch:
Comment: ALERT! The line folding algorithm in LMTP2NNTP_1_1_0 had a bug when wrapping long lines. It used argz_insert() inside an iteration loop while manipulating the elements the loop's based on. When the element being inserted did not fit into the previously allocated buffer, a realloc() occured. This rendered the iteration loop pointer invalid causing the code to write into the wilderness. This caused segfaults at the very best but it also happend that the folding code hung in an arbitrary loop effectively exhausting all available CPU horsepower. This happend on our live machine and was reported by ricudis@paiko.gr, too. This fix is the ultimate reason for releasing LMTP2NNTP_1_1_1.
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/msg.c      1.18 -> 1.19     13 inserted, 2 deleted
ossp-pkg/lmtp2nntp/test.sh      1.7 -> 1.8     11 inserted, 7 deleted

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

--- msg.c        2001/09/12 14:35:14     1.18
+++ msg.c        2001/11/14 14:22:25     1.19
@@ -258,6 +258,8 @@
     char         cOld;
     int          n;
     char        *cpHeaders;
+    char        *azNewheaders;
+    size_t       asNewheaders;
 
     log0(msg, DEBUG, "verify Newsgroups");
     if (msg->azNewsgroups == NULL)
@@ -304,6 +306,8 @@
      * Fragments exceeding WRAPAT characters without having a blank as a
      * splitting point are forcibly cut at a non-blank character.
      */
+    azNewheaders = NULL;
+    asNewheaders = 0;
     cp = NULL;
     while ((cp = argz_next(msg->azHeaders, msg->asHeaders, cp)) != NULL) {
         if (strlen(cp) > WRAPAT) {
@@ -341,11 +345,18 @@
                 strcat(cpWrap, WRAPUSING);
                 strcat(cpWrap, cpRem);
             }
-            argz_delete(&msg->azHeaders, &msg->asHeaders, cp);
-            argz_insert(&msg->azHeaders, &msg->asHeaders, cp, cpWrap);
+            argz_add(&azNewheaders, &asNewheaders, cpWrap);
+            log2(msg, DEBUG, "a folded header \"%{text}D\"", cpWrap, strlen(cpWrap));
             free(cpWrap);
         }
+        else {
+            argz_add(&azNewheaders, &asNewheaders, cp);
+            log2(msg, DEBUG, "verbatim header \"%{text}D\"", cp, strlen(cp));
+        }
     }
+    free(msg->azHeaders);
+    msg->azHeaders = azNewheaders;
+    msg->asHeaders = asNewheaders;
 
     log0(msg, DEBUG, "strigify headers");
     argz_stringify(msg->azHeaders, msg->asHeaders, '\n');


ossp-pkg/lmtp2nntp/test.sh 1.7 -> 1.8

--- test.sh      2001/10/15 14:22:12     1.7
+++ test.sh      2001/11/14 14:22:25     1.8
@@ -16,14 +16,18 @@
 Message-Id: <200108141251.f7ECpmn74812@dev.de.cw.net>
 From: Thomas Lotterer <Thomas.Lotterer@example.com>
 Received: from cw.example.com (cw.example.com [10.1.1.32])
-    by gateway.example.com (8.9.2/8.9.2/$Revision: 1.7 $) with SMTP id NAA08840
+    by gateway.example.com (8.9.2/8.9.2/$Revision: 1.8 $) with SMTP id NAA08840
     for <thomas.lotterer@gateway.example.com>; Mon, 2 Apr 2001 13:20:25 +0200 (MET DST)
 Received: from history (history.example.org [195.143.102.41])
-    by cw.example.com (8.11.0/8.11.0/$Revision: 1.7 $) with ESMTP id f32BKPb12235
+    by cw.example.com (8.11.0/8.11.0/$Revision: 1.8 $) with ESMTP id f32BKPb12235
     for <thomas.lotterer@example.com>; Mon, 2 Apr 2001 13:20:25 +0200
 Received: from example.org (littlemua.example.org [195.143.103.160])
         by history (8.8.8/8.8.8) with ESMTP id LAA12678;
         Mon, 2 Apr 2001 11:23:14 GMT
+X-Linefoldingtest: This is a very long line. It is assumed this line will be
+    wrapped in order to fit. Please note: the quick brown fox jumps over the lazy
+    dog. Did you know that my first computer was a Texas Instruments TI99/4A?
+    What a device! Had a 16bit CPU before the Commodore C64 area has begun.
 Subject: lmtp2nntp testmessage.viasendmail
 
 ..
@@ -114,7 +118,7 @@
 echon "checking whether a valid fake posting succeeds ... "
 prolog
 newmsg
-./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -l ${LOG}:${FILE} -m "${MFILT}" -n ${NODE} -s 1000 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ; RC=$
+./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -l ${LOG}:${FILE} -m "${MFILT}" -n ${NODE} -s 1500 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ; RC=$
 RC="";
 if [ 1 -eq `egrep <${STDOUT} '^220[- ]LMTP Service ready'       | wc -l` ]; then RC="${RC}init "; fi
 if [ 1 -eq `egrep <${STDOUT} '^250[- ].*pleased to meet you'    | wc -l` ]; then RC="${RC}LHLO "; fi
@@ -132,7 +136,7 @@
 echon "checking whether -m option blocks invalid sender ... "
 prolog
 newmsg
-( MFILT=".*@is.invalid" ; ./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -l ${LOG}:${FILE} -m "${MFILT}" -n ${NODE} -s 1000 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ) ; RC=$?
+( MFILT=".*@is.invalid" ; ./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -l ${LOG}:${FILE} -m "${MFILT}" -n ${NODE} -s 1500 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ) ; RC=$?
 RC="";
 if [ 1 -eq `egrep <${STDOUT} '^220[- ]LMTP Service ready'       | wc -l` ]; then RC="${RC}init "; fi
 if [ 1 -eq `egrep <${STDOUT} '^250[- ].+pleased to meet you'    | wc -l` ]; then RC="${RC}LHLO "; fi
@@ -168,7 +172,7 @@
 echon "checking whether -c option fails on invalid local host address ... "
 prolog
 newmsg
-( LOCAL="10.255.255.255" ; ./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -l ${LOG}:${FILE} -m "${MFILT}" -n ${NODE} -s 1000 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ) ; RC=$?
+( LOCAL="10.255.255.255" ; ./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -l ${LOG}:${FILE} -m "${MFILT}" -n ${NODE} -s 1500 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ) ; RC=$?
 RC="";
 if [ 1 -eq `egrep <${STDOUT} '^220[- ]LMTP Service ready'       | wc -l` ]; then RC="${RC}init "; fi
 if [ 1 -eq `egrep <${FILE}   'error.+binding'                   | wc -l` ]; then RC="${RC}bind "; fi
@@ -181,7 +185,7 @@
 echon "checking whether -g envelope option blocks invalid group ... "
 prolog
 newmsg
-( GROUP="foo.*" ; ./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g envelope -d ${HOST} -l ${LOG}:${FILE} -m "${MFILT}" -n ${NODE} -s 1000 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ) ; RC=$?
+( GROUP="foo.*" ; ./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g envelope -d ${HOST} -l ${LOG}:${FILE} -m "${MFILT}" -n ${NODE} -s 1500 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ) ; RC=$?
 RC="";
 if [ 1 -eq `egrep <${STDOUT} '^220[- ]LMTP Service ready'       | wc -l` ]; then RC="${RC}init "; fi
 if [ 1 -eq `egrep <${STDOUT} '^250[- ].*pleased to meet you'    | wc -l` ]; then RC="${RC}LHLO "; fi
@@ -200,7 +204,7 @@
 echon "checking whether -d option times out for invalid host ... "
 prolog
 newmsg
-( HOST="10.255.255.255" ; ./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -l ${LOG}:${FILE} -m "${MFILT}" -n ${NODE} -s 1000 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ) ; RC=$?
+( HOST="10.255.255.255" ; ./lmtp2nntp <${STDIN} -c ${LOCAL} -o 250/2.0.0 -g arg -d ${HOST} -l ${LOG}:${FILE} -m "${MFILT}" -n ${NODE} -s 1500 -t nntp:connect=1 ${GROUP} >${STDOUT} 2>${STDERR} ) ; RC=$?
 RC="";
 if [ 1 -eq `egrep <${STDOUT} '^220[- ]LMTP Service ready'       | wc -l` ]; then RC="${RC}init "; fi
 if [ 1 -eq `egrep <${FILE}   'warning.+connect.+failed'         | wc -l` ]; then RC="${RC}conn "; fi

CVSTrac 2.0.1