$OpenBSD: patch-config_c,v 1.1.1.1 2008/02/08 19:30:52 sthen Exp $ --- config.c.orig Tue May 24 16:49:29 2005 +++ config.c Fri Jan 25 14:05:44 2008 @@ -328,29 +328,18 @@ struct vifconfig *parsePhyintToken() { */ struct SubnetList *parseSubnetAddress(char *addrstr) { struct SubnetList *tmpSubnet; - char *tmpStr; uint32 addr = 0x00000000; uint32 mask = 0xFFFFFFFF; + int bitcnt; - // First get the network part of the address... - tmpStr = strtok(addrstr, "/"); - addr = inet_addr(tmpStr); - - tmpStr = strtok(NULL, "/"); - if(tmpStr != NULL) { - int bitcnt = atoi(tmpStr); - if(bitcnt <= 0 || bitcnt > 32) { - log(LOG_WARNING, 0, "The bits part of the address is invalid : %d.",tmpStr); - return NULL; - } - - mask <<= (32 - bitcnt); - } - - if(addr == -1 || addr == 0) { - log(LOG_WARNING, 0, "Unable to parse address token '%s'.", addrstr); + bitcnt = inet_net_pton(AF_INET, addrstr, &addr, sizeof(addr)); + if(bitcnt<0) { + log(LOG_WARNING, 0, "Unable to parse address token '%s'.",addrstr); return NULL; - } + } else if(bitcnt>0) + mask <<= (32 - bitcnt); + else + mask = 0; tmpSubnet = (struct SubnetList*) malloc(sizeof(struct SubnetList)); tmpSubnet->subnet_addr = addr;