]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
inet: Implement inet_ntoa on top of inet_ntop
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 4 Jun 2025 20:42:44 +0000 (17:42 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 24 Jun 2025 16:34:20 +0000 (13:34 -0300)
Checked on aarch64-linux-gnu and x86_64-linux-gnu.
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
inet/inet_ntoa.c

index a4543f630dee438729bb53c9586650543da5c67e..2efd24ef18e676befb9b1fe94b4a1c564062624d 100644 (file)
 /* The interface of this function is completely stupid, it requires a
    static buffer.  We relax this a bit in that we allow one buffer for
    each thread.  */
-static __thread char buffer[18];
+static __thread char buffer[INET_ADDRSTRLEN];
 
 
 char *
 inet_ntoa (struct in_addr in)
 {
-  unsigned char *bytes = (unsigned char *) &in;
-  __snprintf (buffer, sizeof (buffer), "%d.%d.%d.%d",
-             bytes[0], bytes[1], bytes[2], bytes[3]);
-
+  __inet_ntop (AF_INET, &in, buffer, sizeof buffer);
   return buffer;
 }