]> Pileus Git - ~andy/fetchmail/commitdiff
Try to beat a sign-extension bug.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 28 Jun 2000 11:04:34 +0000 (11:04 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 28 Jun 2000 11:04:34 +0000 (11:04 -0000)
svn path=/trunk/; revision=2912

driver.c
fetchmail.c
fetchmail.h
interface.c
rfc822.c
socket.c

index 267b33c19f388317e5658020c8d6af969601af30..14ab16028569abaaf9ce8d4fd04dc7cc8cfbcd70 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -2229,7 +2229,7 @@ const int maxfetch;               /* maximum number of messages to fetch */
                  (dispatches && protocol->retry && !ctl->keep && !ctl->errcount);
        }
 
-   no_error:
+    /* no_error: */
        /* ordinary termination with no errors -- officially log out */
        ok = (protocol->logout_cmd)(mailserver_socket, ctl);
        /*
index 0dfc7e41611c2faec2c66e8be772fab06cde2120..f2f3cff6eff12ca2e9541b8f44d8e41c03a7bcdb 100644 (file)
@@ -44,6 +44,7 @@
 
 #include "getopt.h"
 #include "fetchmail.h"
+#include "socket.h"
 #include "tunable.h"
 #include "smtp.h"
 #include "netrc.h"
@@ -482,10 +483,11 @@ int main(int argc, char **argv)
                && ctl->server.protocol != P_IMAP_GSS
 #endif /* GSSAPI */
                && !ctl->password)
+       {
            if (!isatty(0))
            {
                fprintf(stderr,
-                       _("fetchmail: can't find a password for %s@s.\n"),
+                       _("fetchmail: can't find a password for %s@%s.\n"),
                        ctl->remotename, ctl->server.pollname);
                return(PS_AUTHFAIL);
            }
@@ -500,6 +502,7 @@ int main(int argc, char **argv)
                               ctl->remotename, ctl->server.pollname);
                ctl->password = xstrdup((char *)fm_getpassword(tmpbuf));
            }
+       }
     }
 
     /*
index 4d4022be752154510f8c27e9068aefe4d9497c33..1603f4e6bd62589c00e5623489cca27361908e78 100644 (file)
@@ -432,8 +432,8 @@ void stuff_warning();
 void close_warning_by_mail(struct query *, struct msgblk *);
 
 /* rfc822.c: RFC822 header parsing */
-char *reply_hack(char *, const char *);
-char *nxtaddr(const char *);
+unsigned char *reply_hack(unsigned char *, const unsigned char *);
+unsigned char *nxtaddr(const unsigned char *);
 
 /* uid.c: UID support */
 void initialize_saved_lists(struct query *, const char *);
index e52db466da956cb22e8e052e047d161458bbfa9b..eefcfd1d5066542115e35ec40554677af5cfdeae 100644 (file)
@@ -42,6 +42,7 @@
 #endif
 #include "config.h"
 #include "fetchmail.h"
+#include "socket.h"
 #include "i18n.h"
 #include "tunable.h"
 
index 1024bc8bf8ef7a5304f70c860a9c1f1f4d1fc851..de6008bf3427bf7de4dee234b3e70891d979730b 100644 (file)
--- a/rfc822.c
+++ b/rfc822.c
@@ -22,12 +22,12 @@ static int verbose;
 char *program_name = "rfc822";
 #endif /* TESTMAIN */
 
-char *reply_hack(buf, host)
+unsigned char *reply_hack(buf, host)
 /* hack message headers so replies will work properly */
-char *buf;             /* header to be hacked */
-const char *host;      /* server hostname */
+unsigned char *buf;            /* header to be hacked */
+const unsigned char *host;     /* server hostname */
 {
-    char *from, *cp, last_nws = '\0', *parens_from = NULL;
+    unsigned char *from, *cp, last_nws = '\0', *parens_from = NULL;
     int parendepth, state, has_bare_name_part, has_host_part;
 #ifndef TESTMAIN
     int addresscount = 1;
@@ -59,7 +59,7 @@ const char *host;     /* server hostname */
     for (cp = buf; *cp; cp++)
        if (*cp == ',' || isspace(*cp))
            addresscount++;
-    buf = (char *)xrealloc(buf, strlen(buf) + addresscount * strlen(host) + 1);
+    buf = (unsigned char *)xrealloc(buf, strlen(buf) + addresscount * strlen(host) + 1);
 #endif /* TESTMAIN */
 
     /*
@@ -115,7 +115,7 @@ const char *host;   /* server hostname */
                         && last_nws != ';')
                {
                    int hostlen;
-                   char *p;
+                   unsigned char *p;
 
                    p = from;
                    if (parens_from)
@@ -185,15 +185,15 @@ const char *host; /* server hostname */
     return(buf);
 }
 
