[Avcheck] Small problem -> solution

Varadi Gabor varadi@mithrandir.hu
Sat, 26 Oct 2002 22:39:00 +0200


--UugvWAfsgieZRqgk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline


 Hi, all.

 I'm found small problema::
 My avcheck send message, but error.

  "unexpected smtp response (need 220): 220-gil.axelero.hu......." 

 This response multiline-banner !! example mail.axelero.hu

tt:~# telnet mail.axelero.hu 25
Trying 195.228.240.10...
Connected to mail.axelero.hu.
Escape character is '^]'.
220-gil.axelero.hu -- Server ESMTP (iPlanet Messaging Server 5.1 HotFix 0.9
(built May 30 2002))
220 Axelero Internet ESMTP open (WE ARE DISALLOW ANY KIND OF SPAM ACTIVITY)

 I'm written patch for avcheck.c (smtpresp)

 This is correct patch ?

 I'm sorry my english.

-- 
    [Varadi Gabor]

--UugvWAfsgieZRqgk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="multi-line.path"

diff -ruN avcheck.c avcheck.c
--- avcheck.c	Thu Oct 10 00:07:59 2002
+++ avcheck.c	Sat Oct 26 22:07:36 2002
@@ -181,8 +182,9 @@
 #ifdef DEBUG
   fprintf(stderr, "(expecting SMTP response %d)\n", exp);
 #else
-  int l;
-  char *p;
+  int l, i;
+  char *p, *e;
+
   l = read(fd, buf, sizeof(buf));
   if (l < 3)
     err(l < 0 ? errno : 0, "unable to read smtp response");
@@ -190,14 +192,26 @@
     err(0, "long line in smtp response");
   if (buf[l-1] == '\r') --l;
   buf[l] = '\0';
-  l = 0;
-  for(p = buf; p < buf+3; ++p)
-    if (*p >= '0' && *p <= '9')
-      l = l * 10 + (*p - '0');
-    else
+  e = p = buf;
+  for (;*p;) {
+    e = p;
+    for (l = i = 0; i < 3; i++, p++)
+      if (*p >= '0' && *p <= '9') {
+        l = l * 10 + (*p - '0');
+      } else
+        break;
+    if (*p == '-') {
+	while (*p && (*p != '\r' && *p != '\n')) {
+	  p++;
+	}
+	while (*p == '\r' || *p == '\n') {
+	  p++;
+	}
+    } else
       break;
+  }
   if (*p != ' ' || l != exp)
-    err(0, "unexpected smtp response (need %d): %s", exp, buf);
+    err(0, "unexpected smtp response (need %d): %s", exp, e);
 #endif
 }
 

--UugvWAfsgieZRqgk--