ports/89308: [patch] www/mod_accounting crash on request_timeout

Andrey Yakovlev freedom at kiev.farlep.net
Sun Nov 20 11:50:19 UTC 2005


>Number:         89308
>Category:       ports
>Synopsis:       [patch] www/mod_accounting crash on request_timeout
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 20 11:50:17 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Andrey Yakovlev
>Release:        FreeBSD 4.11-RELEASE i386
>Organization:
>Environment:
System: FreeBSD webber.kiev.farlep.net 4.11-RELEASE-p11 FreeBSD 4.11-RELEASE-p11 #2: Thu Jun 30 15:38:16 EEST 2005     root at webber.kiev.farlep.net:/usr/obj/u01/src/sys/WEBBER  i386

apache-1.3.34
mysql-client-4.0.26
mysql-server-4.0.26

	
>Description:
	
	Incorrect parsing structure fields  in  mod_accounting, func BytesRecvd() on empty request.
        While in Apache logs we can see following
	
	[Wed Nov  9 11:06:13 2005] [info] [client 82.151.196.185] read request line timed out
	[Wed Nov  9 11:06:13 2005] [notice] child pid 4588 exit signal Segmentation fault (11)
	
	While I'm here, also include patch to allow multiple sql requests in mod_accounting config.

>How-To-Repeat:
	cd /usr/ports/www/mod_accounting/ && make install clean
	configure and wait  request_timeout
	
>Fix:

	

--- mod_accounting.patch begins here ---
*** mod_accounting.c.orig	Sun Sep  8 18:17:22 2002
--- mod_accounting.c	Fri Nov 11 11:26:43 2005
***************
*** 140,146 ****
  // computes the number of bytes received
  static long BytesRecvd( request_rec *r )
  {
! 	long		recvd;
  	const char *len;
  
  #ifdef DEBUG
--- 140,146 ----
  // computes the number of bytes received
  static long BytesRecvd( request_rec *r )
  {
! 	long recvd=0;
  	const char *len;
  
  #ifdef DEBUG
***************
*** 148,153 ****
--- 148,155 ----
  				  "BytesRecvd" );
  #endif
  
+ 	if( ! r ) return( 0 ); // empty request
+ 	if( ! r->the_request  ) return( 0 ); // empty request
  	recvd = strlen( r->the_request ) + TableLen( r, r->headers_in ) + 4; // 2 for CRLF after the request, 2 for CRLF after all headers
  
  	len = ap_table_get( r->headers_in, "Content-Length" );
--- mysql.c.orig	Sat Jan  5 13:50:50 2002
+++ mysql.c	Tue Apr 19 23:32:07 2005
@@ -76,16 +76,39 @@
 
 	if( cfg->DBHandle ) {
 
-		retval = mysql_query(( MYSQL * )cfg->DBHandle, query );
+		//
+		// loop for handling multiple SQL 
+		char* new_query;
+		char* end_;
+		char* copy_query = malloc(strlen(query)+1);
+		
+		(void) strcpy (copy_query, query);
+		
+		end_ = copy_query - 1;
+		
+		do {
+		    
+		    new_query = end_ + 1; 
+		    
+		    // locate occurance of ';'
+		    end_ = strchr( new_query, ';' );
+		    
+		    if (end_) *end_ = 0;
+		    
+		    retval = mysql_query(( MYSQL * )cfg->DBHandle, new_query );
 
-		if( retval ) {
+		    if( retval ) {
 
-			ap_log_error( APLOG_MARK,ERRLEVEL, server, 
-						  ap_pstrcat( p, "MySQL insert failed:  ", query, NULL ));
+			    ap_log_error( APLOG_MARK,ERRLEVEL, server, 
+						    ap_pstrcat( p, "MySQL insert failed:  ", query, NULL ));
 
-			ap_log_error( APLOG_MARK, ERRLEVEL, server, 
-						  ap_pstrcat( p, "MySQL failure reason:  ", MYSQL_ERROR( cfg->DBHandle ), NULL ));
-		}
+			    ap_log_error( APLOG_MARK, ERRLEVEL, server, 
+						    ap_pstrcat( p, "MySQL failure reason:  ", MYSQL_ERROR( cfg->DBHandle ), NULL ));
+		    }
+		
+		} while ( end_ );
+		
+		free( copy_query );
 	}
 
 	signal( SIGPIPE, handler );
--- mod_accounting.patch ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list