@@ -112,7 +112,7 @@ static const char *ErrorMessages[] =
112112#define PHP_WIN32_MAIL_DOT_REPLACE "\n.."
113113
114114static int SendText (char * RPath , const char * Subject , const char * mailTo , const char * data ,
115- const char * headers , char * headers_lc , char * * error_message );
115+ const zend_string * headers , zend_string * headers_lc , char * * error_message );
116116static int MailConnect ();
117117static int PostHeader (char * RPath , const char * Subject , const char * mailTo , char * xheaders );
118118static bool Post (LPCSTR msg );
@@ -278,7 +278,7 @@ PHPAPI int TSendMail(const char *host, int *error, char **error_message,
278278 PW32G (mail_host ), !INI_INT ("smtp_port" ) ? 25 : INI_INT ("smtp_port" ));
279279 return FAILURE ;
280280 } else {
281- ret = SendText (RPath , Subject , mailTo , data , headers ? ZSTR_VAL ( headers_trim ) : NULL , headers ? ZSTR_VAL ( headers_lc ) : NULL , error_message );
281+ ret = SendText (RPath , Subject , mailTo , data , headers_trim , headers_lc , error_message );
282282 TSMClose ();
283283 if (RPath ) {
284284 efree (RPath );
@@ -387,7 +387,7 @@ static char *find_address(char *list, char **state)
387387// History:
388388//*********************************************************************
389389static int SendText (char * RPath , const char * Subject , const char * mailTo , const char * data ,
390- const char * headers , char * headers_lc , char * * error_message )
390+ const zend_string * headers , zend_string * headers_lc , char * * error_message )
391391{
392392 int res ;
393393 char * p ;
@@ -464,11 +464,11 @@ static int SendText(char *RPath, const char *Subject, const char *mailTo, const
464464 efree (tempMailTo );
465465
466466 /* Send mail to all Cc rcpt's */
467- if (headers && (pos1 = strstr (headers_lc , "cc:" )) && ((pos1 == headers_lc ) || (* (pos1 - 1 ) == '\n' ))) {
467+ if (headers && (pos1 = strstr (ZSTR_VAL ( headers_lc ) , "cc:" )) && ((pos1 == ZSTR_VAL ( headers_lc ) ) || (* (pos1 - 1 ) == '\n' ))) {
468468 /* Real offset is memaddress from the original headers + difference of
469469 * string found in the lowercase headers + 3 characters to jump over
470470 * the cc: */
471- pos1 = headers + (pos1 - headers_lc ) + 3 ;
471+ pos1 = ZSTR_VAL ( headers ) + (pos1 - ZSTR_VAL ( headers_lc ) ) + 3 ;
472472 if (NULL == (pos2 = strstr (pos1 , "\r\n" ))) {
473473 tempMailTo = estrndup (pos1 , strlen (pos1 ));
474474 } else {
@@ -508,11 +508,11 @@ static int SendText(char *RPath, const char *Subject, const char *mailTo, const
508508 This is basically a rip of the Cc code above.
509509 Just don't forget to remove the Bcc: from the header afterwards. */
510510 if (headers ) {
511- if ((pos1 = strstr (headers_lc , "bcc:" )) && (pos1 == headers_lc || * (pos1 - 1 ) == '\n' )) {
511+ if ((pos1 = strstr (ZSTR_VAL ( headers_lc ) , "bcc:" )) && (pos1 == ZSTR_VAL ( headers_lc ) || * (pos1 - 1 ) == '\n' )) {
512512 /* Real offset is memaddress from the original headers + difference of
513513 * string found in the lowercase headers + 4 characters to jump over
514514 * the bcc: */
515- pos1 = headers + (pos1 - headers_lc ) + 4 ;
515+ pos1 = ZSTR_VAL ( headers ) + (pos1 - ZSTR_VAL ( headers_lc ) ) + 4 ;
516516 if (NULL == (pos2 = strstr (pos1 , "\r\n" ))) {
517517 tempMailTo = estrndup (pos1 , strlen (pos1 ));
518518 /* Later, when we remove the Bcc: out of the
@@ -557,27 +557,27 @@ static int SendText(char *RPath, const char *Subject, const char *mailTo, const
557557
558558 /* Now that we've identified that we've a Bcc list,
559559 remove it from the current header. */
560- stripped_header = ecalloc (1 , strlen (headers ));
560+ stripped_header = ecalloc (1 , ZSTR_LEN (headers ));
561561 /* headers = point to string start of header
562562 pos1 = pointer IN headers where the Bcc starts
563563 '4' = Length of the characters 'bcc:'
564564 Because we've added +4 above for parsing the Emails
565565 we've to subtract them here. */
566- memcpy (stripped_header , headers , pos1 - headers - 4 );
566+ memcpy (stripped_header , ZSTR_VAL ( headers ) , pos1 - ZSTR_VAL ( headers ) - 4 );
567567 if (pos1 != pos2 ) {
568568 /* if pos1 != pos2 , pos2 points to the rest of the headers.
569569 Since pos1 != pos2 if "\r\n" was found, we know those characters
570570 are there and so we jump over them (else we would generate a new header
571571 which would look like "\r\n\r\n". */
572- memcpy (stripped_header + (pos1 - headers - 4 ), pos2 + 2 , strlen (pos2 ) - 2 );
572+ memcpy (stripped_header + (pos1 - ZSTR_VAL ( headers ) - 4 ), pos2 + 2 , strlen (pos2 ) - 2 );
573573 }
574574 }
575575 }
576576
577577 /* Simplify the code that we create a copy of stripped_header no matter if
578578 we actually strip something or not. So we've a single efree() later. */
579579 if (headers && !stripped_header ) {
580- stripped_header = estrndup (headers , strlen (headers ));
580+ stripped_header = estrndup (ZSTR_VAL ( headers ), ZSTR_LEN (headers ));
581581 }
582582
583583 if (!Post ("DATA\r\n" )) {
0 commit comments