]> git.mikk.net Git - smtpsink/commitdiff
Correct command length, part 2: compute length not including line terminator.
authorchris mikkelson <chris@mikk.net>
Thu, 1 Apr 2010 04:01:59 +0000 (23:01 -0500)
committerchris mikkelson <chris@mikk.net>
Thu, 1 Apr 2010 04:01:59 +0000 (23:01 -0500)
smtp.c

diff --git a/smtp.c b/smtp.c
index c730052930459d8b79f9f9670b4f456d5e6a5058..71a4b16cf42f0c94db78e7eeaf37e9581bec9e0d 100644 (file)
--- a/smtp.c
+++ b/smtp.c
@@ -258,15 +258,16 @@ do_smtp(struct conn  *c, char **buf, int *len)
                int clen;
 
                if (t) {
+                       clen = t - *buf;
                        t += 2;
                }
                else {
                        t = memchr((void *)*buf, '\n', *len);
                        if (!t) return 0;
-                       t ++;
+                       clen = t - *buf;
+                       t++;
                }
-               clen = t - *buf;
-               *len -= clen;
+               *len -= t - *buf;
                *buf = t;
                
                return do_command(c, cmd, clen);