summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorShigeru Yoshida <syoshida@redhat.com>2024-07-16 05:09:05 +0300
committerDavid S. Miller <davem@davemloft.net>2024-07-24 14:18:03 +0300
commitfa96c6baef1b5385e2f0c0677b32b3839e716076 (patch)
treebb7e227d24bc827c44f3adcb67b68452863160f3 /net
parent3ba359c0cd6eb5ea772125a7aededb4a2d516684 (diff)
downloadlinux-fa96c6baef1b5385e2f0c0677b32b3839e716076.tar.xz
tipc: Return non-zero value from tipc_udp_addr2str() on error
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: d0f91938bede ("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>
Diffstat (limited to 'net')
-rw-r--r--net/tipc/udp_media.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
index b849a3d133a0..439f75539977 100644
--- a/net/tipc/udp_media.c
+++ b/net/tipc/udp_media.c
@@ -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;
}