Advoid warning about a short strncpy

We added a NUL one line down, but make the compiler happy...

In function ‘strncpy’,
    inlined from ‘wadj_cfg_req’ at vmod_weightadjust.c:179:10,
    inlined from ‘vmod_random_add_backend’ at vmod_weightadjust.c:300:14:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: error: ‘__builtin_strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |                                   __glibc_objsize (__dest));
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~
vmod_weightadjust.c: In function ‘vmod_random_add_backend’:
vmod_weightadjust.c:169:36: note: length computed here
  169 |         const int reql = request ? strlen(request) + 1 : 0;
      |                                    ^~~~~~~~~~~~~~~
parent ccc0f75c
......@@ -176,7 +176,7 @@ 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);
(void) strncpy(s, request, reql);
s[reql - 1]= '\0';
tok = strtok_r(s, "\r\n", &save);
while (tok) {
......
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