]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
tipc: Return non-zero value from tipc_udp_addr2str() on error
authorShigeru Yoshida <syoshida@redhat.com>
Tue, 16 Jul 2024 02:09:05 +0000 (11:09 +0900)
committerDavid S. Miller <davem@davemloft.net>
Wed, 24 Jul 2024 11:18:03 +0000 (12:18 +0100)
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>
net/tipc/udp_media.c

index b849a3d133a01cffe2b6edab7cff17fab37a8eb0..439f7553997728ae8d264d370178f5bdd8b7aaf8 100644 (file)
@@ -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;
 }