]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Prepare inet_ntop to be fortified
authorFrédéric Bérat <fberat@redhat.com>
Fri, 7 Mar 2025 13:42:26 +0000 (14:42 +0100)
committerFrédéric Bérat <fberat@redhat.com>
Fri, 21 Mar 2025 08:35:16 +0000 (09:35 +0100)
Rename inet_ntop to __inet_ntop and create the inet_ntop weak alias
based on it in order to prepare for disabling fortification when
available.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
include/arpa/inet.h
nss/getnameinfo.c
resolv/inet_ntop.c

index df9472ba3bc526895337f8eddf9cc2b9a1269a10..d1ea13bb19d4a497d02619a27a1a073bee8d4e1e 100644 (file)
@@ -5,7 +5,9 @@
 extern int __inet_aton_exact (const char *__cp, struct in_addr *__inp);
 libc_hidden_proto (__inet_aton_exact)
 
-libc_hidden_proto (inet_ntop)
+extern __typeof (inet_ntop) __inet_ntop;
+libc_hidden_proto (__inet_ntop)
+
 libc_hidden_proto (inet_pton)
 extern __typeof (inet_pton) __inet_pton;
 libc_hidden_proto (__inet_pton)
index c3b46e712b0339c66ecd321c006d56f5f35d2f52..0db06c4ae8319c9b8e41ae5b4c224060f485d809 100644 (file)
@@ -338,7 +338,7 @@ gni_host_inet_numeric (struct scratch_buffer *tmpbuf,
   if (sa->sa_family == AF_INET6)
     {
       const struct sockaddr_in6 *sin6p = (const struct sockaddr_in6 *) sa;
-      if (inet_ntop (AF_INET6, &sin6p->sin6_addr, host, hostlen) == NULL)
+      if (__inet_ntop (AF_INET6, &sin6p->sin6_addr, host, hostlen) == NULL)
        return EAI_OVERFLOW;
 
       uint32_t scopeid = sin6p->sin6_scope_id;
@@ -365,7 +365,7 @@ gni_host_inet_numeric (struct scratch_buffer *tmpbuf,
   else
     {
       const struct sockaddr_in *sinp = (const struct sockaddr_in *) sa;
-      if (inet_ntop (AF_INET, &sinp->sin_addr, host, hostlen) == NULL)
+      if (__inet_ntop (AF_INET, &sinp->sin_addr, host, hostlen) == NULL)
        return EAI_OVERFLOW;
     }
   return 0;
index c4d38c0f951013e51a4fc6eaa8a9b82e146abe5a..acf5f3cb885e2e47262e77aacea1680266f6fafd 100644 (file)
@@ -42,7 +42,7 @@ static const char *inet_ntop4 (const u_char *src, char *dst, socklen_t size);
 static const char *inet_ntop6 (const u_char *src, char *dst, socklen_t size);
 
 /* char *
- * inet_ntop(af, src, dst, size)
+ * __inet_ntop(af, src, dst, size)
  *     convert a network format address to presentation format.
  * return:
  *     pointer to presentation format address (`dst'), or NULL (see errno).
@@ -50,7 +50,7 @@ static const char *inet_ntop6 (const u_char *src, char *dst, socklen_t size);
  *     Paul Vixie, 1996.
  */
 const char *
-inet_ntop (int af, const void *src, char *dst, socklen_t size)
+__inet_ntop (int af, const void *src, char *dst, socklen_t size)
 {
        switch (af) {
        case AF_INET:
@@ -63,7 +63,8 @@ inet_ntop (int af, const void *src, char *dst, socklen_t size)
        }
        /* NOTREACHED */
 }
-libc_hidden_def (inet_ntop)
+libc_hidden_def (__inet_ntop)
+weak_alias (__inet_ntop, inet_ntop)
 
 /* const char *
  * inet_ntop4(src, dst, size)