summaryrefslogtreecommitdiff
path: root/sapi/nsapi/nsapi.c
diff options
context:
space:
mode:
authorUwe Schindler <thetaphi@php.net>2007-03-06 18:15:25 +0000
committerUwe Schindler <thetaphi@php.net>2007-03-06 18:15:25 +0000
commitad336e432a89d0593294a097893ca1a5f85ed368 (patch)
tree27ccc8a6556bf3229333cd4cd263e9822e588eb9 /sapi/nsapi/nsapi.c
parente25bb8ea04f496a7d4e22b359886191909d0527a (diff)
downloadphp-git-ad336e432a89d0593294a097893ca1a5f85ed368.tar.gz
remove (large) static buffers for header names and request uri
Diffstat (limited to 'sapi/nsapi/nsapi.c')
-rw-r--r--sapi/nsapi/nsapi.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/sapi/nsapi/nsapi.c b/sapi/nsapi/nsapi.c
index cec4719009..fcd38f023e 100644
--- a/sapi/nsapi/nsapi.c
+++ b/sapi/nsapi/nsapi.c
@@ -587,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[2048];
+ char buf[32];
struct pb_entry *entry;
for (i = 0; i < nsapi_reqpb_size; i++) {
@@ -602,19 +602,22 @@ 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, 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;
}
@@ -670,22 +673,27 @@ 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) {
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);