netfilter: prefer nla_strlcpy for dealing with NLA_STRING attributes
authorFlorian Westphal <fw@strlen.de>
Sat, 5 May 2018 22:45:43 +0000 (00:45 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 8 May 2018 12:15:31 +0000 (14:15 +0200)
commit4e09fc873d92398001e267f7b60c36c963f825b3
tree020b1146c61c4a25e286cdc53b51411b6280ae5b
parent25fd386e0bc065849db7400f579e82863ea44838
netfilter: prefer nla_strlcpy for dealing with NLA_STRING attributes

fixes these warnings:
'nfnl_cthelper_create' at net/netfilter/nfnetlink_cthelper.c:237:2,
'nfnl_cthelper_new' at net/netfilter/nfnetlink_cthelper.c:450:9:
./include/linux/string.h:246:9: warning: '__builtin_strncpy' specified bound 16 equals destination size [-Wstringop-truncation]
  return __builtin_strncpy(p, q, size);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Moreover, strncpy assumes null-terminated source buffers, but thats
not the case here.
Unlike strlcpy, nla_strlcpy *does* pad the destination buffer
while also considering nla attribute size.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nfnetlink_acct.c
net/netfilter/nfnetlink_cthelper.c