Re: cvs: php4(PHP_4_0_7) /main SAPI.c
| From: | Zeev Suraski | Date: | Sun, 21 Oct 2001 01:23:16 +0000 |
| Subject: | Re: cvs: php4(PHP_4_0_7) /main SAPI.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-7885@lists.php.net to get a copy of this message | ||
Are you sure this is rock solid? It looks like plenty of room for nice crashes in the release :I
At 02:16 21-10-01, Rasmus Lerdorf wrote:
rasmus Sat Oct 20 20:16:58 2001 EDTModified files: (Branch: PHP_4_0_7) /php4/main SAPI.cLog: MFH Index: php4/main/SAPI.c diff -u php4/main/SAPI.c:1.113 php4/main/SAPI.c:1.113.2.1--- php4/main/SAPI.c:1.113 Sun Aug 5 11:29:39 2001 +++ php4/main/SAPI.c Sat Oct 20 20:16:52 2001@@ -23,6 +23,9 @@ #include "php.h" #include "SAPI.h" +#include "ext/standard/php_string.h" +#include "ext/standard/pageinfo.h" +#include "ext/pcre/php_pcre.h" #ifdef ZTS #include "TSRM.h" #endif @@ -371,6 +374,8 @@int retval, free_header = 0; sapi_header_struct sapi_header; char *colon_offset; + int result_len = 0; + long myuid = 0L;if (SG(headers_sent) && !SG(request_info).no_headers) { char *output_start_filename = php_get_output_start_filename(TSRMLS_C);@@ -440,7 +445,59 @@ SG(sapi_headers).http_response_code = 302;} } else if (!STRCASECMP(header_line, "WWW-Authenticate")) { /* HTTP Authentication */ + zval *repl_temp; + char *result, *newheader, *ptr = colon_offset+1; + int newlen, ptr_len=0;+SG(sapi_headers).http_response_code = 401; /* authentication-required */ + if(PG(safe_mode)) { + myuid = php_getuid();++ ptr_len = strlen(ptr); + MAKE_STD_ZVAL(repl_temp); + Z_STRVAL_P(repl_temp) = emalloc(32); + Z_STRLEN_P(repl_temp) = sprintf(Z_STRVAL_P(repl_temp), "realm=\"\\1-%ld\"", myuid); + /* Modify quoted realm value */ + result = php_pcre_replace("/realm=\"(.*?)\"/i", 16, + ptr, ptr_len, + repl_temp, + 0, &result_len, -1 TSRMLS_CC); + if(result_len==ptr_len) { + efree(result); + sprintf(Z_STRVAL_P(repl_temp), "realm=\\1-%ld\\2", myuid); + /* modify unquoted realm value */ + result = php_pcre_replace("/realm=([^\\s]+)(.*)/i", 21, + ptr, ptr_len, + repl_temp, + 0, &result_len, -1 TSRMLS_CC); + if(result_len==ptr_len) { + char *lower_temp = estrdup(ptr); + char conv_temp[32]; + int conv_len;+ + php_strtolower(lower_temp,strlen(lower_temp));+ /* If there is no realm string at all, append one */ + if(!strstr(lower_temp,"realm")) { + efree(result); + conv_len = sprintf(conv_temp," realm=\"%ld\"",myuid); + result = emalloc(ptr_len+conv_len+1); + memcpy(result, ptr, ptr_len); + memcpy(result+ptr_len, conv_temp, conv_len); + *(result+ptr_len+conv_len) = '\0'; + } + efree(lower_temp); + } + } + newlen = sizeof("WWW-Authenticate: ") + result_len; + newheader = emalloc(newlen+1); + sprintf(newheader,"WWW-Authenticate: %s", result); + efree(header_line); + sapi_header.header = newheader; + sapi_header.header_len = newlen; + efree(result); + efree(Z_STRVAL_P(repl_temp)); + efree(repl_temp); + } } *colon_offset = ':'; }-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-cvs-unsubscribe@lists.php.net For additional commands, e-mail: php-cvs-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net