]> diplodocus.org Git - nmh/blobdiff - mts/smtp/smtp.c
Moved free(cp) to right after last (and only) use of cp. The statement
[nmh] / mts / smtp / smtp.c
index 65de0a7fe5364ae323f5e8f59e6739ec34ad9855..8b89dec3e7fb00bf8845eda7b58f78bce43ab4a2 100644 (file)
@@ -96,7 +96,7 @@ static FILE *sm_wfp = NULL;
  */
 
 static sasl_conn_t *conn = NULL;       /* SASL connection state */
  */
 
 static sasl_conn_t *conn = NULL;       /* SASL connection state */
-static int sasl_complete = 0;          /* Has authentication succeded? */
+static int sasl_complete = 0;          /* Has authentication succeeded? */
 static sasl_ssf_t sasl_ssf;            /* Our security strength factor */
 static int maxoutbuf;                  /* Maximum crypto output buffer */
 static char *sasl_outbuffer;           /* SASL output buffer for encryption */
 static sasl_ssf_t sasl_ssf;            /* Our security strength factor */
 static int maxoutbuf;                  /* Maximum crypto output buffer */
 static char *sasl_outbuffer;           /* SASL output buffer for encryption */
@@ -1223,7 +1223,7 @@ sm_wstream (char *buffer, int len)
        return (ferror (sm_wfp) ? sm_werror () : OK);
     }
 
        return (ferror (sm_wfp) ? sm_werror () : OK);
     }
 
-    for (bp = buffer; len > 0; bp++, len--) {
+    for (bp = buffer; bp && len > 0; bp++, len--) {
        switch (*bp) {
            case '\n': 
                sm_nl = TRUE;
        switch (*bp) {
            case '\n': 
                sm_nl = TRUE;
@@ -1272,7 +1272,9 @@ sm_fwrite(char *buffer, int len)
            }
        } else
 #endif /* TLS_SUPPORT */
            }
        } else
 #endif /* TLS_SUPPORT */
-       fwrite(buffer, sizeof(*buffer), len, sm_wfp);
+       if ((int) fwrite(buffer, sizeof(*buffer), len, sm_wfp) < len) {
+           advise ("sm_fwrite", "fwrite");
+       }
 #ifdef CYRUS_SASL
     } else {
        while (len >= maxoutbuf - sasl_outbuflen) {
 #ifdef CYRUS_SASL
     } else {
        while (len >= maxoutbuf - sasl_outbuflen) {
@@ -1288,7 +1290,10 @@ sm_fwrite(char *buffer, int len)
                return NOTOK;
            }
 
                return NOTOK;
            }
 
-           fwrite(output, sizeof(*output), outputlen, sm_wfp);
+           if (fwrite(output, sizeof(*output), outputlen, sm_wfp) <
+               outputlen) {
+               advise ("sm_fwrite", "fwrite");
+           }
        }
 
        if (len > 0) {
        }
 
        if (len > 0) {
@@ -1397,7 +1402,7 @@ tls_negotiate(void)
 #endif /* TLS_SUPPORT */
 
 /*
 #endif /* TLS_SUPPORT */
 
 /*
- * Convenience functions to replace occurences of fputs() and fputc()
+ * Convenience functions to replace occurrences of fputs() and fputc()
  */
 
 static int
  */
 
 static int
@@ -1435,7 +1440,9 @@ sm_fflush(void)
            return;
        }
 
            return;
        }
 
-       fwrite(output, sizeof(*output), outputlen, sm_wfp);
+       if (fwrite(output, sizeof(*output), outputlen, sm_wfp) < outputlen) {
+           advise ("sm_fflush", "fwrite");
+       }
        sasl_outbuflen = 0;
     }
 #endif /* CYRUS_SASL */
        sasl_outbuflen = 0;
     }
 #endif /* CYRUS_SASL */
@@ -1467,7 +1474,7 @@ smhear (void)
     int i, code, cont, bc = 0, rc, more;
     unsigned char *bp;
     char *rp;
     int i, code, cont, bc = 0, rc, more;
     unsigned char *bp;
     char *rp;
-    char **ehlo = NULL, buffer[BUFSIZ];
+    char **ehlo = EHLOkeys, buffer[BUFSIZ];
 
     if (doingEHLO) {
        static int at_least_once = 0;
 
     if (doingEHLO) {
        static int at_least_once = 0;