]> Pileus Git - ~andy/fetchmail/commitdiff
Prevent buffer spamming.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 3 Sep 1997 15:45:21 +0000 (15:45 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 3 Sep 1997 15:45:21 +0000 (15:45 -0000)
svn path=/trunk/; revision=1279

socket.c

index 7a30e3a8b84bdc0c7a8fbec5edda26f23417c2ce..5fe0683c560a264b49024af12d40acf887c39a52 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -53,8 +53,14 @@ int SockOpen(char *host, int clientPort)
     else
     {
         hp = gethostbyname(host);
-        if (hp == NULL)
+
+       /*
+        * Add a check to make sure the address has a valid IPv4 or IPv6
+        * length.  This prevents buffer spamming by a broken DNS.
+        */
+        if (hp == NULL || (hp->h_length != 4 && hp->h_length != 8))
             return -1;
+
         memcpy(&ad.sin_addr, hp->h_addr, hp->h_length);
     }
     ad.sin_port = htons(clientPort);