avoid a warning on gcc8

In function ‘wadj_cfg_req.isra.1’,
    inlined from ‘vmod_random_add_backend’ at
vmod_weightadjust.c:291:14:
vmod_weightadjust.c:170:10: error: ‘strncpy’ output truncated before
terminating nul copying as many bytes from a string as its length
[-Werror=stringop-truncation]

gcc does not understand that we are adding a NUL ourselves. Avoid this
warning by a differnt but equally safe approach.

Reported by volker27@gmx.at, thank you
parent 010507c7
......@@ -167,8 +167,8 @@ wadj_cfg_req(const struct backend *be, VCL_STRING url, VCL_STRING request,
AN(vsb);
VSB_clear(vsb);
if (request != NULL && reql > 1) {
(void) strncpy(s, request, reql - 1);
s[reql - 1]= '\0';
(void) strcpy(s, request);
assert(strlen(s) < sizeof s);
tok = strtok_r(s, "\r\n", &save);
while (tok) {
if (! strcasecmp(tok, "Connection:"))
......
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