| 6299 | } |
| 6300 | |
| 6301 | bool forceReadFileAddress(char *fileName) { |
| 6302 | /* Here we read the original file as usual */ |
| 6303 | FILE *fileDescriptor; |
| 6304 | bool validAddress; |
| 6305 | uint64_t numberItems,i; |
| 6306 | size_t r,raw_value_length; |
| 6307 | uint8_t rawvalue[50]; |
| 6308 | char aux[100],*hextemp; |
| 6309 | fileDescriptor = fopen(fileName,"r"); |
| 6310 | if(fileDescriptor == NULL) { |
| 6311 | fprintf(stderr,"[E] Error opening the file %s, line %i\n",fileName,__LINE__ - 2); |
| 6312 | return false; |
| 6313 | } |
| 6314 | |
| 6315 | /*Count lines in the file*/ |
| 6316 | numberItems = 0; |
| 6317 | while(!feof(fileDescriptor)) { |
| 6318 | hextemp = fgets(aux,100,fileDescriptor); |
| 6319 | trim(aux," \t\n\r"); |
| 6320 | if(hextemp == aux) { |
| 6321 | r = strlen(aux); |
| 6322 | if(r > 20) { |
| 6323 | numberItems++; |
| 6324 | } |
| 6325 | } |
| 6326 | } |
| 6327 | fseek(fileDescriptor,0,SEEK_SET); |
| 6328 | MAXLENGTHADDRESS = 20; /*20 bytes beacuase we only need the data in binary*/ |
| 6329 | |
| 6330 | printf("[+] Allocating memory for %" PRIu64 " elements: %.2f MB\n",numberItems,(double)(((double) sizeof(struct address_value)*numberItems)/(double)1048576)); |
| 6331 | addressTable = (struct address_value*) malloc(sizeof(struct address_value)*numberItems); |
| 6332 | checkpointer((void *)addressTable,__FILE__,"malloc","addressTable" ,__LINE__ -1 ); |
| 6333 | |
| 6334 | if(!initBloomFilter(&bloom,numberItems)) |
| 6335 | return false; |
| 6336 | |
| 6337 | i = 0; |
| 6338 | while(i < numberItems) { |
| 6339 | validAddress = false; |
| 6340 | memset(aux,0,100); |
| 6341 | memset(addressTable[i].value,0,sizeof(struct address_value)); |
| 6342 | hextemp = fgets(aux,100,fileDescriptor); |
| 6343 | trim(aux," \t\n\r"); |
| 6344 | r = strlen(aux); |
| 6345 | if(r > 0 && r <= 40) { |
| 6346 | if(r<40 && isValidBase58String(aux)) { //Address |
| 6347 | raw_value_length = 25; |
| 6348 | b58tobin(rawvalue,&raw_value_length,aux,r); |
| 6349 | if(raw_value_length == 25) { |
| 6350 | //hextemp = tohex((char*)rawvalue+1,20); |
| 6351 | bloom_add(&bloom, rawvalue+1 ,sizeof(struct address_value)); |
| 6352 | memcpy(addressTable[i].value,rawvalue+1,sizeof(struct address_value)); |
| 6353 | i++; |
| 6354 | validAddress = true; |
| 6355 | } |
| 6356 | } |
| 6357 | if(r == 40 && isValidHex(aux)) { //RMD |
| 6358 | hexs2bin(aux,rawvalue); |
no test coverage detected