thetaphi Tue Mar 6 18:15:05 2007 UTC
Modified files:
/php-src/sapi/nsapi nsapi.c
Log:
remove (large) static buffers for header names and request uri
http://cvs.php.net/viewvc.cgi/php-src/sapi/nsapi/nsapi.c?r1=1.80&r2=1.81&diff_format=u
Index: php-src/sapi/nsapi/nsapi.c
diff -u php-src/sapi/nsapi/nsapi.c:1.80 php-src/sapi/nsapi/nsapi.c:1.81
--- php-src/sapi/nsapi/nsapi.c:1.80 Tue Mar 6 16:19:36 2007
+++ php-src/sapi/nsapi/nsapi.c Tue Mar 6 18:15:04 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: nsapi.c,v 1.80 2007/03/06 16:19:36 thetaphi Exp $ */
+/* $Id: nsapi.c,v 1.81 2007/03/06 18:15:04 thetaphi Exp $ */
/*
* PHP includes
@@ -308,7 +308,7 @@
PHP_MINFO_FUNCTION(nsapi)
{
php_info_print_table_start();
- php_info_print_table_row(2, "NSAPI Module Revision", "$Revision: 1.80
$");
+ php_info_print_table_row(2, "NSAPI Module Revision", "$Revision: 1.81
$");
php_info_print_table_row(2, "Server Software", system_version());
php_info_print_table_row(2, "Sub-requests with nsapi_virtual()",
(nsapi_servact_service)?((zend_ini_long("zlib.output_compression",
sizeof("zlib.output_compression"), 0))?"not supported with
zlib.output_compression":"enabled"):"not supported on this platform" );
@@ -585,7 +585,7 @@
register size_t i;
int pos;
char *value,*p;
- char buf[2048];
+ char buf[32];
struct pb_entry *entry;
for (i = 0; i < nsapi_reqpb_size; i++) {
@@ -599,19 +599,22 @@
entry=rc->rq->headers->ht[i];
while (entry) {
if (strcasecmp(entry->param->name, "content-length")==0
|| strcasecmp(entry->param->name, "content-type")==0) {
- strlcpy(buf, entry->param->name, sizeof(buf));
+ value=estrdup(entry->param->name);
pos = 0;
} else {
- slprintf(buf, sizeof(buf), "HTTP_%s",
entry->param->name);
+ spprintf(&value, 0, "HTTP_%s",
entry->param->name);
pos = 5;
}
- for(p = buf + pos; *p; p++) {
- *p = toupper(*p);
- if (*p < 'A' || *p > 'Z') {
- *p = '_';
+ if (value) {
+ for(p = value + pos; *p; p++) {
+ *p = toupper(*p);
+ if (*p < 'A' || *p > 'Z') {
+ *p = '_';
+ }
}
+ php_register_variable(value,
entry->param->value, track_vars_array TSRMLS_CC);
+ efree(value);
}
- php_register_variable(buf, entry->param->value,
track_vars_array TSRMLS_CC);
entry=entry->next;
}
}
@@ -666,22 +669,27 @@
/* Create full Request-URI & Script-Name */
if (SG(request_info).request_uri) {
if (SG(request_info).query_string) {
- slprintf(buf, sizeof(buf), "%s?%s",
SG(request_info).request_uri, SG(request_info).query_string);
+ spprintf(&value, 0, "%s?%s",
SG(request_info).request_uri, SG(request_info).query_string);
+ if (value) {
+ php_register_variable("REQUEST_URI", value,
track_vars_array TSRMLS_CC);
+ efree(value);
+ }
} else {
- strlcpy(buf, SG(request_info).request_uri, sizeof(buf));
+ php_register_variable("REQUEST_URI",
SG(request_info).request_uri, track_vars_array TSRMLS_CC);
}
- php_register_variable("REQUEST_URI", buf, track_vars_array
TSRMLS_CC);
- strlcpy(buf, SG(request_info).request_uri, sizeof(buf));
- if (rc->path_info) {
- pos = strlen(SG(request_info).request_uri) -
strlen(rc->path_info);
- if (pos>=0 && pos<sizeof(buf)) {
- buf[pos] = '\0';
- } else {
- buf[0]='\0';
+ if (value = nsapi_strdup(SG(request_info).request_uri)) {
+ if (rc->path_info) {
+ pos = strlen(SG(request_info).request_uri) -
strlen(rc->path_info);
+ if (pos>=0) {
+ value[pos] = '\0';
+ } else {
+ value[0]='\0';
+ }
}
+ php_register_variable("SCRIPT_NAME", value,
track_vars_array TSRMLS_CC);
+ nsapi_free(value);
}
- php_register_variable("SCRIPT_NAME", buf, track_vars_array
TSRMLS_CC);
}
php_register_variable("SCRIPT_FILENAME",
SG(request_info).path_translated, track_vars_array TSRMLS_CC);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php