-char *nxtaddr(hdr)
+unsigned char *nxtaddr(hdr)
 /* parse addresses in succession out of a specified RFC822 header */
-const char *hdr;       /* header to be parsed, NUL to continue previous hdr */
+const unsigned char *hdr;      /* header to be parsed, NUL to continue previous hdr */
 {
-    static char *tp, address[POPBUFSIZE+1];
-    static const char *hp;
+    static unsigned char *tp, address[POPBUFSIZE+1];
+    static const unsigned char *hp;
     static int state, oldstate;
 #ifdef TESTMAIN
-    static const char *orighdr;
+    static const unsigned char *orighdr;
 #endif /* TESTMAIN */
     int parendepth = 0;
 
@@ -236,14 +236,14 @@ const char *hdr;  /* header to be parsed, NUL to continue previous hdr */
                    continue;
                *++tp = '\0';
            }
-           return(tp > address ? (tp = address) : (char *)NULL);
+           return(tp > address ? (tp = address) : (unsigned char *)NULL);
        }
        else if (*hp == '\\')           /* handle RFC822 escaping */
        {
            if (state != INSIDE_PARENS)
            {
                *tp++ = *hp++;                  /* take the escape */
-               *tp++ = *hp;                    /* take following char */
+               *tp++ = *hp;                    /* take following unsigned char */
            }
        }
        else switch (state)
@@ -348,9 +348,9 @@ const char *hdr;    /* header to be parsed, NUL to continue previous hdr */
 }
 
 #ifdef TESTMAIN
-static void parsebuf(char *longbuf, int reply)
+static void parsebuf(unsigned char *longbuf, int reply)
 {
-    char       *cp;
+    unsigned char      *cp;
 
     if (reply)
     {
@@ -358,19 +358,19 @@ static void parsebuf(char *longbuf, int reply)
        printf("Rewritten buffer: %s", longbuf);
     }
     else
-       if ((cp = nxtaddr(longbuf)) != (char *)NULL)
+       if ((cp = nxtaddr(longbuf)) != (unsigned char *)NULL)
            do {
                printf("\t-> \"%s\"\n", cp);
            } while
-               ((cp = nxtaddr((char *)NULL)) != (char *)NULL);
+               ((cp = nxtaddr((unsigned char *)NULL)) != (unsigned char *)NULL);
 }
 
 
 
 main(int argc, char *argv[])
 {
-    char       buf[MSGBUFSIZE], longbuf[BUFSIZ];
-    int                ch, reply;
+    unsigned char      buf[MSGBUFSIZE], longbuf[BUFSIZ];
+    int                        ch, reply;
     
     verbose = reply = FALSE;
     while ((ch = getopt(argc, argv, "rv")) != EOF)
index 8c367d0c1182c90e399866e8d35cd8c4b88a84f7..f5d98e9a3f9fffba902e6c57fe0761bb91ba9271 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -698,7 +698,6 @@ int SSLOpen(int sock, char *mycert, char *mykey, char *servercname )
 int SockClose(int sock)
 /* close a socket gracefully */
 {
-    char ch;
 #ifdef SSL_ENABLE
     SSL *ssl;
 
@@ -721,6 +720,7 @@ int SockClose(int sock)
      * This stops sends but allows receives (effectively, it sends a
      * TCP <FIN>).  */
     if (shutdown(sock, 1) == 0) {
+       char ch;
        /* If there is any data still waiting in the queue, discard it.
         * Call recv() until either it returns 0 (meaning we received a FIN)
         * or any error occurs.  This makes sure all data sent by the other