Changeset 1205

Show
Ignore:
Timestamp:
03/04/10 08:40:57 (2 years ago)
Author:
Gary
Message:

unxsBind AAAA input validation in progress.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/unxsBind/tresourcefunc.h

    r1204 r1205  
    208208                unsigned h7=0; 
    209209                unsigned h8=0; 
     210                char *cp; 
    210211 
    211212                //Insure these are empty 
     
    214215                if(!strcmp(cZone+strlen(cZone)-5,".arpa")) 
    215216                        tResource("Can not add AAAA records to arpa zones"); 
    216                 sscanf(cParam1,"%x:%x:%x:%x:%x:%x:%x:%x",&h1,&h2,&h3,&h4,&h5,&h6,&h7,&h8); 
     217 
     218                //This is not going to work for all cases. 
     219                //if cParam1 has no consecutive colons 
     220                if(!(cp=strstr(cParam1,"::"))) 
     221                { 
     222                        sscanf(cParam1,"%x:%x:%x:%x:%x:%x:%x:%x",&h1,&h2,&h3,&h4,&h5,&h6,&h7,&h8); 
     223                } 
     224                else 
     225                { 
     226                        unsigned uPos=0; 
     227 
     228                        if(strstr(cp+2,"::")) 
     229                        { 
     230                                guMode=uMode; 
     231                                tResource("IPv6 number can not have more than one double colons."); 
     232                        } 
     233 
     234                        uPos=sscanf(cParam1,"%x:%x:%x:%x:%x:%x:%x:%x",&h1,&h2,&h3,&h4,&h5,&h6,&h7,&h8); 
     235                        //All first position cases, i.e. 2,3,4,5 and 6 word cases 
     236                        if(uPos==1) 
     237                        { 
     238                                uPos=sscanf(cParam1,"%x::%x:%x:%x:%x:%x:%x",&h1, &h3,&h4,&h5,&h6,&h7,&h8); 
     239                                if(uPos==2) 
     240                                        uPos=sscanf(cParam1,"%x:%x::%x:%x:%x:%x:%x",&h1,&h2, &h4,&h5,&h6,&h7,&h8); 
     241                        } 
     242                                 
     243                } 
    217244 
    218245                //Leading 0's. Done via sprintf below. 
     
    228255                { 
    229256                        guMode=uMode; 
    230                         tResource("IPv6 number can not have a 0 in last 16 bit hex word."); 
     257                        sprintf(gcQuery," IPv6 number can not have a 0 in last 16 bit hex word:" 
     258                                        " %x:%x:%x:%x:%x:%x:%x:%x",h1,h2,h3,h4,h5,h6,h7,h8); 
     259                        tResource(gcQuery); 
    231260                } 
    232261