Changeset 2037

Show
Ignore:
Timestamp:
01/16/2008 01:00:32 AM (6 months ago)
Author:
glen
Message:

- prevent crash in certain php-fcgi configurations (#841)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/lighttpd-1.4.x/NEWS

    r2035 r2037  
    1313  * fixed a bug that made /-prefixed extensions being handled also when 
    1414    matching the end of the uri in fcgi,scgi and proxy modules (#1489) 
    15   * Print error if X-LIGHTTPD-send-file cannot be done; reset header 
    16     Content-Length for send-file. Patches by Stefan B� 
     15  * print error if X-LIGHTTPD-send-file cannot be done; reset header 
     16    Content-Length for send-file. Patches by Stefan B�  * prevent crash in certain php-fcgi configurations (#841) 
     17 
    1718- 1.4.18 - 2007-09-09 
    1819 
  • branches/lighttpd-1.4.x/src/mod_fastcgi.c

    r2034 r2037  
    163163         * whole connection is local 
    164164         * 
    165          * if tcp/ip should be used host AND port have 
    166          * to be specified 
     165         * if port is not 0, and host is not specified, 
     166         * "localhost" (INADDR_LOOPBACK) is assumed. 
    167167         * 
    168168         */ 
     
    824824 
    825825                if (buffer_is_empty(host->host)) { 
    826                         fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_ANY); 
     826                        fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_LOOPBACK); 
    827827                } else { 
    828828                        struct hostent *he; 
    829829 
    830830                        /* set a useful default */ 
    831                         fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_ANY); 
     831                        fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_LOOPBACK); 
    832832 
    833833 
     
    859859 
    860860                buffer_copy_string(proc->connection_name, "tcp:"); 
    861                 buffer_append_string_buffer(proc->connection_name, host->host); 
     861                if (!buffer_is_empty(host->host)) { 
     862                        buffer_append_string_buffer(proc->connection_name, host->host); 
     863                } else { 
     864                        buffer_append_string(proc->connection_name, "localhost"); 
     865                } 
    862866                buffer_append_string(proc->connection_name, ":"); 
    863867                buffer_append_long(proc->connection_name, proc->port); 
     
    16881692        } else { 
    16891693                fcgi_addr_in.sin_family = AF_INET; 
    1690                 if (0 == inet_aton(host->host->ptr, &(fcgi_addr_in.sin_addr))) { 
    1691                         log_error_write(srv, __FILE__, __LINE__, "sbs", 
    1692                                         "converting IP address failed for", host->host, 
    1693                                         "\nBe sure to specify an IP address here"); 
    1694  
    1695                         return -1; 
     1694                if (!buffer_is_empty(host->host)) { 
     1695                        if (0 == inet_aton(host->host->ptr, &(fcgi_addr_in.sin_addr))) { 
     1696                                log_error_write(srv, __FILE__, __LINE__, "sbs", 
     1697                                                "converting IP address failed for", host->host, 
     1698                                                "\nBe sure to specify an IP address here"); 
     1699         
     1700                                return -1; 
     1701                        } 
     1702                } else { 
     1703                        fcgi_addr_in.sin_addr.s_addr = htonl(INADDR_LOOPBACK); 
    16961704                } 
    16971705                fcgi_addr_in.sin_port = htons(proc->port); 
     
    17031711                        /* on remote spawing we have to set the connection-name now */ 
    17041712                        buffer_copy_string(proc->connection_name, "tcp:"); 
    1705                         buffer_append_string_buffer(proc->connection_name, host->host); 
     1713                        if (!buffer_is_empty(host->host)) { 
     1714                                buffer_append_string_buffer(proc->connection_name, host->host); 
     1715                        } else { 
     1716                                buffer_append_string(proc->connection_name, "localhost"); 
     1717                        } 
    17061718                        buffer_append_string(proc->connection_name, ":"); 
    17071719                        buffer_append_long(proc->connection_name, proc->port); 
     
    27332745        int ret; 
    27342746 
    2735         /* sanity check */ 
     2747        /* sanity check: 
     2748         *  - host != NULL 
     2749         *  - either: 
     2750         *     - tcp socket (do not check host->host->uses, as it may be not set which means INADDR_LOOPBACK) 
     2751         *     - unix socket 
     2752         */ 
    27362753        if (!host || 
    2737             ((!host->host->used || !host->port) && !host->unixsocket->used)) { 
     2754            (!host->port && !host->unixsocket->used)) { 
    27382755                log_error_write(srv, __FILE__, __LINE__, "sxddd", 
    27392756                                "write-req: error",