]> diplodocus.org Git - nmh/blobdiff - sbr/m_getfld.c
Revert "Default to enabling (Cyrus) SASL, if available."
[nmh] / sbr / m_getfld.c
index f19f7f11c632bdcf60b45d6b88f7a82ece92aaa8..63b3fda21fd87713a60f4c2a34ff331e329d8923 100644 (file)
@@ -630,18 +630,21 @@ m_getfld (m_getfld_state_t *gstate, char name[NAMESZ], char *buf, int *bufsz,
            n = 0;
            for (finished = 0; ! finished; ) {
                while (c != '\n'  &&  c != EOF  &&  n++ < max) {
-                   *cp++ = c = Getc (s);
+                   if ((c = Getc (s)) != EOF) { *cp++ = c; }
                }
 
                if (c != EOF) c = Peek (s);
                if (max < n) {
                    /* The dest buffer is full.  Need to back the read
-                       pointer up by one because when m_getfld() is
-                       reentered, it will read a character.  Then
-                       we'll jump right to the FLDPLUS handling code,
-                       which will not store that character, but
-                       instead move on to the next one. */
-                    if (s->readpos > s->msg_buf) --s->readpos;
+                      pointer up by one because when m_getfld() is
+                      reentered, it will read a character.  Then
+                      we'll jump right to the FLDPLUS handling code,
+                      which will not store that character, but
+                      instead move on to the next one. */
+                   if (s->readpos > s->msg_buf) {
+                       --s->readpos;
+                       --s->bytes_read;
+                   }
                    s->state = FLDPLUS;
                    finished = 1;
                } else if (c != ' '  &&  c != '\t') {
@@ -796,7 +799,7 @@ m_unknown(m_getfld_state_t *gstate, FILE *iob)
     s->msg_style = MS_UNKNOWN;
 
     for (i = 0, cp = text; i < sizeof text; ++i, ++cp) {
-       if ((*cp = Getc (s)) == EOF) {
+       if ((signed char) (*cp = Getc (s)) == EOF) {
            break;
        }
     }
@@ -876,7 +879,7 @@ m_Eom (m_getfld_state_t s, int c)
     char *cp;
 
     for (i = 0, cp = text; i < s->edelimlen; ++i, ++cp) {
-       if ((*cp = Getc (s)) == EOF) {
+       if ((signed char) (*cp = Getc (s)) == EOF) {
            break;
        }
     }