]> Pileus Git - ~andy/fetchmail/blobdiff - smtp.c
Fix typo repsonsible -> responsible.
[~andy/fetchmail] / smtp.c
diff --git a/smtp.c b/smtp.c
index e6047f8fc3595495d700f76ff138e95fb8badd76..d831249243192b401831e4ce1ed7f93a0ce0f560 100644 (file)
--- a/smtp.c
+++ b/smtp.c
@@ -18,7 +18,7 @@
 #include <signal.h>
 #include "socket.h"
 #include "smtp.h"
-#include "i18n.h"
+#include "gettext.h"
 
 struct opt
 {
@@ -97,8 +97,8 @@ static void SMTP_auth(int sock, char smtp_mode, char *username, char *password,
                }
                if (outlevel >= O_DEBUG)
                        report(stdout, GT_("Challenge decoded: %s\n"), b64buf);
-               hmac_md5(password, strlen(password),
-                        b64buf, strlen(b64buf), digest, sizeof(digest));
+               hmac_md5((unsigned char *)password, strlen(password),
+                        (unsigned char *)b64buf, strlen(b64buf), digest, sizeof(digest));
                snprintf(tmp, sizeof(tmp),
                "%s %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
                username,  digest[0], digest[1], digest[2], digest[3],
@@ -185,15 +185,16 @@ int SMTP_ehlo(int sock, char smtp_mode, const char *host, char *name, char *pass
   *opt = 0;
   while ((SockRead(sock, smtp_response, sizeof(smtp_response)-1)) != -1)
   {
-      int  n = strlen(smtp_response);
+      size_t n;
 
       set_timeout(0);
       (void)set_signal_handler(SIGALRM, alrmsave);
 
-      if (smtp_response[strlen(smtp_response)-1] == '\n')
-         smtp_response[strlen(smtp_response)-1] = '\0';
-      if (smtp_response[strlen(smtp_response)-1] == '\r')
-         smtp_response[strlen(smtp_response)-1] = '\0';
+      n = strlen(smtp_response);
+      if (n > 0 && smtp_response[n-1] == '\n')
+         smtp_response[--n] = '\0';
+      if (n > 0 && smtp_response[n-1] == '\r')
+         smtp_response[--n] = '\0';
       if (n < 4)
          return SM_ERROR;
       smtp_response[n] = '\0';
@@ -329,10 +330,9 @@ int SMTP_ok(int sock, char smtp_mode, int mintimeout)
 
        n = strlen(reply);
        if (n > 0 && reply[n-1] == '\n')
-           n--;
+           reply[--n] = '\0';
        if (n > 0 && reply[n-1] == '\r')
-           n--;
-       reply[n] = '\0';
+           reply[--n] = '\0';
 
        /* stomp over control characters */
        for (i = reply; *i; i++)
@@ -352,16 +352,16 @@ int SMTP_ok(int sock, char smtp_mode, int mintimeout)
 
        last_smtp_ok = time((time_t *) NULL);
 
+       strlcat(smtp_response, reply,  sizeof(smtp_response));
+
        if (strchr("123", reply[0])
                && isdigit((unsigned char)reply[1])
                && isdigit((unsigned char)reply[2])
                && strchr(" ", reply[3])) /* matches space and \0 */ {
-           strlcat(smtp_response, reply, sizeof(smtp_response));
            return SM_OK;
        } else if (reply[3] != '-')
            return SM_ERROR;
 
-       strlcat(smtp_response, reply,  sizeof(smtp_response));
        strlcat(smtp_response, "\r\n", sizeof(smtp_response));
 
        /* set an alarm for smtp ok */