diff options
| author | Uwe Schindler <thetaphi@php.net> | 2007-03-06 15:43:49 +0000 |
|---|---|---|
| committer | Uwe Schindler <thetaphi@php.net> | 2007-03-06 15:43:49 +0000 |
| commit | e25bb8ea04f496a7d4e22b359886191909d0527a (patch) | |
| tree | c39199b4c879047dd309bb43fbc036919471ca0c /sapi/nsapi/nsapi.c | |
| parent | cc49ea3a1ef02b2883936b82271f928de3ff82a0 (diff) | |
| download | php-git-e25bb8ea04f496a7d4e22b359886191909d0527a.tar.gz | |
use slprintf instead of snprintf and remove 0termination things (because slprintf is always available now)
Diffstat (limited to 'sapi/nsapi/nsapi.c')
| -rw-r--r-- | sapi/nsapi/nsapi.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c index c2636ff332..cec4719009 100644 --- a/sapi/nsapi/nsapi.c +++ b/sapi/nsapi/nsapi.c @@ -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 */ @@ -589,7 +587,7 @@ static void sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_D 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 @@ static void sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_D 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 @@ static void sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_D 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 @@ static void sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_D /* 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 @@ static void sapi_nsapi_register_server_variables(zval *track_vars_array TSRMLS_D /* 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); } } |
