thetaphi Tue Mar 6 15:43:49 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/sapi/nsapi nsapi.c Log: use slprintf instead of snprintf and remove 0termination things (because slprintf is always available now) http://cvs.php.net/viewvc.cgi/php-src/sapi/nsapi/nsapi.c?r1=1.69.2.3.2.3&r2=1.69.2.3.2.4&diff_format=u Index: php-src/sapi/nsapi/nsapi.c diff -u php-src/sapi/nsapi/nsapi.c:1.69.2.3.2.3 php-src/sapi/nsapi/nsapi.c:1.69.2.3.2.4 --- php-src/sapi/nsapi/nsapi.c:1.69.2.3.2.3 Mon Mar 5 16:29:18 2007 +++ php-src/sapi/nsapi/nsapi.c Tue Mar 6 15:43:49 2007 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: nsapi.c,v 1.69.2.3.2.3 2007/03/05 16:29:18 thetaphi Exp $ */ +/* $Id: nsapi.c,v 1.69.2.3.2.4 2007/03/06 15:43:49 thetaphi Exp $ */ /* * PHP includes @@ -73,8 +73,6 @@ #define NSLS_CC , NSLS_C #define NSG(v) (request_context->v) -#define NS_BUF_SIZE 2048 - /* * ZTS needs to be defined for NSAPI to work */ @@ -310,7 +308,7 @@ PHP_MINFO_FUNCTION(nsapi) { php_info_print_table_start(); - php_info_print_table_row(2, "NSAPI Module Revision", "$Revision: 1.69.2.3.2.3 $"); + php_info_print_table_row(2, "NSAPI Module Revision", "$Revision: 1.69.2.3.2.4 $"); 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" ); @@ -589,7 +587,7 @@ register size_t i; int pos; char *value,*p; - char buf[NS_BUF_SIZE + 1]; + char buf[2048]; struct pb_entry *entry; for (i = 0; i < nsapi_reqpb_size; i++) { @@ -604,13 +602,12 @@ while (entry) { if (!PG(safe_mode) || strncasecmp(entry->param->name, "authorization", 13)) { if (strcasecmp(entry->param->name, "content-length")==0 || strcasecmp(entry->param->name, "content-type")==0) { - strlcpy(buf, entry->param->name, NS_BUF_SIZE); + strlcpy(buf, entry->param->name, sizeof(buf)); pos = 0; } else { - snprintf(buf, NS_BUF_SIZE, "HTTP_%s", entry->param->name); + slprintf(buf, sizeof(buf), "HTTP_%s", entry->param->name); pos = 5; } - buf[NS_BUF_SIZE]='\0'; for(p = buf + pos; *p; p++) { *p = toupper(*p); if (*p < 'A' || *p > 'Z') { @@ -642,7 +639,7 @@ nsapi_free(value); } - snprintf(buf, NS_BUF_SIZE, "%d", conf_getglobals()->Vport); + slprintf(buf, sizeof(buf), "%d", conf_getglobals()->Vport); php_register_variable("SERVER_PORT", buf, track_vars_array TSRMLS_CC); php_register_variable("SERVER_NAME", conf_getglobals()->Vserver_hostname, track_vars_array TSRMLS_CC); @@ -672,18 +669,17 @@ /* Create full Request-URI & Script-Name */ if (SG(request_info).request_uri) { - strlcpy(buf, SG(request_info).request_uri, NS_BUF_SIZE); if (SG(request_info).query_string) { - p = strchr(buf, 0); - snprintf(p, NS_BUF_SIZE-(p-buf), "?%s", SG(request_info).query_string); - buf[NS_BUF_SIZE]='\0'; + slprintf(buf, sizeof(buf), "%s?%s", SG(request_info).request_uri, SG(request_info).query_string); + } else { + strlcpy(buf, SG(request_info).request_uri, sizeof(buf)); } php_register_variable("REQUEST_URI", buf, track_vars_array TSRMLS_CC); - strlcpy(buf, SG(request_info).request_uri, NS_BUF_SIZE); + 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<=NS_BUF_SIZE && rc->path_info) { + if (pos>=0 && pos<sizeof(buf)) { buf[pos] = '\0'; } else { buf[0]='\0'; @@ -695,7 +691,7 @@ /* special variables in error mode */ if (rc->http_error) { - snprintf(buf, NS_BUF_SIZE, "%d", rc->http_error); + slprintf(buf, sizeof(buf), "%d", rc->http_error); php_register_variable("ERROR_TYPE", buf, track_vars_array TSRMLS_CC); } }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php