Re: cvs: php4 /sapi/thttpd thttpd.c

From: Date: Thu, 03 May 2001 09:10:17 +0000
Subject: Re: cvs: php4 /sapi/thttpd thttpd.c
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-5490@lists.php.net to get a copy of this message
Hmm didn't know that strlcpy() is slower than strlen()&memcpy(). Anyway, it's your module. Enjoy... Andi At 09:04 AM 5/3/2001 +0000, Sascha Schumann wrote:
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");
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-cvs-unsubscribe@lists.php.net For additional commands, e-mail: php-cvs-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.cvs (#5490) next »