jani                                     Tue, 08 Dec 2009 17:46:19 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=291888

Log:
MFB: sprintf -> snprintf + all other patches people did not bother to merge

Changed paths:
    U   php/php-src/trunk/sapi/apache2handler/php_functions.c
    U   php/php-src/trunk/sapi/cli/php.1.in
    U   php/php-src/trunk/sapi/cli/php_cli_readline.c
    U   php/php-src/trunk/sapi/isapi/php5isapi.c
    U   php/php-src/trunk/sapi/litespeed/lsapilib.c

Modified: php/php-src/trunk/sapi/apache2handler/php_functions.c
===================================================================
--- php/php-src/trunk/sapi/apache2handler/php_functions.c       2009-12-08 
17:30:22 UTC (rev 291887)
+++ php/php-src/trunk/sapi/apache2handler/php_functions.c       2009-12-08 
17:46:19 UTC (rev 291888)
@@ -396,27 +396,27 @@
        if (apv && *apv) {
                php_info_print_table_row(2, "Apache Version", apv);
        }
-       sprintf(tmp, "%d", MODULE_MAGIC_NUMBER);
+       snprintf(tmp, sizeof(tmp), "%d", MODULE_MAGIC_NUMBER);
        php_info_print_table_row(2, "Apache API Version", tmp);

        if (serv->server_admin && *(serv->server_admin)) {
                php_info_print_table_row(2, "Server Administrator", 
serv->server_admin);
        }

-       sprintf(tmp, "%s:%u", serv->server_hostname, serv->port);
+       snprintf(tmp, sizeof(tmp), "%s:%u", serv->server_hostname, serv->port);
        php_info_print_table_row(2, "Hostname:Port", tmp);

 #if !defined(WIN32) && !defined(WINNT)
 #if MODULE_MAGIC_NUMBER_MAJOR >= 20081201
-       sprintf(tmp, "%s(%d)/%d", ap_unixd_config.user_name, 
ap_unixd_config.user_id, ap_unixd_config.group_id);
+       snprintf(tmp, sizeof(tmp), "%s(%d)/%d", ap_unixd_config.user_name, 
ap_unixd_config.user_id, ap_unixd_config.group_id);
 #else
-       sprintf(tmp, "%s(%d)/%d", unixd_config.user_name, unixd_config.user_id, 
unixd_config.group_id);
+       snprintf(tmp, sizeof(tmp), "%s(%d)/%d", unixd_config.user_name, 
unixd_config.user_id, unixd_config.group_id);
 #endif
        php_info_print_table_row(2, "User/Group", tmp);
 #endif

        ap_mpm_query(AP_MPMQ_MAX_REQUESTS_DAEMON, &max_requests);
-       sprintf(tmp, "Per Child: %d - Keep Alive: %s - Max Per Connection: %d", 
max_requests, (serv->keep_alive ? "on":"off"), serv->keep_alive_max);
+       snprintf(tmp, sizeof(tmp), "Per Child: %d - Keep Alive: %s - Max Per 
Connection: %d", max_requests, (serv->keep_alive ? "on":"off"), 
serv->keep_alive_max);
        php_info_print_table_row(2, "Max Requests", tmp);

        apr_snprintf(tmp, sizeof tmp,

Modified: php/php-src/trunk/sapi/cli/php.1.in
===================================================================
--- php/php-src/trunk/sapi/cli/php.1.in 2009-12-08 17:30:22 UTC (rev 291887)
+++ php/php-src/trunk/sapi/cli/php.1.in 2009-12-08 17:46:19 UTC (rev 291888)
@@ -375,11 +375,6 @@
 .B http://www.php.net/manual/
 .PD 1
 .P
-A nice introduction to PHP by Stig Bakken can be found here:
-.PD 0
-.P
-.B http://www.zend.com/zend/art/intro.php
-.PD 1
 .SH BUGS
 You can view the list of known bugs or report any new bug you
 found at:

Modified: php/php-src/trunk/sapi/cli/php_cli_readline.c
===================================================================
--- php/php-src/trunk/sapi/cli/php_cli_readline.c       2009-12-08 17:30:22 UTC 
(rev 291887)
+++ php/php-src/trunk/sapi/cli/php_cli_readline.c       2009-12-08 17:46:19 UTC 
(rev 291888)
@@ -59,8 +59,6 @@
 #include "zend_highlight.h"
 #include "zend_indent.h"

-/* {{{ cli_is_valid_code
- */
 typedef enum {
        body,
        sstring,
@@ -74,7 +72,7 @@
        outside,
 } php_code_type;

-int cli_is_valid_code(char *code, int len, char **prompt TSRMLS_DC)
+int cli_is_valid_code(char *code, int len, char **prompt TSRMLS_DC) /* {{{ */
 {
        int valid_end = 1, last_valid_end;
        int brackets_count = 0;
@@ -458,9 +456,10 @@
                        efree(class_name);
                }
                if (pce && retval) {
-                       char *tmp = malloc(class_name_len + 2 + strlen(retval) 
+ 1);
+                       int len = class_name_len + 2 + strlen(retval) + 1;
+                       char *tmp = malloc(len);

-                       sprintf(tmp, "%s::%s", (*pce)->name.s, retval);
+                       snprintf(tmp, len, "%s::%s", (*pce)->name.s, retval);
                        free(retval);
                        retval = tmp;
                }
@@ -469,9 +468,7 @@
        return retval;
 } /* }}} */

