[Raw Msg Headers][Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

smtp client segfaulting



I found the culprit.

If you have RFC822TABS undefined (i.e. *do* convert tabs to spaces) then
smtp segfaults horribly in chunking mode.  It also *may* just send
wrong data in non-chunking mode but I did not check it.  The problem
is in libta/swriteheaders.c.  One piece inside "if (*WriteTabs == '0')"
is horribly broken.  's' and 'linelen' are mangled by the time this part
is run; and hunk size is not upscaled properly.

Strange thing, when I changed it it still segfaulted until I recompiled
this piece without optimization (gcc 2.7.2 on SPARC/Solaris 2.5.1).
Apparently, there is some other problem too.  In any case my changes seem
to do the right thing.  Please take a look, Matti.

--- swriteheaders.c     2000/02/25 18:12:28     1.8
+++ swriteheaders.c     2000/03/17 18:02:07
@@ -79,16 +79,20 @@
            if (*WriteTabs == '0') {
              /* Expand line TABs */
              int col = 0;
+             s = *msgheaders;
+             linelen = strlen(s);
              for (; linelen > 0; --linelen, ++s) {
                if (*s == '\t') {
                  int c2 = col + 8 - (col & 7);
                  while (col < c2) {
                    *p++ = ' ';
                    ++col;
+                   hsize++;
                  }
                } else {
                  ++col;
                  *p++ = *s;
+                 hsize++;
                }
              }
            }

Eugene