Changeset 148
- Timestamp:
- 02/22/09 18:22:59 (16 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/range_list.h
r122 r148 1 1 /* 2 * Copyright (C) 2008 Timothy D. Morgan2 * Copyright (C) 2008-2009 Timothy D. Morgan 3 3 * 4 4 * This program is free software; you can redistribute it and/or modify … … 18 18 */ 19 19 20 #ifndef _RANGE_LIST_H 21 #define _RANGE_LIST_H 22 20 23 #include <stdlib.h> 21 24 #include <stdbool.h> 22 25 #include <stdint.h> 23 26 #include <string.h> 24 25 #ifndef _RANGE_LIST_H 26 #define _RANGE_LIST_H 27 27 #include <math.h> 28 #include "talloc.h" 28 29 29 30 typedef struct _range_list_element -
trunk/include/winsec.h
r147 r148 54 54 #define WINSEC_ACE_MIN_SIZE 16 55 55 56 /* TODO: Fill in definitions of other flags */57 /* This means offsets contained in the descriptor are relative to the58 * descriptor's offset. This had better be true in the registry.56 /* XXX: Fill in definitions of other flags */ 57 /* This self relative flag means offsets contained in the descriptor are relative 58 * to the descriptor's offset. This had better be true in the registry. 59 59 */ 60 60 #define WINSEC_DESC_SELF_RELATIVE 0x8000 … … 70 70 71 71 72 typedef struct _winsec_uuid 72 typedef struct _winsec_uuid 73 73 { 74 74 uint32 time_low; -
trunk/lib/range_list.c
r147 r148 18 18 */ 19 19 20 #include <math.h>21 20 #include "range_list.h" 22 21 … … 27 26 #define RANGE_LIST_ALLOC_SIZE 256 28 27 29 #if 0 28 #if 0 /* For debugging */ 30 29 #include <stdio.h> 31 30 static void range_list_print(const range_list* rl) … … 53 52 if(rl->size == rl->elem_alloced) 54 53 { 55 tmp = (range_list_element**)realloc(rl->elements, 56 (rl->elem_alloced+RANGE_LIST_ALLOC_SIZE) 57 * sizeof(range_list_element*)); 54 tmp = talloc_realloc(rl, rl->elements, range_list_element*, 55 (rl->elem_alloced+RANGE_LIST_ALLOC_SIZE)); 58 56 if(tmp == NULL) 59 57 return false; … … 125 123 range_list* rl; 126 124 127 rl = (range_list*)malloc(sizeof(range_list));125 rl = talloc(NULL, range_list); 128 126 if(rl == NULL) 129 127 return NULL; 130 128 131 rl->elements = (range_list_element**)malloc(sizeof(range_list_element*) 132 * RANGE_LIST_ALLOC_SIZE); 133 129 rl->elements = talloc_array(rl, range_list_element*, RANGE_LIST_ALLOC_SIZE); 134 130 if(rl->elements == NULL) 135 131 { 136 free(rl);132 talloc_free(rl); 137 133 return NULL; 138 134 } … … 147 143 void range_list_free(range_list* rl) 148 144 { 149 uint32_t i;150 151 145 if(rl == NULL) 152 146 return; 153 147 154 for(i=0; i < rl->size; i++) 155 free(rl->elements[i]); 156 157 free(rl->elements); 158 free(rl); 148 talloc_free(rl); 159 149 } 160 150 … … 201 191 return false; 202 192 203 elem = (range_list_element*)malloc(sizeof(range_list_element));193 elem = talloc(rl->elements, range_list_element); 204 194 if(elem == NULL) 205 195 return false; … … 210 200 if(!range_list_insert(rl, elem, insert_index)) 211 201 { 212 free(elem);202 talloc_free(elem); 213 203 return false; 214 204 } … … 226 216 return false; 227 217 228 free(rl->elements[index]);218 talloc_free(rl->elements[index]); 229 219 230 220 /* Do the shuffle to the left. */ … … 237 227 if(rl->size + 2 * RANGE_LIST_ALLOC_SIZE < rl->elem_alloced) 238 228 { 239 tmp = (range_list_element**)realloc(rl->elements, 240 (rl->elem_alloced-2*RANGE_LIST_ALLOC_SIZE) 241 * sizeof(range_list_element*)); 229 tmp = talloc_realloc(rl, rl->elements, range_list_element*, 230 (rl->elem_alloced-2*RANGE_LIST_ALLOC_SIZE)); 242 231 if(tmp != NULL) 243 232 { … … 305 294 return false; 306 295 307 new_elem = (range_list_element*)malloc(sizeof(range_list_element));296 new_elem = talloc(rl->elements, range_list_element); 308 297 if(new_elem == NULL) 309 298 return false; … … 315 304 if(!range_list_insert(rl, new_elem, index+1)) 316 305 { 317 free(new_elem);306 talloc_free(new_elem); 318 307 return false; 319 308 } -
trunk/lib/regfi.c
r147 r148 343 343 { 344 344 ret_val = tmp_val; 345 size += s nprintf(ret_val+size, extra, "%s%s%c%s%c%s%c%s",346 347 348 349 345 size += sprintf(ret_val+size, "%s%s%c%s%c%s%c%s", 346 ace_delim,sid_str, 347 field_delim,type_str, 348 field_delim,perms_str, 349 field_delim,flags_str); 350 350 ace_delim = "|"; 351 351 } … … 1279 1279 { 1280 1280 rla = range_list_add(rb->hbins, hbin->file_off, hbin->block_size, hbin); 1281 if(rla) 1282 talloc_steal(rb->hbins, hbin); 1281 1283 hbin_off = hbin->file_off + hbin->block_size; 1282 1284 hbin = regfi_parse_hbin(rb, hbin_off, true); 1283 1285 } 1284 1285 1286 1286 1287 /* This secret isn't very secret, but we don't need a good one. This … … 1301 1302 1302 1303 1303 /******************************************************************* 1304 ******************************************************************* /1304 /****************************************************************************** 1305 ******************************************************************************/ 1305 1306 int regfi_close(REGFI_FILE *file) 1306 1307 { 1307 1308 int fd; 1308 uint32 i;1309 1309 1310 1310 /* nothing to do if there is no open file */ … … 1314 1314 fd = file->fd; 1315 1315 file->fd = -1; 1316 for(i=0; i < range_list_size(file->hbins); i++) 1317 free(range_list_get(file->hbins, i)->data); 1316 1318 1317 range_list_free(file->hbins); 1319 1318 1320 1321 1319 if(file->sk_cache != NULL) 1322 1320 lru_cache_destroy(file->sk_cache); 1321 1323 1322 free(file); 1324 1325 1323 return close(fd); 1326 1324 } … … 1330 1328 * There should be only *one* root key in the registry file based 1331 1329 * on my experience. --jerry 1332 ***************************************************************************** /1330 ******************************************************************************/ 1333 1331 REGFI_NK_REC* regfi_rootkey(REGFI_FILE *file) 1334 1332 { … … 1791 1789 1792 1790 1793 /******************************************************************* 1791 /****************************************************************************** 1794 1792 * Given real file offset, read and parse the hbin at that location 1795 1793 * along with it's associated cells. 1796 *******************************************************************/ 1797 /* XXX: Need a way to return types of errors. 1798 */ 1794 ******************************************************************************/ 1799 1795 REGFI_HBIN* regfi_parse_hbin(REGFI_FILE* file, uint32 offset, bool strict) 1800 1796 { … … 1825 1821 } 1826 1822 1827 if(!(hbin = (REGFI_HBIN*)zalloc(sizeof(REGFI_HBIN)))) 1823 hbin = talloc(NULL, REGFI_HBIN); 1824 if(hbin == NULL) 1828 1825 return NULL; 1829 1826 hbin->file_off = offset; … … 1836 1833 " 0x%.8X.", hbin->magic[0], hbin->magic[1], 1837 1834 hbin->magic[2], hbin->magic[3], offset); 1838 free(hbin);1835 talloc_free(hbin); 1839 1836 return NULL; 1840 1837 } … … 1858 1855 " or runs off the end of the file" 1859 1856 " while parsing hbin at offset 0x%.8X.", offset); 1860 free(hbin);1857 talloc_free(hbin); 1861 1858 return NULL; 1862 1859 } -
trunk/lib/winsec.c
r147 r148 55 55 if (buf == NULL || buf_len < WINSEC_DESC_HEADER_SIZE) 56 56 return NULL; 57 /* 58 if((ret_val = (WINSEC_DESC*)zalloc(sizeof(WINSEC_DESC))) == NULL) 59 return NULL; 60 */ 57 61 58 if((ret_val = talloc(talloc_ctx, WINSEC_DESC)) == NULL) 62 59 return NULL; … … 86 83 } 87 84 88 if(ret_val->off_owner_sid != 0) 85 if(ret_val->off_owner_sid == 0) 86 ret_val->owner_sid = NULL; 87 else 89 88 { 90 89 ret_val->owner_sid = winsec_parse_dom_sid(ret_val, … … 98 97 } 99 98 100 if (ret_val->off_grp_sid != 0) 99 if(ret_val->off_grp_sid == 0) 100 ret_val->grp_sid = NULL; 101 else 101 102 { 102 103 ret_val->grp_sid = winsec_parse_dom_sid(ret_val, buf + ret_val->off_grp_sid, … … 109 110 } 110 111 111 if 112 if((ret_val->control & WINSEC_DESC_SACL_PRESENT) && ret_val->off_sacl) 112 113 { 113 114 ret_val->sacl = winsec_parse_acl(ret_val, buf + ret_val->off_sacl, … … 119 120 } 120 121 } 121 122 if ((ret_val->control & WINSEC_DESC_DACL_PRESENT) && ret_val->off_dacl != 0) 122 else 123 ret_val->sacl = NULL; 124 125 if((ret_val->control & WINSEC_DESC_DACL_PRESENT) && ret_val->off_dacl != 0) 123 126 { 124 127 ret_val->dacl = winsec_parse_acl(ret_val, buf + ret_val->off_dacl, … … 130 133 } 131 134 } 135 else 136 ret_val->dacl = NULL; 132 137 133 138 return ret_val; … … 150 155 if (buf == NULL || buf_len < 8) 151 156 return NULL; 152 /* 153 if((ret_val = (WINSEC_ACL*)zalloc(sizeof(WINSEC_ACL))) == NULL) 154 return NULL; 155 */ 157 156 158 if((ret_val = talloc(talloc_ctx, WINSEC_ACL)) == NULL) 157 159 return NULL; … … 175 177 * (allow no access). 176 178 */ 177 /* if((ret_val->aces = (WINSEC_ACE**)zcalloc(sizeof(WINSEC_ACE*),178 ret_val->num_aces+1)) == NULL)179 */180 179 if((ret_val->aces = talloc_array(ret_val, WINSEC_ACE*, 181 180 ret_val->num_aces+1)) == NULL) … … 203 202 } 204 203 } 204 ret_val->aces[ret_val->num_aces] = NULL; 205 205 206 206 return ret_val; … … 219 219 if(buf == NULL || buf_len < WINSEC_ACE_MIN_SIZE) 220 220 return NULL; 221 222 /* if((ret_val = (WINSEC_ACE*)zalloc(sizeof(WINSEC_ACE))) == NULL)*/223 221 224 222 if((ret_val = talloc(talloc_ctx, WINSEC_ACE)) == NULL) … … 249 247 offset += sizeof(WINSEC_UUID); 250 248 } 249 else 250 ret_val->obj_guid = NULL; 251 251 252 252 if(ret_val->obj_flags & WINSEC_ACE_OBJECT_INHERITED_PRESENT) … … 261 261 offset += sizeof(WINSEC_UUID); 262 262 } 263 else 264 ret_val->inh_guid = NULL; 263 265 } 264 266 … … 322 324 return false; 323 325 324 /* if((ret_val = (WINSEC_UUID*)zalloc(sizeof(WINSEC_UUID))) == NULL)*/325 326 if((ret_val = talloc(talloc_ctx, WINSEC_UUID)) == NULL) 326 327 return NULL; -
trunk/src/reglookup-recover.c
r147 r148 23 23 #include <stdlib.h> 24 24 25 #include "talloc.h" 25 26 #include "regfi.h" 26 27 #include "range_list.h" … … 684 685 return 20; 685 686 } 687 talloc_steal(unalloc_sks, sk); 686 688 j+=sk->cell_size-8; 687 689 } … … 908 910 } 909 911 912 range_list_free(unalloc_cells); 913 range_list_free(unalloc_keys); 914 range_list_free(unalloc_linked_values); 915 range_list_free(unalloc_values); 916 range_list_free(unalloc_sks); 917 910 918 return 0; 911 919 }
Note: See TracChangeset
for help on using the changeset viewer.