- Timestamp:
- 04/29/08 16:38:27 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/regfi.c
r108 r109 681 681 682 682 683 683 684 /******************************************************************* 684 685 static REGF_SK_REC* find_sk_record_by_sec_desc( REGF_FILE *file, SEC_DESC *sd ) 686 { 687 REGF_SK_REC *p; 688 689 for ( p=file->sec_desc_list; p; p=p->next ) { 690 if ( sec_desc_equal( p->sec_desc, sd ) ) 691 return p; 692 } 693 694 695 return NULL; 696 } 697 *******************************************************************/ 698 699 /******************************************************************* 700 * TODO: Need to add full key and SK record caching using a 685 * TODO: Need to add full key caching using a 701 686 * custom cache structure. 702 687 *******************************************************************/ 703 REGF_NK_REC* regfi_load_key(REGF_FILE *file, uint32 offset, bool strict)688 REGF_NK_REC* regfi_load_key(REGF_FILE* file, uint32 offset, bool strict) 704 689 { 705 690 REGF_HBIN* hbin; … … 780 765 } 781 766 782 /* get the security descriptor. First look if we have already parsed it */783 if((nk->sk_off!=REGF_OFFSET_NONE)784 && !(nk->sec_desc = (REGF_SK_REC*)lru_cache_find(file->sk_recs,785 &nk->sk_off, 4)))786 {787 sub_hbin = hbin;788 if(!regfi_offset_in_hbin(hbin, nk->sk_off))789 sub_hbin = regfi_lookup_hbin(file, nk->sk_off);790 791 if(sub_hbin == NULL)792 {793 free(nk);794 /* TODO: need convenient way to free nk->values and nk->subkeys deeply795 * in all cases.796 */797 return NULL;798 }799 800 off = nk->sk_off + REGF_BLOCKSIZE;801 max_length = sub_hbin->block_size + sub_hbin->file_off - off;802 nk->sec_desc = regfi_parse_sk(file, off, max_length, true);803 if(strict && nk->sec_desc == NULL)804 {805 free(nk);806 /* TODO: need convenient way to free nk->values and nk->subkeys deeply807 * in all cases.808 */809 return NULL;810 }811 nk->sec_desc->sk_off = nk->sk_off;812 813 lru_cache_update(file->sk_recs, &nk->sk_off, 4, nk->sec_desc);814 }815 816 767 return nk; 817 768 } … … 903 854 } 904 855 905 /* TODO: come up with a better secret. */906 rb->sk_recs = lru_cache_create(127, 0xDEADBEEF, true);907 908 856 rla = true; 909 857 hbin_off = REGF_BLOCKSIZE; … … 942 890 range_list_free(file->unalloc_cells); 943 891 944 lru_cache_destroy(file->sk_recs);945 946 892 free(file); 947 893 … … 1038 984 } 1039 985 986 /* TODO: come up with a better secret. */ 987 ret_val->sk_recs = lru_cache_create(127, 0xDEADBEEF, true); 988 1040 989 ret_val->f = fh; 1041 990 ret_val->cur_key = root; … … 1062 1011 } 1063 1012 1013 lru_cache_destroy(i->sk_recs); 1014 1064 1015 free(i); 1065 1016 } … … 1201 1152 return i->cur_key; 1202 1153 } 1154 1155 1156 /****************************************************************************** 1157 *****************************************************************************/ 1158 const REGF_SK_REC* regfi_iterator_cur_sk(REGFI_ITERATOR* i) 1159 { 1160 REGF_SK_REC* ret_val; 1161 REGF_HBIN* hbin; 1162 uint32 max_length, off; 1163 1164 if(i->cur_key == NULL) 1165 return NULL; 1166 1167 /* First look if we have already parsed it */ 1168 if((i->cur_key->sk_off!=REGF_OFFSET_NONE) 1169 && !(ret_val =(REGF_SK_REC*)lru_cache_find(i->sk_recs, 1170 &i->cur_key->sk_off, 4))) 1171 { 1172 hbin = regfi_lookup_hbin(i->f, i->cur_key->sk_off); 1173 1174 if(hbin == NULL) 1175 return NULL; 1176 1177 off = i->cur_key->sk_off + REGF_BLOCKSIZE; 1178 max_length = hbin->block_size + hbin->file_off - off; 1179 ret_val = regfi_parse_sk(i->f, off, max_length, true); 1180 if(ret_val == NULL) 1181 return NULL; 1182 1183 ret_val->sk_off = i->cur_key->sk_off; 1184 lru_cache_update(i->sk_recs, &i->cur_key->sk_off, 4, ret_val); 1185 } 1186 1187 return ret_val; 1188 } 1189 1203 1190 1204 1191
Note: See TracChangeset
for help on using the changeset viewer.