Commit 4dcf6aa8 by 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
......@@ -100,16 +100,18 @@ const char * const ua_prepend[DCS_VARNISH2_NHDRS] = {
[3] = NULL
};
#define appnd(w, space, r, l) \
l = strlen(r); \
strncpy(w, r, space); \
if (l > space) { \
w += space; \
space = 0; \
break; \
} \
space -= l; \
w += l;
#define appnd(w, space, r, l) \
do { \
l = strlen(r); \
strncpy(w, r, space); \
if (l > space) { \
w += space; \
space = 0; \
break; \
} \
space -= l; \
w += l; \
} while(0)
static int
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