diff options
author | Pascal Obry <obry@adacore.com> | 2021-11-17 17:20:32 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-12-02 16:26:18 +0000 |
commit | 261d367a1019ed98f078709a762cea28f330d289 (patch) | |
tree | d3cd5b1fb594957fee184e724c323bd7f1edbffc /gcc/ada/libgnat | |
parent | 0ef5185a1556a419e16e61a5704fbc1a65e95e56 (diff) | |
download | gcc-261d367a1019ed98f078709a762cea28f330d289.zip gcc-261d367a1019ed98f078709a762cea28f330d289.tar.gz gcc-261d367a1019ed98f078709a762cea28f330d289.tar.bz2 |
[Ada] Fix possible memory corruption for hostnames longer than 1024 bytes
gcc/ada/
* libgnat/g-socket.ads (Max_Name_Length): Initialize with
NI_MAXHOST.
Diffstat (limited to 'gcc/ada/libgnat')
-rw-r--r-- | gcc/ada/libgnat/g-socket.ads | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/ada/libgnat/g-socket.ads b/gcc/ada/libgnat/g-socket.ads index 5254bb0..d4265a2 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 <netdb.h>. subtype Name_Index is Natural range 1 .. Max_Name_Length; |