Bug 54179 - Improper logging of large messages
Summary: Improper logging of large messages
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_dumpio (show other bugs)
Version: 2.4.3
Hardware: PC Linux
: P2 minor (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: FixedInTrunk
Depends on:
Blocks:
 
Reported: 2012-11-21 10:36 UTC by Marek Wianecki
Modified: 2013-05-31 07:11 UTC (History)
0 users



Attachments
simple patch - to review, not to use (1.55 KB, patch)
2012-11-21 10:36 UTC, Marek Wianecki
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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