]> git.baikalelectronics.ru Git - kernel.git/commit
Modify return value of nla_strlcpy to match that of strscpy.
authorFrancis Laniel <laniel_francis@privacyrequired.com>
Sun, 15 Nov 2020 17:08:05 +0000 (18:08 +0100)
committerJakub Kicinski <kuba@kernel.org>
Mon, 16 Nov 2020 16:08:54 +0000 (08:08 -0800)
commit4f6aff231107a3bd848aee75fd5d57bc4a316fcd
tree89d5f226138c49fdd1bfd2116b28b2b469357280
parent403e32a08d46f574c97d97aab1f44664757f9aff
Modify return value of nla_strlcpy to match that of strscpy.

nla_strlcpy now returns -E2BIG if src was truncated when written to dst.
It also returns this error value if dstsize is 0 or higher than INT_MAX.

For example, if src is "foo\0" and dst is 3 bytes long, the result will be:
1. "foG" after memcpy (G means garbage).
2. "fo\0" after memset.
3. -E2BIG is returned because src was not completely written into dst.

The callers of nla_strlcpy were modified to take into account this modification.

Signed-off-by: Francis Laniel <laniel_francis@privacyrequired.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/netlink.h
include/net/pkt_cls.h
lib/nlattr.c
net/sched/act_api.c
net/sched/cls_api.c
net/sched/sch_api.c