mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-14 07:44:21 +08:00
tipc: Return non-zero value from tipc_udp_addr2str() on error
[ Upstream commitfa96c6baef
] tipc_udp_addr2str() should return non-zero value if the UDP media address is invalid. Otherwise, a buffer overflow access can occur in tipc_media_addr_printf(). Fix this by returning 1 on an invalid UDP media address. Fixes:d0f91938be
("tipc: add ip/udp media type") Signed-off-by: Shigeru Yoshida <syoshida@redhat.com> Reviewed-by: Tung Nguyen <tung.q.nguyen@endava.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
b90d2b3f17
commit
5eea127675
@ -135,8 +135,11 @@ static int tipc_udp_addr2str(struct tipc_media_addr *a, char *buf, int size)
|
||||
snprintf(buf, size, "%pI4:%u", &ua->ipv4, ntohs(ua->port));
|
||||
else if (ntohs(ua->proto) == ETH_P_IPV6)
|
||||
snprintf(buf, size, "%pI6:%u", &ua->ipv6, ntohs(ua->port));
|
||||
else
|
||||
else {
|
||||
pr_err("Invalid UDP media address\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user