Changeset 147 for trunk/lib/regfi.c
- Timestamp:
- 02/22/09 14:31:52 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/regfi.c
r146 r147 24 24 */ 25 25 26 #include " ../include/regfi.h"26 #include "regfi.h" 27 27 28 28 … … 762 762 763 763 764 /******************************************************************* 765 *******************************************************************/ 766 REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32 offset, uint32 max_size, bool strict) 764 /****************************************************************************** 765 * 766 ******************************************************************************/ 767 REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32 offset, uint32 max_size, 768 bool strict) 767 769 { 768 770 REGFI_SK_REC* ret_val; 769 uint8* sec_desc_buf ;771 uint8* sec_desc_buf = NULL; 770 772 uint32 cell_length, length; 771 /*prs_struct ps;*/772 773 uint8 sk_header[REGFI_SK_MIN_LENGTH]; 773 774 bool unalloc = false; … … 788 789 } 789 790 790 ret_val = (REGFI_SK_REC*)zalloc(sizeof(REGFI_SK_REC)); 791 /* ret_val = (REGFI_SK_REC*)zalloc(sizeof(REGFI_SK_REC));*/ 792 ret_val = talloc(NULL, REGFI_SK_REC); 791 793 if(ret_val == NULL) 792 794 return NULL; … … 805 807 regfi_add_message(file, REGFI_MSG_WARN, "Invalid cell size found while" 806 808 " parsing SK record at offset 0x%.8X.", offset); 807 free(ret_val); 808 return NULL; 809 goto fail; 809 810 } 810 811 … … 824 825 " are not a multiple of 8 while parsing SK record at" 825 826 " offset 0x%.8X.", offset); 826 free(ret_val); 827 return NULL; 827 goto fail; 828 828 } 829 829 … … 833 833 " cell while parsing SK record at offset 0x%.8X.", 834 834 offset); 835 free(ret_val); 836 return NULL; 837 } 838 839 sec_desc_buf = (uint8*)zalloc(ret_val->desc_size); 840 if(ret_val == NULL) 841 { 842 free(ret_val); 843 return NULL; 844 } 835 goto fail; 836 } 837 838 sec_desc_buf = (uint8*)malloc(ret_val->desc_size); 839 if(sec_desc_buf == NULL) 840 goto fail; 845 841 846 842 length = ret_val->desc_size; … … 851 847 " descriptor while parsing SK record at offset 0x%.8X.", 852 848 offset); 853 free(ret_val);854 return NULL;855 } 856 857 if(!(ret_val->sec_desc = winsec_parse_desc(sec_desc_buf,ret_val->desc_size)))849 goto fail; 850 } 851 852 if(!(ret_val->sec_desc = winsec_parse_desc(ret_val, sec_desc_buf, 853 ret_val->desc_size))) 858 854 { 859 855 regfi_add_message(file, REGFI_MSG_ERROR, "Failed to parse security" 860 856 " descriptor while parsing SK record at offset 0x%.8X.", 861 857 offset); 858 goto fail; 859 } 860 861 free(sec_desc_buf); 862 return ret_val; 863 864 fail: 865 if(sec_desc_buf != NULL) 862 866 free(sec_desc_buf); 863 free(ret_val); 864 return NULL; 865 } 866 free(sec_desc_buf); 867 868 869 return ret_val; 867 talloc_free(ret_val); 868 return NULL; 870 869 } 871 870 … … 1147 1146 const REGFI_HBIN* hbin; 1148 1147 uint32 max_length; 1149 1148 void* failure_ptr = NULL; 1149 1150 1150 /* First look if we have already parsed it */ 1151 1151 ret_val = (REGFI_SK_REC*)lru_cache_find(file->sk_cache, &offset, 4); … … 1165 1165 if(ret_val == NULL) 1166 1166 { /* Cache the parse failure and bail out. */ 1167 lru_cache_update(file->sk_cache, &offset, 4, (void*)REGFI_OFFSET_NONE); 1167 failure_ptr = talloc(NULL, uint32_t); 1168 if(failure_ptr == NULL) 1169 return NULL; 1170 *(uint32_t*)failure_ptr = REGFI_OFFSET_NONE; 1171 lru_cache_update(file->sk_cache, &offset, 4, failure_ptr); 1168 1172 return NULL; 1169 1173 } … … 1287 1291 1288 1292 /* Cache an unlimited number of SK records. Typically there are very few. */ 1289 rb->sk_cache = lru_cache_create (0, cache_secret, true);1293 rb->sk_cache = lru_cache_create_ctx(NULL, 0, cache_secret, true); 1290 1294 1291 1295 /* Default message mask */ … … 1314 1318 range_list_free(file->hbins); 1315 1319 1320 1316 1321 if(file->sk_cache != NULL) 1317 1322 lru_cache_destroy(file->sk_cache);
Note: See TracChangeset
for help on using the changeset viewer.