mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 21:33:52 +00:00
net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr()
[ Upstream commitd6f4de70f7
] The intent is to check if the strings' are truncated or not. So, >= should be used instead of >, because strlcat() and snprintf() return the length of the output, excluding the trailing NULL. Fixes:a02d692611
("SUNRPC: Provide functions for managing universal addresses") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Benjamin Coddington <bcodding@redhat.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
8ede73123c
commit
8c0fe010cb
1 changed files with 2 additions and 2 deletions
|
@ -284,10 +284,10 @@ char *rpc_sockaddr2uaddr(const struct sockaddr *sap, gfp_t gfp_flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snprintf(portbuf, sizeof(portbuf),
|
if (snprintf(portbuf, sizeof(portbuf),
|
||||||
".%u.%u", port >> 8, port & 0xff) > (int)sizeof(portbuf))
|
".%u.%u", port >> 8, port & 0xff) >= (int)sizeof(portbuf))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (strlcat(addrbuf, portbuf, sizeof(addrbuf)) > sizeof(addrbuf))
|
if (strlcat(addrbuf, portbuf, sizeof(addrbuf)) >= sizeof(addrbuf))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return kstrdup(addrbuf, gfp_flags);
|
return kstrdup(addrbuf, gfp_flags);
|
||||||
|
|
Loading…
Reference in a new issue