public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5719] [Ada] Fix possible memory corruption for hostnames longer than 1024 bytes
@ 2021-12-02 16:27 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-12-02 16:27 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:261d367a1019ed98f078709a762cea28f330d289

commit r12-5719-g261d367a1019ed98f078709a762cea28f330d289
Author: Pascal Obry <obry@adacore.com>
Date:   Wed Nov 17 17:20:32 2021 +0100

    [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:
---
 gcc/ada/libgnat/g-socket.ads | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/libgnat/g-socket.ads b/gcc/ada/libgnat/g-socket.ads
index 5254bb09807..d4265a2cb5b 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;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-02 16:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-02 16:27 [gcc r12-5719] [Ada] Fix possible memory corruption for hostnames longer than 1024 bytes Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).