]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Fix possible memory corruption for hostnames longer than 1024 bytes
authorPascal Obry <obry@adacore.com>
Wed, 17 Nov 2021 16:20:32 +0000 (17:20 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 2 Dec 2021 16:26:18 +0000 (16:26 +0000)
gcc/ada/

* libgnat/g-socket.ads (Max_Name_Length): Initialize with
NI_MAXHOST.

gcc/ada/libgnat/g-socket.ads

index 5254bb09807206dd6aa83ec8380babfafe4f38ba..d4265a2cb5b6285924096531beb392b986835120 100644 (file)
@@ -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 <netdb.h>.
 
    subtype Name_Index is Natural range 1 .. Max_Name_Length;