From: Pascal Obry Date: Wed, 17 Nov 2021 16:20:32 +0000 (+0100) Subject: [Ada] Fix possible memory corruption for hostnames longer than 1024 bytes X-Git-Tag: basepoints/gcc-13~2594 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=261d367a1019ed98f078709a762cea28f330d289;p=thirdparty%2Fgcc.git [Ada] Fix possible memory corruption for hostnames longer than 1024 bytes gcc/ada/ * libgnat/g-socket.ads (Max_Name_Length): Initialize with NI_MAXHOST. --- diff --git a/gcc/ada/libgnat/g-socket.ads b/gcc/ada/libgnat/g-socket.ads index 5254bb098072..d4265a2cb5b6 100644 --- a/gcc/ada/libgnat/g-socket.ads +++ b/gcc/ada/libgnat/g-socket.ads @@ -1558,8 +1558,10 @@ private No_Sock_Addr : constant Sock_Addr_Type := (Family_Inet, No_Inet_Addr, 0); - Max_Name_Length : constant := 64; - -- The constant MAXHOSTNAMELEN is usually set to 64 + Max_Name_Length : constant := SOSC.NI_MAXHOST; + -- Most systems don't provide constants that specify the maximum size + -- of either a FQDN or a service name. In order to aid applications in + -- allocating buffers, the constant NI_MAXHOST is defined in . subtype Name_Index is Natural range 1 .. Max_Name_Length;