diff src/checkwait_smtpreply.c @ 775:d0bf2135ab34

Check the server gives a reply before reading it to avoid segfaulting
author Ben Schmidt
date Fri, 12 Nov 2010 02:27:50 +1100
parents a38cde48669f
children 04d916168efb
line wrap: on
line diff
--- a/src/checkwait_smtpreply.c	Fri Nov 12 02:26:49 2010 +1100
+++ b/src/checkwait_smtpreply.c	Fri Nov 12 02:27:50 2010 +1100
@@ -36,6 +36,12 @@
 	char *smtpreply;
 
 	smtpreply = mygetline(sockfd);
+	if(smtpreply == NULL) {
+		/* This will never be a valid SMTP response so will always be returned,
+		 * but is more descriptive than an empty string. */
+		smtpreply = mystrdup("none / error / closed connection");
+	}
+
 #if 0
 	printf("replytype = [%d], smtpreply = [%s]\n", replytype, smtpreply);
 	fprintf(stderr, "%s", smtpreply);