- Timestamp:
- 05/04/08 14:29:02 (17 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/range_list.h
r106 r113 176 176 bool range_list_split_element(range_list* rl, uint32_t index, uint32_t offset); 177 177 178 179 /* range_list_has_range(): 180 * Determines whether or not a specified range exists contiguously within the 181 * range_list. 182 * 183 * Arguments: 184 * rl -- the range_list to search 185 * start -- the offset at the beginning of the range 186 * length -- the length of the range 187 * 188 * Returns: 189 * true if the specified range exists and is complete, false otherwise. 190 */ 191 bool range_list_has_range(range_list* rl, uint32_t start, uint32_t length); 192 178 193 #endif -
trunk/lib/range_list.c
r111 r113 320 320 return true; 321 321 } 322 323 324 bool range_list_has_range(range_list* rl, uint32_t start, uint32_t length) 325 { 326 int32_t idx1, idx2; 327 328 idx1 = range_list_find(rl, start); 329 if(idx1 < 0) 330 return false; 331 332 idx2 = range_list_find(rl, start+length); 333 if(idx2 < 0) 334 return false; 335 336 if(idx1 == idx2) 337 return true; 338 339 while(idx1 != idx2) 340 { 341 if(rl->elements[idx1]->offset + rl->elements[idx1]->length 342 != rl->elements[idx1+1]->offset) 343 return false; 344 idx1++; 345 } 346 347 return true; 348 } -
trunk/lib/regfi.c
r111 r113 1665 1665 if(ret_val->flag & VK_FLAG_NAME_PRESENT) 1666 1666 { 1667 if(ret_val->name_length + REGFI_VK_MIN_LENGTH > ret_val->cell_size)1667 if(ret_val->name_length + REGFI_VK_MIN_LENGTH + 4 > ret_val->cell_size) 1668 1668 { 1669 1669 if(strict) … … 1673 1673 } 1674 1674 else 1675 ret_val->name_length = ret_val->cell_size - REGFI_VK_MIN_LENGTH ;1675 ret_val->name_length = ret_val->cell_size - REGFI_VK_MIN_LENGTH - 4; 1676 1676 } 1677 1677 1678 1678 /* Round up to the next multiple of 8 */ 1679 length = (ret_val->name_length + REGFI_NK_MIN_LENGTH) & 0xFFFFFFF8;1680 if( length < ret_val->name_length + REGFI_NK_MIN_LENGTH)1681 length+=8;1679 cell_length = (ret_val->name_length + REGFI_VK_MIN_LENGTH + 4) & 0xFFFFFFF8; 1680 if(cell_length < ret_val->name_length + REGFI_VK_MIN_LENGTH + 4) 1681 cell_length+=8; 1682 1682 1683 1683 ret_val->valuename = (char*)zalloc(sizeof(char)*(ret_val->name_length+1)); … … 1687 1687 return NULL; 1688 1688 } 1689 1690 /* Don't need to seek, should be at the right offset */ 1689 1691 1690 length = ret_val->name_length; 1692 1691 if((regfi_read(file->fd, (uint8*)ret_val->valuename, &length) != 0) … … 1700 1699 } 1701 1700 else 1702 length = REGFI_VK_MIN_LENGTH;1701 cell_length = REGFI_VK_MIN_LENGTH + 4; 1703 1702 1704 1703 if(unalloc) 1705 1704 { 1706 1705 /* If cell_size is still greater, truncate. */ 1707 if( length < ret_val->cell_size)1708 ret_val->cell_size = length;1706 if(cell_length < ret_val->cell_size) 1707 ret_val->cell_size = cell_length; 1709 1708 } 1710 1709 … … 1816 1815 break; 1817 1816 1818 if((cell_len == 0) || ((cell_len & 0xFFFFFFF C) != cell_len))1817 if((cell_len == 0) || ((cell_len & 0xFFFFFFF8) != cell_len)) 1819 1818 /* TODO: should report an error here. */ 1820 1819 break; -
trunk/src/reglookup-recover.c
r112 r113 418 418 419 419 420 bool removeRange(range_list* rl, uint32 rm_idx, uint32 offset, uint32 length) 421 { 422 const range_list_element* cur_elem = range_list_get(rl, rm_idx); 423 420 bool removeRange(range_list* rl, uint32 offset, uint32 length) 421 { 422 int32 rm_idx; 423 const range_list_element* cur_elem; 424 425 rm_idx = range_list_find(rl, offset); 426 if(rm_idx < 0) 427 return false; 428 429 cur_elem = range_list_get(rl, rm_idx); 424 430 if(cur_elem == NULL) 425 431 { … … 481 487 } 482 488 483 if(!removeRange(unalloc_cells, i,key->offset, key->cell_size))489 if(!removeRange(unalloc_cells, key->offset, key->cell_size)) 484 490 return 30; 485 491 } … … 499 505 const range_list_element* cur_elem; 500 506 uint32 i, j, num_keys, off, values_length, max_length; 501 int32 idx;502 507 503 508 num_keys=range_list_size(unalloc_keys); … … 529 534 if(nk->values != NULL) 530 535 { 531 idx = range_list_find(unalloc_cells, off); 532 if(idx < 0) 536 if(!range_list_has_range(unalloc_cells, off, nk->cell_size)) 533 537 { /* We've parsed a values-list which isn't in the unallocated list, 534 538 * so prune it. … … 553 557 if(values_length != (values_length & 0xFFFFFFF8)) 554 558 values_length = (values_length & 0xFFFFFFF8) + 8; 555 if(!removeRange(unalloc_cells, idx, off, values_length)) 559 560 if(!removeRange(unalloc_cells, off, values_length)) 556 561 return 20; 557 562 … … 560 565 if(nk->values[j] != NULL) 561 566 { 562 i dx = range_list_find(unalloc_cells, nk->values[j]->offset);563 if(idx < 0)567 if(!range_list_has_range(unalloc_cells, nk->values[j]->offset, 568 nk->values[j]->cell_size)) 564 569 { /* We've parsed a value which isn't in the unallocated list, 565 570 * so prune it. … … 575 580 * and inspect data. 576 581 */ 577 if(!removeRange(unalloc_cells, idx,nk->values[j]->offset,582 if(!removeRange(unalloc_cells, nk->values[j]->offset, 578 583 nk->values[j]->cell_size)) 579 584 return 21; 580 585 581 586 /* Don't bother pruning or removing from unalloc_cells if 582 * there is no data, if it is storedthe offset.587 * there is no data, or it is stored in the offset. 583 588 */ 584 589 if(nk->values[j]->data != NULL && !nk->values[j]->data_in_offset) 585 590 { 586 591 off = nk->values[j]->data_off+REGF_BLOCKSIZE; 587 i dx = range_list_find(unalloc_cells, off);588 if(idx < 0)592 if(!range_list_has_range(unalloc_cells, off, 593 nk->values[j]->data_size)) 589 594 { /* We've parsed a data cell which isn't in the unallocated 590 595 * list, so prune it. … … 595 600 else 596 601 { /*A data record was recovered. Remove from unalloc_cells.*/ 597 if(!removeRange(unalloc_cells, idx, off,602 if(!removeRange(unalloc_cells, off, 598 603 nk->values[j]->data_size)) 599 604 return 22; … … 638 643 } 639 644 640 if(!removeRange(unalloc_cells, i,vk->offset, vk->cell_size))645 if(!removeRange(unalloc_cells, vk->offset, vk->cell_size)) 641 646 return 30; 642 647 } … … 672 677 } 673 678 674 if(!removeRange(unalloc_cells, i,sk->offset, sk->cell_size))679 if(!removeRange(unalloc_cells, sk->offset, sk->cell_size)) 675 680 return 30; 676 681 }
Note: See TracChangeset
for help on using the changeset viewer.