Commit 6ce146fb authored by Nils Goroll's avatar Nils Goroll

Rather than disregard overflowing classification headers, fill up our buffer

completely (with up to UA_LIMIT characters)

Add a regression test with a 1025 byte long User-Agent Header

Fixes Assertion `w > uabuf' failed panics.
parent eaaa50f6
......@@ -59,8 +59,11 @@ const char * const ua_prepend[DCS_VARNISH2_NHDRS] = {
#define appnd(w, space, r, l) \
l = strlen(r); \
strncpy(w, r, space); \
if (l > space) \
if (l > space) { \
w += space; \
space = 0; \
break; \
} \
space -= l; \
w += l;
......
# $Id$
varnishtest "Test dcs vmod excessively long ua"
server s1 {
rxreq
txresp
} -start
varnish v1 -vcl+backend {
import dcs from "${vmod_topbuild}/src/.libs/libvmod_dcs.so";
sub vcl_recv {
# this code will classify
#
# for best performance in production, only call classify
# once or use inline-C to save the return value of
# classify (int)
# exotic use cases
set req.http.xx-entry-key = dcs.entry_key(dcs.classify());
set req.http.xx-type-id = dcs.type_id(dcs.classify());
# common use cases
set req.http.x-nb-classified = dcs.type_name(dcs.classify());
set req.http.X-DeviceClass = dcs.type_class(dcs.classify());
error 200;
}
sub vcl_error {
set obj.http.xx-entry-key = req.http.xx-entry-key;
set obj.http.xx-type-id = req.http.xx-type-id;
set obj.http.x-nb-classified = req.http.x-nb-classified;
set obj.http.X-DeviceClass = req.http.X-DeviceClass;
synthetic {"classified ad here
"};
return (deliver);
}
} -start
client c1 {
txreq -hdr "User-Agent: motorokr z6/r60_g_80.xx.yyi mozilla/4.0 (compatible; msie 6.0 linux; motorokr z6;nnn) profile/midp-2.0 configuration/cldc-1.1 opera 8.50[yy] up.link/6.3.0.0.0 netbiscuits motorokr z6/r60_g_80.xx.yyi mozilla/4.0 (compatible; msie 6.0 linux; motorokr z6;nnn) profile/midp-2.0 configuration/cldc-1.1 opera 8.50[yy] up.link/6.3.0.0.0 netbiscuits motorokr z6/r60_g_80.xx.yyi mozilla/4.0 (compatible; msie 6.0 linux; motorokr z6;nnn) profile/midp-2.0 configuration/cldc-1.1 opera 8.50[yy] up.link/6.3.0.0.0 netbiscuits motorokr z6/r60_g_80.xx.yyi mozilla/4.0 (compatible; msie 6.0 linux; motorokr z6;nnn) profile/midp-2.0 configuration/cldc-1.1 opera 8.50[yy] up.link/6.3.0.0.0 netbiscuits motorokr z6/r60_g_80.xx.yyi mozilla/4.0 (compatible; msie 6.0 linux; motorokr z6;nnn) profile/midp-2.0 configuration/cldc-1.1 opera 8.50[yy] up.link/6.3.0.0.0 netbiscuits motorokr z6/r60_g_80.xx.yyi mozilla/4.0 (compatible; msie 6.0 linux; motorokr z6;nnn) profile/midp-2.0 configuration/cldc-1.1 opera 8.50[yy] up.link/6.3.0.0.0 netbiscuits" \
-hdr "X-Goog-Source: even longer"
rxresp
expect resp.status == 200
expect resp.http.xx-entry-key == "motorokr z6/r60_g_80.xx.yyi mozilla/4.0 (compatible; msie 6.0 linux; motorokr z6;nnn) profile/midp-2.0 configuration/cldc-1.1 opera 8.50[yy] up.link/6.3.0.0.0 netbiscuits"
expect resp.http.xx-type-id == "11"
expect resp.http.x-nb-classified == "Mobile Phone"
expect resp.http.X-DeviceClass == "smartphone"
} -run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment