]> git.pld-linux.org Git - packages/php.git/blob - php-mailsecurity2.patch
- release 12: rebuild against ucd-snmp 4.2.3.
[packages/php.git] / php-mailsecurity2.patch
1 Index: php4/ext/standard/mail.c
2 ===================================================================
3 RCS file: /repository/php4/ext/standard/mail.c,v
4 retrieving revision 1.33
5 retrieving revision 1.44
6 diff -u -r1.33 -r1.44
7 --- php4/ext/standard/mail.c    2 Apr 2001 16:37:50 -0000       1.33
8 +++ php4/ext/standard/mail.c    25 Sep 2001 22:48:43 -0000      1.44
9 @@ -12,11 +12,11 @@
10     | obtain it through the world-wide-web, please send a note to          |
11     | license@php.net so we can mail you a copy immediately.               |
12     +----------------------------------------------------------------------+
13 -   | Authors:                                                             |
14 +   | Authors: Rasmus Lerdorf <rasmus@php.net>                             |
15     +----------------------------------------------------------------------+
16   */
17  
18 -/* $Id$ */
19 +/* $Id$ */
20  
21  #include <stdlib.h>
22  #include <ctype.h>
23 @@ -34,6 +34,8 @@
24  #endif
25  #include "php_mail.h"
26  #include "php_ini.h"
27 +#include "safe_mode.h"
28 +#include "exec.h"
29  
30  #if HAVE_SENDMAIL
31  #ifdef PHP_WIN32
32 @@ -54,8 +56,8 @@
33         }
34  
35         convert_to_string_ex(pstr);
36 -       if ((*pstr)->value.str.val) {
37 -               str = (*pstr)->value.str.val;
38 +       if (Z_STRVAL_PP(pstr)) {
39 +               str = Z_STRVAL_PP(pstr);
40         } else {
41                 php_error(E_WARNING, "Must give string parameter to ezmlm_hash()");
42                 RETURN_FALSE;
43 @@ -70,6 +72,7 @@
44         
45         RETURN_LONG((int) h);
46  }
47 +/* }}} */
48  
49  /* {{{ proto int mail(string to, string subject, string message [, string additional_headers [, string additional_parameters]])
50     Send an email message */
51 @@ -85,8 +88,8 @@
52         }
53         /* To: */
54         convert_to_string_ex(argv[0]);
55 -       if ((*argv[0])->value.str.val) {
56 -               to = (*argv[0])->value.str.val;
57 +       if (Z_STRVAL_PP(argv[0])) {
58 +               to = Z_STRVAL_PP(argv[0]);
59         } else {
60                 php_error(E_WARNING, "No to field in mail command");
61                 RETURN_FALSE;
62 @@ -94,8 +97,8 @@
63  
64         /* Subject: */
65         convert_to_string_ex(argv[1]);
66 -       if ((*argv[1])->value.str.val) {
67 -               subject = (*argv[1])->value.str.val;
68 +       if (Z_STRVAL_PP(argv[1])) {
69 +               subject = Z_STRVAL_PP(argv[1]);
70         } else {
71                 php_error(E_WARNING, "No subject field in mail command");
72                 RETURN_FALSE;
73 @@ -103,8 +106,8 @@
74  
75         /* message body */
76         convert_to_string_ex(argv[2]);
77 -       if ((*argv[2])->value.str.val) {
78 -               message = (*argv[2])->value.str.val;
79 +       if (Z_STRVAL_PP(argv[2])) {
80 +               message = Z_STRVAL_PP(argv[2]);
81         } else {
82                 /* this is not really an error, so it is allowed. */
83                 php_error(E_WARNING, "No message string in mail command");
84 @@ -113,41 +116,46 @@
85  
86         if (argc >= 4) {                        /* other headers */
87                 convert_to_string_ex(argv[3]);
88 -               headers = (*argv[3])->value.str.val;
89 +               headers = Z_STRVAL_PP(argv[3]);
90         }
91         
92         if (argc == 5) {                        /* extra options that get passed to the mailer */
93                 convert_to_string_ex(argv[4]);
94 -               extra_cmd = (*argv[4])->value.str.val;
95 +               extra_cmd = php_escape_shell_arg(Z_STRVAL_PP(argv[4]));
96         }
97         
98         if (php_mail(to, subject, message, headers, extra_cmd)) {
99 -               RETURN_TRUE;
100 +               RETVAL_TRUE;
101         } else {
102 -               RETURN_FALSE;
103 +               RETVAL_FALSE;
104         }
105 +       if (extra_cmd) efree (extra_cmd);
106  }
107  /* }}} */
108  
109 -int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd)
110 +/* {{{ php_mail
111 + */
112 +PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd)
113  {
114  #ifdef PHP_WIN32
115         int tsm_err;
116 -#else
117 +#endif
118         FILE *sendmail;
119         int ret;
120         char *sendmail_path = INI_STR("sendmail_path");
121         char *sendmail_cmd = NULL;
122 -#endif
123  
124 +       if (!sendmail_path) {
125  #ifdef PHP_WIN32
126 -       if (TSendMail(INI_STR("SMTP"), &tsm_err, headers, subject, to, message) != SUCCESS){
127 -               php_error(E_WARNING, GetSMErrorText(tsm_err));
128 -               return 0;
129 -       }
130 +               /* handle old style win smtp sending */
131 +               if (TSendMail(INI_STR("SMTP"), &tsm_err, headers, subject, to, message) != SUCCESS){
132 +                       php_error(E_WARNING, GetSMErrorText(tsm_err));
133 +                       return 0;
134 +               }
135 +               return 1;
136  #else
137 -       if (!sendmail_path) {
138                 return 0;
139 +#endif
140         }
141         if (extra_cmd != NULL) {
142                 sendmail_cmd = emalloc (strlen (sendmail_path) + strlen (extra_cmd) + 2);
143 @@ -158,7 +166,11 @@
144                 sendmail_cmd = sendmail_path;
145         }
146  
147 +#ifdef PHP_WIN32
148 +       sendmail = popen(sendmail_cmd, "wb");
149 +#else
150         sendmail = popen(sendmail_cmd, "w");
151 +#endif
152         if (extra_cmd != NULL)
153                 efree (sendmail_cmd);
154  
155 @@ -170,11 +182,16 @@
156                 }
157                 fprintf(sendmail, "\n%s\n", message);
158                 ret = pclose(sendmail);
159 +#ifdef PHP_WIN32
160 +               if (ret == -1)
161 +#else
162  #if defined(EX_TEMPFAIL)
163 -               if ((ret != EX_OK)&&(ret != EX_TEMPFAIL)) {
164 +               if ((ret != EX_OK)&&(ret != EX_TEMPFAIL)) 
165  #else
166 -               if (ret != EX_OK) {
167 +               if (ret != EX_OK) 
168 +#endif
169  #endif
170 +               {
171                         return 0;
172                 } else {
173                         return 1;
174 @@ -183,18 +200,27 @@
175                 php_error(E_WARNING, "Could not execute mail delivery program");
176                 return 0;
177         }
178 -#endif
179         return 1;
180  }
181 +/* }}} */
182  
183 +/* {{{ PHP_MINFO_FUNCTION
184 + */
185  PHP_MINFO_FUNCTION(mail)
186  {
187 +       char *sendmail_path = INI_STR("sendmail_path");
188 +
189  #ifdef PHP_WIN32
190 -        php_info_print_table_row(2, "Internal Sendmail Support for Windows 4", "enabled");
191 +       if (!sendmail_path) {
192 +        php_info_print_table_row(2, "Internal Sendmail Support for Windows", "enabled");
193 +       } else {
194 +        php_info_print_table_row(2, "Path to sendmail", sendmail_path);
195 +       }
196  #else
197 -        php_info_print_table_row(2, "Path to sendmail", INI_STR("sendmail_path") );
198 +    php_info_print_table_row(2, "Path to sendmail", sendmail_path);
199  #endif
200  }
201 +/* }}} */
202  
203  #else
204  
205 @@ -203,9 +229,11 @@
206  
207  #endif
208  
209 -
210  /*
211   * Local variables:
212   * tab-width: 4
213 + * c-basic-offset: 4
214   * End:
215 + * vim600: sw=4 ts=4 fdm=marker
216 + * vim<600: sw=4 ts=4
217   */
This page took 0.042224 seconds and 3 git commands to generate.