- } else if (foundslash) {
- /* If we found a slash (/), this can only be a CIDR ban */
- /* However, it might be broken, so we need to retain the exact string
- * to track it accurately */
- cbp->host=getsstring(&mask[i+1],HOSTLEN);
- if ((notip || dotcount!=3) && !foundwild) {
- cbp->flags |= (CHANBAN_INVALID | CHANBAN_HOSTEXACT);
- } else if (foundwild) {
- cbp->flags |= (CHANBAN_INVALID | CHANBAN_HOSTMASK);
- } else {
- unsigned int a,b,c,d,l;
- /* CIDR bans have to match this pattern. */
- if ((sscanf(&mask[i+1], "%u.%u.%u.%u/%u",&a,&b,&c,&d,&l) != 5) ||
- (a>255) || (b>255) || (c>255) || (d>255) || (l>32) ) {
- cbp->flags |= (CHANBAN_HOSTEXACT | CHANBAN_INVALID);
- } else {
- /* Save the IP address and mask for later */
- cbp->ipaddr=(a<<24)|(b<<16)|(c<<8)|d;
- cbp->mask=0xffffffff;
- if (l==0) {
- cbp->mask=0;
- } else if (l<32) {
- cbp->mask<<=(32-l);
- }
- /* pre-AND the IP with the mask here. */
- cbp->ipaddr &= cbp->mask;
- cbp->flags |= (CHANBAN_HOSTEXACT | CHANBAN_CIDR);
- }
- }