-/* {{{ cli_code_completion
- */
-char **cli_code_completion(const char *text, int start, int end)
+char **cli_code_completion(const char *text, int start, int end) /* {{{ */
 {
        return rl_completion_matches(text, cli_completion_generator);
 }

Modified: php/php-src/trunk/sapi/isapi/php5isapi.c
===================================================================
--- php/php-src/trunk/sapi/isapi/php5isapi.c    2009-12-08 17:30:22 UTC (rev 
291887)
+++ php/php-src/trunk/sapi/isapi/php5isapi.c    2009-12-08 17:46:19 UTC (rev 
291888)
@@ -389,24 +389,24 @@
         */
        strcpy( static_cons_buf, "/C=" );
        if( lpECB->GetServerVariable( lpECB->ConnID, "SSL_CLIENT_C", 
static_variable_buf, &variable_len ) && static_variable_buf[0] ) {
-               strcat( static_cons_buf, static_variable_buf );
+               strlcat( static_cons_buf, static_variable_buf,  
ISAPI_SERVER_VAR_BUF_SIZE);
        }
-       strcat( static_cons_buf, "/ST=" );
+       strlcat( static_cons_buf, "/ST=",  ISAPI_SERVER_VAR_BUF_SIZE);
        variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
        if( lpECB->GetServerVariable( lpECB->ConnID, "SSL_CLIENT_ST", 
static_variable_buf, &variable_len ) && static_variable_buf[0] ) {
-               strcat( static_cons_buf, static_variable_buf );
+               strlcat( static_cons_buf, static_variable_buf, 
ISAPI_SERVER_VAR_BUF_SIZE );
        }
        php_register_variable( "SSL_CLIENT_DN", static_cons_buf, 
track_vars_array TSRMLS_CC );

        strcpy( static_cons_buf, "/C=" );
        variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
        if( lpECB->GetServerVariable( lpECB->ConnID, "SSL_CLIENT_I_C", 
static_variable_buf, &variable_len ) && static_variable_buf[0] ) {
-               strcat( static_cons_buf, static_variable_buf );
+               strlcat( static_cons_buf, static_variable_buf, 
ISAPI_SERVER_VAR_BUF_SIZE );
        }
-       strcat( static_cons_buf, "/ST=" );
+       strlcat( static_cons_buf, "/ST=", ISAPI_SERVER_VAR_BUF_SIZE);
        variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
        if( lpECB->GetServerVariable( lpECB->ConnID, "SSL_CLIENT_I_ST", 
static_variable_buf, &variable_len ) && static_variable_buf[0] ) {
-               strcat( static_cons_buf, static_variable_buf );
+               strlcat( static_cons_buf, static_variable_buf, 
ISAPI_SERVER_VAR_BUF_SIZE );
        }
        php_register_variable( "SSL_CLIENT_I_DN", static_cons_buf, 
track_vars_array TSRMLS_CC );
 }

Modified: php/php-src/trunk/sapi/litespeed/lsapilib.c
===================================================================
--- php/php-src/trunk/sapi/litespeed/lsapilib.c 2009-12-08 17:30:22 UTC (rev 
291887)
+++ php/php-src/trunk/sapi/litespeed/lsapilib.c 2009-12-08 17:46:19 UTC (rev 
291888)
@@ -581,6 +581,9 @@
 #if defined(SIGXFSZ) && defined(SIG_IGN)
         signal(SIGXFSZ, SIG_IGN);
 #endif
+        /* let STDOUT function as STDERR,
+           just in case writing to STDOUT directly */
+        dup2( 2, 1 );

         if ( LSAPI_InitRequest( &g_req, LSAPI_SOCK_FILENO ) == -1 ) {
             return -1;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to