libmultipath: fix gcc -Wstringop-truncation warning in set_value()
authorMartin Wilck <mwilck@suse.com>
Mon, 24 Jun 2019 09:27:27 +0000 (11:27 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Wed, 3 Jul 2019 06:30:29 +0000 (08:30 +0200)
commitf12b4a389b3b68da7cd92f0cf88d243913fc970e
tree7d5587bd71255e5d4d8a7a391736c2adb4ac8f02
parent3bb52dc2eb05e2eab7e190490ac61ed1aedd4240
libmultipath: fix gcc -Wstringop-truncation warning in set_value()

Fixes the following warning:

In function ‘strncat’,
    inlined from ‘set_value’ at parser.c:382:3:
/usr/include/bits/string_fortified.h:136:10: warning: ‘__builtin_strncat’
    output truncated before terminating nul copying as many bytes from a
    string as its length [-Wstringop-truncation]
  136 |   return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parser.c: In function ‘set_value’:
parser.c:382:3: note: length computed here
  382 |   strncat(alloc, str, strlen(str));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

gcc's stringop checker expects that the size argument of strncat() is derived
from the destination, not source, side.
See https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/

Fix typo in error message along the way.

Signed-off-by: Martin Wilck <mwilck@suse.com>
libmultipath/parser.c