cvs: php4 /sapi/thttpd thttpd.c
| From: | Sascha Schumann | Date: | Thu, 03 May 2001 09:04:15 +0000 |
| Subject: | cvs: php4 /sapi/thttpd thttpd.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-5488@lists.php.net to get a copy of this message | ||
sas Thu May 3 02:04:15 2001 EDT
Modified files:
/php4/sapi/thttpd thttpd.c
Log:
Replace slow strlcpy with a quick memcpy.
Index: php4/sapi/thttpd/thttpd.c
diff -u php4/sapi/thttpd/thttpd.c:1.42 php4/sapi/thttpd/thttpd.c:1.43
--- php4/sapi/thttpd/thttpd.c:1.42 Wed May 2 15:53:41 2001
+++ php4/sapi/thttpd/thttpd.c Thu May 3 02:04:15 2001
@@ -165,6 +165,7 @@
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 @@
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");