]> granicus.if.org Git - php/commitdiff
MFB: sprintf -> snprintf + all other patches people did not bother to merge
authorJani Taskinen <jani@php.net>
Tue, 8 Dec 2009 17:46:19 +0000 (17:46 +0000)
committerJani Taskinen <jani@php.net>
Tue, 8 Dec 2009 17:46:19 +0000 (17:46 +0000)
sapi/apache2handler/php_functions.c
sapi/cli/php.1.in
sapi/cli/php_cli_readline.c
sapi/isapi/php5isapi.c
sapi/litespeed/lsapilib.c

index bafdd605a00d5f06dbe5c6928f4eac455ed7f864..da8808605b8fab147268b39943ac482227659ebc 100644 (file)
@@ -396,27 +396,27 @@ PHP_MINFO_FUNCTION(apache)
        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,
index 9a88886f7d1c4cf92fe0d03a9eb45ae5d0ab3f95..1033bb5d9b835862f4f416ea74355330342a916d 100644 (file)
@@ -375,11 +375,6 @@ For a more or less complete description of PHP look here:
 .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:
index 876775f1232d8f2ce267c58ac3842a10403d520f..6da5b93908bf00d08489a574863faf98d86acc41 100644 (file)
@@ -59,8 +59,6 @@
 #include "zend_highlight.h"
 #include "zend_indent.h"
 
-/* {{{ cli_is_valid_code
- */
 typedef enum {
        body,
        sstring,
@@ -74,7 +72,7 @@ typedef enum {
        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 @@ TODO:
                        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 @@ TODO:
        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);
 }
index f3a1b58e28769aed723317dbcfc3a0ad7ba3b830..da76829867633cf9bb5c8b4c8ade1c091bb0324f 100644 (file)
@@ -389,24 +389,24 @@ static void sapi_isapi_register_zeus_ssl_variables(LPEXTENSION_CONTROL_BLOCK lpE
         */
        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 );        
 }
index 9df413d05ac28492af372c9c06a060f0095eda42..aa5b46f4555b4f70d92366e970969bcef663d2f3 100644 (file)
@@ -581,6 +581,9 @@ int LSAPI_Init(void)
 #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;