Commit 4dcf6aa8 authored by Nils Goroll's avatar Nils Goroll

fix the appnd() macro - it needs a block

when called below in

	if (ua_prepend[i])
		appnd(w, space, ua_prepend[i], l);

appnd would exand such that only the first line (l = strlen(r))
was conditional on ua_prepend[i] being non-null, which then would
trigger a null pointer dereference in strncpy.

This is a particularly embarassing bug.
parent 8d763bee
...@@ -101,6 +101,7 @@ const char * const ua_prepend[DCS_VARNISH2_NHDRS] = { ...@@ -101,6 +101,7 @@ const char * const ua_prepend[DCS_VARNISH2_NHDRS] = {
}; };
#define appnd(w, space, r, l) \ #define appnd(w, space, r, l) \
do { \
l = strlen(r); \ l = strlen(r); \
strncpy(w, r, space); \ strncpy(w, r, space); \
if (l > space) { \ if (l > space) { \
...@@ -109,7 +110,8 @@ const char * const ua_prepend[DCS_VARNISH2_NHDRS] = { ...@@ -109,7 +110,8 @@ const char * const ua_prepend[DCS_VARNISH2_NHDRS] = {
break; \ break; \
} \ } \
space -= l; \ space -= l; \
w += l; w += l; \
} while(0)
static int static int
dcs_varnish_classify(dcs_ctx *ctx) { dcs_varnish_classify(dcs_ctx *ctx) {
......
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