cvs: php4(PHP_4_2_0) /win32 sendmail.c sendmail.h

From: Date: Tue, 14 May 2002 14:17:05 +0000
Subject: cvs: php4(PHP_4_2_0) /win32 sendmail.c sendmail.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-11913@lists.php.net to get a copy of this message
mfischer Tue May 14 10:17:05 2002 EDT Modified files: (Branch: PHP_4_2_0) /php4/win32 sendmail.c sendmail.h Log: - MFH fix for Cc: crash Index: php4/win32/sendmail.c diff -u php4/win32/sendmail.c:1.24 php4/win32/sendmail.c:1.24.2.1 --- php4/win32/sendmail.c:1.24 Thu Dec 20 13:06:13 2001 +++ php4/win32/sendmail.c Tue May 14 10:17:04 2002 @@ -18,7 +18,7 @@ * */ -/* $Id: sendmail.c,v 1.24 2001/12/20 18:06:13 fmk Exp $ */ +/* $Id: sendmail.c,v 1.24.2.1 2002/05/14 14:17:04 mfischer Exp $ */ #include "php.h" /*php specific */ #include <stdio.h> @@ -69,26 +69,27 @@ /* Error messages */ static char *ErrorMessages[] = { - {"Success"}, - {"Bad arguments from form"}, + {"Success"}, /* 0 */ + {"Bad arguments from form"}, /* 1 */ {"Unable to open temporary mailfile for read"}, {"Failed to Start Sockets"}, {"Failed to Resolve Host"}, - {"Failed to obtain socket handle"}, - {"Failed to Connect"}, + {"Failed to obtain socket handle"}, /* 5 */ + {"Failed to connect to mailserver, verify your \"SMTP\" setting in php.ini"}, {"Failed to Send"}, {"Failed to Receive"}, {"Server Error"}, - {"Failed to resolve the host IP name"}, + {"Failed to resolve the host IP name"}, /* 10 */ {"Out of memory"}, {"Unknown error"}, {"Bad Message Contents"}, {"Bad Message Subject"}, - {"Bad Message destination"}, + {"Bad Message destination"}, /* 15 */ {"Bad Message Return Path"}, {"Bad Mail Host"}, {"Bad Message File"}, - {"PHP Internal error: php.ini sendmail from variable not set!"} + {"\"sendmail_from\" NOT set in php.ini"}, + {"Mailserver rejected our \"sendmail_from\" setting"} /* 20 */ }; @@ -126,8 +127,9 @@ if (INI_STR("sendmail_from")){ RPath = estrdup(INI_STR("sendmail_from")); - } else { - return 19; + } else { + *error = W32_SM_SENDMAIL_FROM_NOT_SET; + return FAILURE; } /* attempt to connect with mail host */ @@ -178,11 +180,12 @@ //*******************************************************************/ char *GetSMErrorText(int index) { - - if ((index > MAX_ERROR_INDEX) || (index < MIN_ERROR_INDEX)) - return (ErrorMessages[UNKNOWN_ERROR]); - else - return (ErrorMessages[index]); + + if (MIN_ERROR_INDEX <= index && index < MAX_ERROR_INDEX) { + return (ErrorMessages[index]); + } else { + return (ErrorMessages[UNKNOWN_ERROR]); + } } @@ -235,7 +238,7 @@ if ((res = Post(Buffer)) != SUCCESS) return (res); if ((res = Ack()) != SUCCESS) - return (res); + return W32_SM_SENDMAIL_FROM_MALFORMED; tempMailTo = estrdup(mailTo); @@ -255,8 +258,11 @@ /* Send mail to all Cc rcpt's */ efree(tempMailTo); if (headers && (pos1 = strstr(headers, "Cc:"))) { - pos2 = strstr(pos1, "\r\n"); - tempMailTo = estrndup(pos1, pos2-pos1); + if (NULL == (pos2 = strstr(pos1, "\r\n"))) { + tempMailTo = estrndup(pos1, strlen(pos1)); + } else { + tempMailTo = estrndup(pos1, pos2-pos1); + } token = strtok(tempMailTo, ","); while(token != NULL) Index: php4/win32/sendmail.h diff -u php4/win32/sendmail.h:1.3 php4/win32/sendmail.h:1.3.2.1 --- php4/win32/sendmail.h:1.3 Tue Dec 4 13:47:07 2001 +++ php4/win32/sendmail.h Tue May 14 10:17:04 2002 @@ -4,29 +4,31 @@ #define HOST_NAME_LEN 256 #define MAX_APPNAME_LENGHT 100 -#define MAX_ERROR_INDEX 17 -#define MIN_ERROR_INDEX 0 -#define MAIL_BUFFER_SIZE (1024*4) /* 4k buffer */ +#define MAIL_BUFFER_SIZE (1024*4) /* 4k buffer */ /* Return values */ -#define SUCCESS 0 -#define FAILED_TO_PARSE_ARGUMENTS 1 -#define FAILED_TO_OPEN_MAILFILE 2 -#define FAILED_TO_START_SOCKETS 3 -#define FAILED_TO_RESOLVE_HOST 4 -#define FAILED_TO_OBTAIN_SOCKET_HANDLE 5 -#define FAILED_TO_CONNECT 6 -#define FAILED_TO_SEND 7 -#define FAILED_TO_RECEIVE 8 -#define SMTP_SERVER_ERROR 9 -#define FAILED_TO_GET_HOSTNAME 10 -#define OUT_OF_MEMORY 11 -#define UNKNOWN_ERROR 12 -#define BAD_MSG_CONTENTS 13 -#define BAD_MSG_SUBJECT 14 -#define BAD_MSG_DESTINATION 15 -#define BAD_MSG_RPATH 16 -#define BAD_MAIL_HOST 17 -#define BAD_MSG_FILE 18 +#define MIN_ERROR_INDEX 0 /* Always 0 like SUCCESS */ +#define SUCCESS 0 +#define FAILED_TO_PARSE_ARGUMENTS 1 +#define FAILED_TO_OPEN_MAILFILE 2 +#define FAILED_TO_START_SOCKETS 3 +#define FAILED_TO_RESOLVE_HOST 4 +#define FAILED_TO_OBTAIN_SOCKET_HANDLE 5 +#define FAILED_TO_CONNECT 6 +#define FAILED_TO_SEND 7 +#define FAILED_TO_RECEIVE 8 +#define SMTP_SERVER_ERROR 9 +#define FAILED_TO_GET_HOSTNAME 10 +#define OUT_OF_MEMORY 11 +#define UNKNOWN_ERROR 12 +#define BAD_MSG_CONTENTS 13 +#define BAD_MSG_SUBJECT 14 +#define BAD_MSG_DESTINATION 15 +#define BAD_MSG_RPATH 16 +#define BAD_MAIL_HOST 17 +#define BAD_MSG_FILE 18 +#define W32_SM_SENDMAIL_FROM_NOT_SET 19 +#define W32_SM_SENDMAIL_FROM_MALFORMED 20 +#define MAX_ERROR_INDEX 21 /* Always last error message + 1 */ int TSendMail(char *smtpaddr, int *returnerror,

« previous php.cvs (#11913) next »