Commit 5669adee authored by Geoff Simmons's avatar Geoff Simmons

fix an off-by-one error reading chunks into a VSB

parent 9ef5b13e
...@@ -94,6 +94,7 @@ get_payload(logline_t *rec) ...@@ -94,6 +94,7 @@ get_payload(logline_t *rec)
chunk = VSTAILQ_NEXT(chunk, chunklist); chunk = VSTAILQ_NEXT(chunk, chunklist);
} }
} }
assert(VSB_len(payload) == rec->len);
VSB_finish(payload); VSB_finish(payload);
} }
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
/* including source must include varnishevent.h and vre.h */ /* including source must include varnishevent.h and vre.h */
/* XXX: init as fixed size with length shm_reclen */ /* XXX: init as fixed size with length max_reclen + 1 */
struct vsb *payload; struct vsb *payload;
/* XXX: init time_start_re as VRE_compile(TS_START_REGEX) */ /* XXX: init time_start_re as VRE_compile(TS_START_REGEX) */
......
...@@ -54,7 +54,7 @@ static const char ...@@ -54,7 +54,7 @@ static const char
CONF_Init(); CONF_Init();
payload = VSB_new(NULL, NULL, DEFAULT_MAX_RECLEN, VSB_FIXEDLEN); payload = VSB_new(NULL, NULL, DEFAULT_MAX_RECLEN + 1, VSB_FIXEDLEN);
MAN(payload); MAN(payload);
time_start_re = VRE_compile(TS_START_REGEX, VRE_CASELESS, &error, time_start_re = VRE_compile(TS_START_REGEX, VRE_CASELESS, &error,
...@@ -106,7 +106,7 @@ static const char ...@@ -106,7 +106,7 @@ static const char
} }
char *str = (char *) malloc(config.max_reclen); char *str = (char *) malloc(config.max_reclen);
MAN(str); MAN(str);
sprintf(str, "%0*d", config.max_reclen - 1, 0); sprintf(str, "%0*d", config.max_reclen, 0);
get_payload(&rec); get_payload(&rec);
MASSERT(strcmp(VSB_data(payload), str) == 0); MASSERT(strcmp(VSB_data(payload), str) == 0);
......
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