- Timestamp:
- 08/03/08 15:34:27 (16 years ago)
- Location:
- trunk/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/range_list.c
r113 r116 18 18 */ 19 19 20 #include <stdio.h>21 20 #include <math.h> 22 21 #include "../include/range_list.h" … … 29 28 30 29 #if 0 30 #include <stdio.h> 31 31 static void range_list_print(const range_list* rl) 32 32 { -
trunk/lib/regfi.c
r113 r116 442 442 443 443 /******************************************************************* 444 TODO: not currently validating against max_size445 444 *******************************************************************/ 446 445 REGF_HASH_LIST* regfi_load_hashlist(REGF_FILE* file, uint32 offset, … … 463 462 464 463 ret_val->offset = offset; 464 if(cell_length > max_size) 465 { 466 if(strict) 467 return NULL; 468 cell_length = max_size & 0xFFFFFFF8; 469 } 465 470 ret_val->cell_size = cell_length; 466 471 … … 491 496 return NULL; 492 497 } 493 /* TODO: Not sure which should be authoritative, the number from the494 * 495 * 496 * 498 /* XXX: Not sure which should be authoritative, the number from the 499 * NK record, or the number in the hash list. Go with the larger 500 * of the two to ensure all keys are found. Note the length checks 501 * on the cell later ensure that there won't be any critical errors. 497 502 */ 498 503 if(num_keys < ret_val->num_keys) … … 565 570 566 571 ret_val->offset = offset; 567 /* TODO: is there a way to be more conservative (shorter) with568 * 572 /* XXX: Is there a way to be more conservative (shorter) with 573 * cell length when cell is unallocated? 569 574 */ 570 575 ret_val->cell_size = cell_length; … … 582 587 ret_val->magic[1] = sk_header[1]; 583 588 584 /* TODO: can additional validation be added here? */589 /* XXX: Can additional validation be added here? */ 585 590 ret_val->unknown_tag = SVAL(sk_header, 0x2); 586 591 ret_val->prev_sk_off = IVAL(sk_header, 0x4); … … 595 600 } 596 601 597 /* TODO: need to get rid of this, but currently the security descriptor602 /* XXX: need to get rid of this, but currently the security descriptor 598 603 * code depends on the ps structure. 599 604 */ … … 678 683 679 684 /****************************************************************************** 680 * If !strict, the list may contain NULLs and VK records may point to NULL data.685 * If !strict, the list may contain NULLs, VK records may point to NULL. 681 686 ******************************************************************************/ 682 687 REGF_VK_REC** regfi_load_valuelist(REGF_FILE* file, uint32 offset, … … 686 691 REGF_VK_REC** ret_val; 687 692 REGF_HBIN* hbin; 688 uint32 i, vk_offset, vk_max_length ;693 uint32 i, vk_offset, vk_max_length, usable_num_values; 689 694 uint32* voffsets; 690 695 691 696 if((num_values+1) * sizeof(uint32) > max_size) 692 return NULL; 693 694 /* TODO: For now, everything strict seems to make sense on this call. 695 * Maybe remove the parameter or use it for other things. 696 */ 697 voffsets = regfi_parse_valuelist(file, offset, num_values, true); 697 { 698 if(strict) 699 return NULL; 700 usable_num_values = max_size/sizeof(uint32) - sizeof(uint32); 701 } 702 else 703 usable_num_values = num_values; 704 705 voffsets = regfi_parse_valuelist(file, offset, usable_num_values, strict); 698 706 if(voffsets == NULL) 699 707 return NULL; … … 706 714 } 707 715 708 for(i=0; i < num_values; i++)716 for(i=0; i < usable_num_values; i++) 709 717 { 710 718 hbin = regfi_lookup_hbin(file, voffsets[i]); … … 739 747 740 748 /******************************************************************* 741 * TODO: Need to add full key caching using a742 * 749 * XXX: Need to add full key caching using a 750 * custom cache structure. 743 751 *******************************************************************/ 744 752 REGF_NK_REC* regfi_load_key(REGF_FILE* file, uint32 offset, bool strict) … … 800 808 if(strict) 801 809 { 802 free(nk); 803 /* TODO: need convenient way to free nk->values deeply in all cases. */ 810 regfi_key_free(nk); 804 811 return NULL; 805 812 } … … 815 822 if(nk->subkeys == NULL) 816 823 { 817 /* TODO: temporary hack to get around 'ri' records */824 /* XXX: Temporary hack to get around 'ri' records */ 818 825 nk->num_subkeys = 0; 819 826 } … … 1031 1038 } 1032 1039 1033 /* TODO: come up with a better secret. */ 1034 ret_val->sk_recs = lru_cache_create(127, 0xDEADBEEF, true); 1040 /* This secret isn't very secret, but we don't need a good one. This 1041 * secret is just designed to prevent someone from trying to blow our 1042 * caching and make things slow. 1043 */ 1044 ret_val->sk_recs = lru_cache_create(127, 0x15DEAD05^time(NULL) 1045 ^(getpid()<<16)^(getppid()<<8), 1046 true); 1035 1047 1036 1048 ret_val->f = fh; … … 1367 1379 1368 1380 /******************************************************************* 1369 * TODO: add way to return more detailed error information.1381 * XXX: Add way to return more detailed error information. 1370 1382 *******************************************************************/ 1371 1383 REGF_FILE* regfi_parse_regf(int fd, bool strict) … … 1441 1453 * along with it's associated cells. 1442 1454 *******************************************************************/ 1443 /* TODO: Need a way to return types of errors. Also need to free 1444 * the hbin/ps when an error occurs. 1455 /* XXX: Need a way to return types of errors. 1445 1456 */ 1446 1457 REGF_HBIN* regfi_parse_hbin(REGF_FILE* file, uint32 offset, bool strict) … … 1485 1496 * the end of the file. 1486 1497 */ 1487 /* TODO: This may need to be relaxed for dealing with 1488 * partial or corrupt files. */ 1498 /* XXX: This may need to be relaxed for dealing with 1499 * partial or corrupt files. 1500 */ 1489 1501 if((offset + hbin->block_size > file->file_length) 1490 1502 || (hbin->block_size & 0xFFFFF000) != hbin->block_size) … … 1515 1527 if((nk_header[0x0] != 'n') || (nk_header[0x1] != 'k')) 1516 1528 { 1517 /* TODO: deal with subkey-lists that reference other subkey-lists. */ 1529 /* XXX: Deal with subkey-lists that reference other subkey-lists 1530 * (e.g. 'ri' records). 1531 */ 1518 1532 return NULL; 1519 1533 } … … 1549 1563 ret_val->mtime.low = IVAL(nk_header, 0x4); 1550 1564 ret_val->mtime.high = IVAL(nk_header, 0x8); 1551 1565 /* If the key is unallocated and the MTIME is earlier than Jan 1, 1990 1566 * or later than Jan 1, 2290, we consider this a bad key. This helps 1567 * weed out some false positives during deleted data recovery. 1568 */ 1569 if(unalloc 1570 && ((ret_val->mtime.high < REGFI_MTIME_MIN_HIGH 1571 && ret_val->mtime.low < REGFI_MTIME_MIN_LOW) 1572 || (ret_val->mtime.high > REGFI_MTIME_MAX_HIGH 1573 && ret_val->mtime.low > REGFI_MTIME_MAX_LOW))) 1574 return NULL; 1575 1552 1576 ret_val->unknown1 = IVAL(nk_header, 0xC); 1553 1577 ret_val->parent_off = IVAL(nk_header, 0x10); … … 1559 1583 ret_val->values_off = IVAL(nk_header, 0x28); 1560 1584 ret_val->sk_off = IVAL(nk_header, 0x2C); 1561 /* TODO: currently we do nothing with class names. Need to investigate. */1585 /* XXX: currently we do nothing with class names. Need to investigate. */ 1562 1586 ret_val->classname_off = IVAL(nk_header, 0x30); 1563 1587 … … 1758 1782 if(cell_length - 4 < length) 1759 1783 { 1760 /* TODO: This strict condition has been triggered in multiple registries.1761 * 1762 * 1784 /* XXX: This strict condition has been triggered in multiple registries. 1785 * Not sure the cause, but the data length values are very large, 1786 * such as 53392. 1763 1787 */ 1764 1788 if(strict) … … 1768 1792 } 1769 1793 1770 /* TODO: There is currently no check to ensure the data1771 * 1794 /* XXX: There is currently no check to ensure the data 1795 * cell doesn't cross HBIN boundary. 1772 1796 */ 1773 1797 … … 1816 1840 1817 1841 if((cell_len == 0) || ((cell_len & 0xFFFFFFF8) != cell_len)) 1818 /* TODO: should report an error here. */1842 /* XXX: should report an error here. */ 1819 1843 break; 1820 1844
Note: See TracChangeset
for help on using the changeset viewer.