Bug 54179

Summary: Improper logging of large messages
Product: Apache httpd-2 Reporter: Marek Wianecki <mieszek2>
Component: mod_dumpioAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: RESOLVED FIXED    
Severity: minor Keywords: FixedInTrunk
Priority: P2    
Version: 2.4.3   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: simple patch - to review, not to use

Description Marek Wianecki 2012-11-21 10:36:40 UTC
Created attachment 29616 [details]
simple patch - to review, not to use

When large message is logged by moddumpio message is divided in parts (MAX_STRING_LEN / 4 - 80 -> length of a message) and logged by ap_log_cerror() function. When message is divided its always logged from the beggining so part of a message is lost, example log(edited):

 mod_dumpio.c(63): [client 9.9.9.5:29835] mod_dumpio:  dumpio_out (data-HEAP): 204 bytes
 mod_dumpio.c(103): [client 9.9.9.5:29835] mod_dumpio:  dumpio_out (data-HEAP): HTTP/1.1 200 OK\r\nDate: Tue, 20 Nov 2012 09:49:33 GMT\r\nServer: WebSphere Application Server/6.1\r\nContent-Type: text/xml; charset=utf-8\r\nContent-Language: en-US\r\nContent-Length: 25709\r\nConnection: close\r\n\r\n
 mod_dumpio.c(161): [client 9.9.9.5:29835] mod_dumpio: dumpio_out
 mod_dumpio.c(63): [client 9.9.9.5:29835] mod_dumpio:  dumpio_out (data-TRANSIENT): 1163 bytes
 mod_dumpio.c(103): [client 9.9.9.5:29835] mod_dumpio:  dumpio_out (data-TRANSIENT): <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><message>part
 mod_dumpio.c(63): [client 9.9.9.5:29835] mod_dumpio:  dumpio_out (data-TRANSIENT): 4044 bytes
 mod_dumpio.c(103): [client 9.9.9.5:29835] mod_dumpio:  dumpio_out (data-TRANSIENT): //www.w3.org/2001/XMLSchema-instance"><bigmessage>message part 1 .... </bigmessage
 mod_dumpio.c(103): [client 9.9.9.5:29835] mod_dumpio:  dumpio_out (data-TRANSIENT): //www.w3.org/2001/XMLSchema-instance"><bigmessage>message part 1 .... </bigmessage
 mod_dumpio.c(103): [client 9.9.9.5:29835] mod_dumpio:  dumpio_out (data-TRANSIENT): //www.w3.org/2001/XMLSchema-instance"><bigmessage>message part 1 .... </bigmessage


message part 1 was logged 3 times, no message part 2 and 3 will be logged.

Probable cause:
ap_log_cerror call in dumpit function shouldn't be made with &buf as a parameter because it will allways result in a message log made from the beggining of a message. Pointer to message passed to ap_log_cerror must be incremented by the value of previously logged message length. 

Im attaching patch which is working for us but it was not written by C proggramer so it shoutldn't be used :)
Comment 1 Christophe JAILLET 2012-11-21 20:59:43 UTC
Thanks for the report.

Fixed in trunk, with a slightly different patch.
http://svn.apache.org/viewvc?view=revision&sortby=date&revision=1412278

The idea is obviously the same, but I put the '+ logbytes' outside of the #if/#else/#endif because the issue is the same on the other branch.
I also made some small cosmetic changes.


I'll propose it for backport to 2.4.x in 1 week or so if nobody complains.
Comment 2 Marek Wianecki 2012-11-22 13:02:00 UTC
thx, patch works for me :)
Comment 3 Stefan Fritsch 2013-03-03 16:53:40 UTC
fixed in 2.4.4