--- nmap/nping/utils.cc 2010-05-24 03:29:45.110203434 -0500 +++ nmap-my-branch/nping/utils.cc 2010-05-26 05:29:20.085931466 -0500 @@ -177,23 +177,33 @@ static u8 dst[16384]; size_t dstlen=16384; unsigned int i=0, j=0; + char *start=NULL; if(str==NULL || outlen==NULL) return NULL; - memset(auxbuff,0,1024); + /* This catches the empty string possibility "" */ + if(strlen(str) == 0) + return NULL; + + memset(auxbuff,0,1024); - char *start=NULL; /* String should be treated as a hex number in this format: 0xAABBCCDDEE... - * He process it the way it is specified, we don't perform byte order + * We process it the way it is specified, we don't perform byte order * conversions so if the users says 0x00AA we write dst[0]=0x00, dst[1]==0xAA * no matter the endianness of the host system. */ if( !strncmp("0x", str, 2) ){ + /* This catches the case of an empty "0x" */ + if(strlen(str) == 2) + return NULL; start=str+2; } /* String should be treated as list of hex char in this format: \x00\xFF\x0A*/ - else if( !strncmp("\\x", str, 1) ){ + else if( !strncmp("\\x", str, 2) ){ + /* This catches the case of an empty "\x" */ + if(strlen(str) == 2) + return NULL; /* Copy all interesting bytes to an aux array, discard "\x" */ for(i=0; i