rvagg/mod_geoip2_xff — pull request #2 by KevinGaudin (2012-08-28 22:20:50+00:00)
Title: Bugfix: bad string allocation management caused numerous seg faults on production server when several intermediate servers were involved (proxy + CDN + load balancer)

Hi Rod,

I experienced real strange frequent random bugs on one of our websites where mod_geoip2_xff was installed, occurring only when behind our corporate proxy + CDNs. Here is the result of my analysis and a proposed fix.

XFF strings like "10.6.1.35,10.6.21.241,10.6.1.45,94.127.72.60" were
causing segmentation faults.
Fixed:
- match was allocated memory with a wrong size, before the calculation
of its required length. If 3 IP followed with the second being shorter than the
third, seg faults happened.
- as the trailing 0 is added after strncpy, we must add 1 byte to the
allocation for match
- str was never freed

I'll have this new version deployed on our servers during the following days.

Kevin