[squid-dev] Http::One::Parser::getHeaderField bug

Amos Jeffries squid3 at treenet.co.nz
Thu Nov 13 03:06:54 UTC 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 13/11/2014 5:34 a.m., Tsantilas Christos wrote:
> The following patch is fixing it:
> 
> === modified file 'src/http/one/Parser.cc' ---
> src/http/one/Parser.cc      2014-09-14 12:43:00 +0000 +++
> src/http/one/Parser.cc      2014-11-12 16:31:08 +0000 @@ -71,7
> +71,7 @@ p.chop(0, sizeof(header)-1);
> 
> // return the header field-value -        xstrncpy(header,
> p.rawContent(), p.length()); +        strcpy(header, p.c_str());

c_str() re-allocates. We can and need to avoid that here.

> debugs(25, 5, "returning " << header); return header; }
> 
> 
> Does this looks like an SBuf bug?

No. I think it was just me overlooking that xstrncpy() length includes
and enforces the '\0' termination.

Use this:  xstrncpy(header, p.rawContent(), p.length()+1);

Amos

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (MingW32)

iQEcBAEBAgAGBQJUZCBOAAoJELJo5wb/XPRjNMwH/31Cc0HAv10iAqcQfQlR0b7f
Kv2mtLpLefo0xZQ2aPEX5zhG6XcjwckGCLWBuG3/OosZjI/US0stzM1EtPfQXo1h
9l/qD9dLEltjHD6Ohin8li/bMgrdu8228xnr7haDhSqdBYvg5ruhDrNLVJELrMRJ
JhBL8tTh3bZeUMpn31WfuU67m8cwUzoGwMesrGCuSblQifqmOSdXWT7rvnVRavG/
zma1oQ0XnK14fPyVB7F9UChyKe+IBSleU3QZjOQOT71XgxAiJ9mOznQ19jE7pUCO
OItVcD5OHj4Yl6nIfGyA9HyMK9W4DNXtFI3gjwesFBOgyugMZRPDbdrf7/PlGiY=
=H30D
-----END PGP SIGNATURE-----


More information about the squid-dev mailing list