From: Jani Taskinen Date: Tue, 8 Dec 2009 17:46:19 +0000 (+0000) Subject: MFB: sprintf -> snprintf + all other patches people did not bother to merge X-Git-Tag: php-5.4.0alpha1~191^2~2274 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0b092054139c4e5c6f1353cb8fa060061e1f2f8c;p=php MFB: sprintf -> snprintf + all other patches people did not bother to merge --- diff --git a/sapi/apache2handler/php_functions.c b/sapi/apache2handler/php_functions.c index bafdd605a0..da8808605b 100644 --- a/sapi/apache2handler/php_functions.c +++ b/sapi/apache2handler/php_functions.c @@ -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, diff --git a/sapi/cli/php.1.in b/sapi/cli/php.1.in index 9a88886f7d..1033bb5d9b 100644 --- a/sapi/cli/php.1.in +++ b/sapi/cli/php.1.in @@ -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: diff --git a/sapi/cli/php_cli_readline.c b/sapi/cli/php_cli_readline.c index 876775f123..6da5b93908 100644 --- a/sapi/cli/php_cli_readline.c +++ b/sapi/cli/php_cli_readline.c @@ -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); } diff --git a/sapi/isapi/php5isapi.c b/sapi/isapi/php5isapi.c index f3a1b58e28..da76829867 100644 --- a/sapi/isapi/php5isapi.c +++ b/sapi/isapi/php5isapi.c @@ -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 ); } diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c index 9df413d05a..aa5b46f455 100644 --- a/sapi/litespeed/lsapilib.c +++ b/sapi/litespeed/lsapilib.c @@ -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;