windows-config-ipaddr-parsing-20081106
authorJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 6 Nov 2008 22:09:05 +0000 (22:09 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 6 Nov 2008 22:09:05 +0000 (22:09 +0000)
LICENSE MIT

when parsing ipaddrs in CellServDB rejects addrs whose components are
values greater than 255.

src/WINNT/afsd/cm_config.c

index 5fbaf70..b15f973 100644 (file)
@@ -299,16 +299,16 @@ long cm_SearchCellFileEx(char *cellNamep, char *newCellNamep,
                }
                 if (!thp) {
                     afs_uint32 ip_addr;
-                   int c1, c2, c3, c4;
+                   unsigned int c1, c2, c3, c4;
                     
                     /* Since there is no gethostbyname() data 
                     * available we will read the IP address
                     * stored in the CellServDB file
                      */
-                    code = sscanf(lineBuffer, " %d.%d.%d.%d",
+                    code = sscanf(lineBuffer, " %u.%u.%u.%u",
                                    &c1, &c2, &c3, &c4);
-                    if (code == 4) {
-                        tp = (char *) &ip_addr;
+                    if (code == 4 && c1<256 && c2<256 && c3<256 && c4<256) {
+                        tp = (unsigned char *) &ip_addr;
                         *tp++ = c1;
                         *tp++ = c2;
                         *tp++ = c3;