comparison 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
comparison
equal deleted inserted replaced
774:62f9b36df5a5 775:d0bf2135ab34
34 char *checkwait_smtpreply(int sockfd, int replytype) 34 char *checkwait_smtpreply(int sockfd, int replytype)
35 { 35 {
36 char *smtpreply; 36 char *smtpreply;
37 37
38 smtpreply = mygetline(sockfd); 38 smtpreply = mygetline(sockfd);
39 if(smtpreply == NULL) {
40 /* This will never be a valid SMTP response so will always be returned,
41 * but is more descriptive than an empty string. */
42 smtpreply = mystrdup("none / error / closed connection");
43 }
44
39 #if 0 45 #if 0
40 printf("replytype = [%d], smtpreply = [%s]\n", replytype, smtpreply); 46 printf("replytype = [%d], smtpreply = [%s]\n", replytype, smtpreply);
41 fprintf(stderr, "%s", smtpreply); 47 fprintf(stderr, "%s", smtpreply);
42 #endif 48 #endif
43 49