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