diff options
author | Sascha Schumann <sas@php.net> | 2001-05-03 09:04:15 +0000 |
---|---|---|
committer | Sascha Schumann <sas@php.net> | 2001-05-03 09:04:15 +0000 |
commit | e337f07ecd4e53d394f07b631f6ec536e9c8c81f (patch) | |
tree | 623a3a85383b01c3b4fe1686c43849eb80812318 | |
parent | e176e5c101eca30bcf2ec2eeeacf7f8be0dd07ea (diff) | |
download | php-git-e337f07ecd4e53d394f07b631f6ec536e9c8c81f.tar.gz |
Replace slow strlcpy with a quick memcpy.
-rw-r--r-- | sapi/thttpd/thttpd.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c index e949cc77d9..a47bb1d0c8 100644 --- a/sapi/thttpd/thttpd.c +++ b/sapi/thttpd/thttpd.c @@ -165,6 +165,7 @@ static char *sapi_thttpd_read_cookies(SLS_D) static void sapi_thttpd_register_variables(zval *track_vars_array ELS_DC SLS_DC PLS_DC) { char buf[BUF_SIZE + 1]; + char *p; TLS_FETCH(); php_register_variable("PHP_SELF", SG(request_info).request_uri, track_vars_array ELS_CC PLS_CC); @@ -174,9 +175,13 @@ static void sapi_thttpd_register_variables(zval *track_vars_array ELS_DC SLS_DC php_register_variable("REQUEST_URI", SG(request_info).request_uri, track_vars_array ELS_CC PLS_CC); php_register_variable("PATH_TRANSLATED", SG(request_info).path_translated, track_vars_array ELS_CC PLS_CC); - strlcpy(buf, inet_ntoa(TG(hc)->client_addr.sa_in.sin_addr), sizeof(buf)); - ADD_STRING("REMOTE_ADDR"); - ADD_STRING("REMOTE_HOST"); + p = inet_ntoa(TG(hc)->client_addr.sa_in.sin_addr); + /* string representation of IPs are never larger than 512 bytes */ + if (p) { + memcpy(buf, p, strlen(p) + 1); + ADD_STRING("REMOTE_ADDR"); + ADD_STRING("REMOTE_HOST"); + } snprintf(buf, BUF_SIZE, "%d", TG(hc)->hs->port); ADD_STRING("SERVER_PORT"); |