- Timestamp:
- 03/02/10 19:08:42 (15 years ago)
- Location:
- trunk/lib
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Makefile
r147 r168 3 3 ################################################################################ 4 4 5 FILES=regfi.o smb_deps.owinsec.o void_stack.o range_list.o lru_cache.o talloc.o5 FILES=regfi.o winsec.o void_stack.o range_list.o lru_cache.o talloc.o 6 6 7 7 all: $(FILES) … … 9 9 regfi.o: regfi.c 10 10 $(CC) $(CFLAGS) $(OPTS) $(INC) -c -o $@ regfi.c 11 12 smb_deps.o: smb_deps.c13 $(CC) $(CFLAGS) $(OPTS) $(INC) -c -o $@ smb_deps.c14 11 15 12 winsec.o: winsec.c -
trunk/lib/lru_cache.c
r147 r168 1 /* 1 /** 2 * @file 3 * 2 4 * Copyright (C) 2008-2009 Timothy D. Morgan 3 5 * -
trunk/lib/range_list.c
r150 r168 1 /* 1 /** 2 * @file 3 * 2 4 * Copyright (C) 2008-2009 Timothy D. Morgan 3 5 * -
trunk/lib/regfi.c
r167 r168 24 24 */ 25 25 26 /** @file */ 27 26 28 #include "regfi.h" 27 29 … … 39 41 /****************************************************************************** 40 42 ******************************************************************************/ 41 void regfi_add_message(REGFI_FILE* file, uint16 msg_type, const char* fmt, ...)43 void regfi_add_message(REGFI_FILE* file, uint16_t msg_type, const char* fmt, ...) 42 44 { 43 45 /* XXX: This function is not particularly efficient, 44 46 * but then it is mostly used during errors. 45 47 */ 46 uint32 buf_size, buf_used;48 uint32_t buf_size, buf_used; 47 49 char* new_msg; 48 50 va_list args; … … 98 100 99 101 100 void regfi_set_message_mask(REGFI_FILE* file, uint16 mask)102 void regfi_set_message_mask(REGFI_FILE* file, uint16_t mask) 101 103 { 102 104 file->msg_mask = mask; … … 154 156 /* Security descriptor formatting functions */ 155 157 156 const char* regfi_ace_type2str(uint8 type)158 const char* regfi_ace_type2str(uint8_t type) 157 159 { 158 160 static const char* map[7] … … 174 176 * http://msdn2.microsoft.com/en-us/library/aa772242.aspx 175 177 */ 176 char* regfi_ace_flags2str(uint8 flags)178 char* regfi_ace_flags2str(uint8_t flags) 177 179 { 178 180 static const char* flag_map[32] = … … 189 191 char* ret_val = malloc(35*sizeof(char)); 190 192 char* fo = ret_val; 191 uint32 i;192 uint8 f;193 uint32_t i; 194 uint8_t f; 193 195 194 196 if(ret_val == NULL) … … 223 225 224 226 225 char* regfi_ace_perms2str(uint32 perms)226 { 227 uint32 i, p;227 char* regfi_ace_perms2str(uint32_t perms) 228 { 229 uint32_t i, p; 228 230 /* This is more than is needed by a fair margin. */ 229 231 char* ret_val = malloc(350*sizeof(char)); … … 304 306 char* regfi_sid2str(WINSEC_DOM_SID* sid) 305 307 { 306 uint32 i, size = WINSEC_MAX_SUBAUTHS*11 + 24;307 uint32 left = size;308 uint8 comps = sid->num_auths;308 uint32_t i, size = WINSEC_MAX_SUBAUTHS*11 + 24; 309 uint32_t left = size; 310 uint8_t comps = sid->num_auths; 309 311 char* ret_val = malloc(size); 310 312 … … 326 328 char* regfi_get_acl(WINSEC_ACL* acl) 327 329 { 328 uint32 i, extra, size = 0;330 uint32_t i, extra, size = 0; 329 331 const char* type_str; 330 332 char* flags_str; … … 425 427 * returned as 0, then EOF was encountered immediately 426 428 *****************************************************************************/ 427 uint32 regfi_read(int fd, uint8* buf, uint32* length)428 { 429 uint32 rsize = 0;430 uint32 rret = 0;429 uint32_t regfi_read(int fd, uint8_t* buf, uint32_t* length) 430 { 431 uint32_t rsize = 0; 432 uint32_t rret = 0; 431 433 432 434 do … … 449 451 * 450 452 *****************************************************************************/ 451 bool regfi_parse_cell(int fd, uint32 offset, uint8* hdr, uint32hdr_len,452 uint32 * cell_length, bool* unalloc)453 { 454 uint32 length;455 int32 raw_length;456 uint8 tmp[4];453 bool regfi_parse_cell(int fd, uint32_t offset, uint8_t* hdr, uint32_t hdr_len, 454 uint32_t* cell_length, bool* unalloc) 455 { 456 uint32_t length; 457 int32_t raw_length; 458 uint8_t tmp[4]; 457 459 458 460 if(lseek(fd, offset, SEEK_SET) == -1) … … 493 495 * The offset is a virtual file offset. 494 496 ******************************************************************************/ 495 static bool regfi_offset_in_hbin(const REGFI_HBIN* hbin, uint32 voffset)497 static bool regfi_offset_in_hbin(const REGFI_HBIN* hbin, uint32_t voffset) 496 498 { 497 499 if(!hbin) … … 511 513 * block for it. NULL if one doesn't exist. 512 514 ******************************************************************************/ 513 const REGFI_HBIN* regfi_lookup_hbin(REGFI_FILE* file, uint32 offset)515 const REGFI_HBIN* regfi_lookup_hbin(REGFI_FILE* file, uint32_t offset) 514 516 { 515 517 return (const REGFI_HBIN*)range_list_find_data(file->hbins, offset); … … 523 525 * (Since cells can only be ~2^31 in size, this works out.) 524 526 ******************************************************************************/ 525 int32 regfi_calc_maxsize(REGFI_FILE* file, uint32offset)527 int32_t regfi_calc_maxsize(REGFI_FILE* file, uint32_t offset) 526 528 { 527 529 const REGFI_HBIN* hbin = regfi_lookup_hbin(file, offset); … … 535 537 /****************************************************************************** 536 538 ******************************************************************************/ 537 REGFI_SUBKEY_LIST* regfi_load_subkeylist(REGFI_FILE* file, uint32 offset,538 uint32 num_keys, uint32max_size,539 REGFI_SUBKEY_LIST* regfi_load_subkeylist(REGFI_FILE* file, uint32_t offset, 540 uint32_t num_keys, uint32_t max_size, 539 541 bool strict) 540 542 { … … 568 570 /****************************************************************************** 569 571 ******************************************************************************/ 570 REGFI_SUBKEY_LIST* regfi_load_subkeylist_aux(REGFI_FILE* file, uint32 offset,571 uint32 max_size, bool strict,572 uint8 depth_left)572 REGFI_SUBKEY_LIST* regfi_load_subkeylist_aux(REGFI_FILE* file, uint32_t offset, 573 uint32_t max_size, bool strict, 574 uint8_t depth_left) 573 575 { 574 576 REGFI_SUBKEY_LIST* ret_val; 575 577 REGFI_SUBKEY_LIST** sublists; 576 uint32 i, num_sublists, off;577 int32 sublist_maxsize;578 uint32_t i, num_sublists, off; 579 int32_t sublist_maxsize; 578 580 579 581 if(depth_left == 0) … … 616 618 /****************************************************************************** 617 619 ******************************************************************************/ 618 REGFI_SUBKEY_LIST* regfi_parse_subkeylist(REGFI_FILE* file, uint32 offset,619 uint32 max_size, bool strict)620 REGFI_SUBKEY_LIST* regfi_parse_subkeylist(REGFI_FILE* file, uint32_t offset, 621 uint32_t max_size, bool strict) 620 622 { 621 623 REGFI_SUBKEY_LIST* ret_val; 622 uint32 i, cell_length, length, elem_size, read_len;623 uint8 * elements = NULL;624 uint8 buf[REGFI_SUBKEY_LIST_MIN_LEN];624 uint32_t i, cell_length, length, elem_size, read_len; 625 uint8_t* elements = NULL; 626 uint8_t buf[REGFI_SUBKEY_LIST_MIN_LEN]; 625 627 bool unalloc; 626 628 bool recursive_type; … … 647 649 { 648 650 recursive_type = true; 649 elem_size = sizeof(uint32 );651 elem_size = sizeof(uint32_t); 650 652 } 651 653 else if(buf[0] == 'l' && buf[1] == 'i') 652 elem_size = sizeof(uint32 );654 elem_size = sizeof(uint32_t); 653 655 else if((buf[0] == 'l') && (buf[1] == 'f' || buf[1] == 'h')) 654 656 elem_size = sizeof(REGFI_SUBKEY_LIST_ELEM); … … 676 678 677 679 length = elem_size*ret_val->num_children; 678 if(cell_length - REGFI_SUBKEY_LIST_MIN_LEN - sizeof(uint32 ) < length)680 if(cell_length - REGFI_SUBKEY_LIST_MIN_LEN - sizeof(uint32_t) < length) 679 681 { 680 682 regfi_add_message(file, REGFI_MSG_WARN, "Number of elements too large for" … … 683 685 if(strict) 684 686 goto fail; 685 length = cell_length - REGFI_SUBKEY_LIST_MIN_LEN - sizeof(uint32 );687 length = cell_length - REGFI_SUBKEY_LIST_MIN_LEN - sizeof(uint32_t); 686 688 } 687 689 … … 691 693 goto fail; 692 694 693 elements = (uint8 *)malloc(length);695 elements = (uint8_t*)malloc(length); 694 696 if(elements == NULL) 695 697 goto fail; … … 699 701 goto fail; 700 702 701 if(elem_size == sizeof(uint32 ))703 if(elem_size == sizeof(uint32_t)) 702 704 { 703 705 for (i=0; i < ret_val->num_children; i++) … … 729 731 /******************************************************************* 730 732 *******************************************************************/ 731 REGFI_SUBKEY_LIST* regfi_merge_subkeylists(uint16 num_lists,733 REGFI_SUBKEY_LIST* regfi_merge_subkeylists(uint16_t num_lists, 732 734 REGFI_SUBKEY_LIST** lists, 733 735 bool strict) 734 736 { 735 uint32 i,j,k;737 uint32_t i,j,k; 736 738 REGFI_SUBKEY_LIST* ret_val; 737 739 … … 785 787 * 786 788 ******************************************************************************/ 787 REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32 offset, uint32max_size,789 REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32_t offset, uint32_t max_size, 788 790 bool strict) 789 791 { 790 792 REGFI_SK_REC* ret_val; 791 uint8 * sec_desc_buf = NULL;792 uint32 cell_length, length;793 uint8 sk_header[REGFI_SK_MIN_LENGTH];793 uint8_t* sec_desc_buf = NULL; 794 uint32_t cell_length, length; 795 uint8_t sk_header[REGFI_SK_MIN_LENGTH]; 794 796 bool unalloc = false; 795 797 … … 855 857 } 856 858 857 sec_desc_buf = (uint8 *)malloc(ret_val->desc_size);859 sec_desc_buf = (uint8_t*)malloc(ret_val->desc_size); 858 860 if(sec_desc_buf == NULL) 859 861 goto fail; … … 889 891 890 892 891 REGFI_VALUE_LIST* regfi_parse_valuelist(REGFI_FILE* file, uint32 offset,892 uint32 num_values, bool strict)893 REGFI_VALUE_LIST* regfi_parse_valuelist(REGFI_FILE* file, uint32_t offset, 894 uint32_t num_values, bool strict) 893 895 { 894 896 REGFI_VALUE_LIST* ret_val; 895 uint32 i, cell_length, length, read_len;897 uint32_t i, cell_length, length, read_len; 896 898 bool unalloc; 897 899 … … 912 914 } 913 915 914 if((num_values * sizeof(uint32 )) > cell_length-sizeof(uint32))916 if((num_values * sizeof(uint32_t)) > cell_length-sizeof(uint32_t)) 915 917 { 916 918 regfi_add_message(file, REGFI_MSG_WARN, "Too many values found" … … 918 920 if(strict) 919 921 return NULL; 920 num_values = cell_length/sizeof(uint32 ) - sizeof(uint32);921 } 922 923 read_len = num_values*sizeof(uint32 );922 num_values = cell_length/sizeof(uint32_t) - sizeof(uint32_t); 923 } 924 925 read_len = num_values*sizeof(uint32_t); 924 926 ret_val = talloc(NULL, REGFI_VALUE_LIST); 925 927 if(ret_val == NULL) … … 935 937 936 938 length = read_len; 937 if((regfi_read(file->fd, (uint8 *)ret_val->elements, &length) != 0)939 if((regfi_read(file->fd, (uint8_t*)ret_val->elements, &length) != 0) 938 940 || length != read_len) 939 941 { … … 973 975 /****************************************************************************** 974 976 ******************************************************************************/ 975 REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32 offset,977 REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32_t offset, 976 978 REGFI_ENCODING output_encoding, bool strict) 977 979 { 978 980 REGFI_VK_REC* ret_val = NULL; 979 int32 max_size, tmp_size;981 int32_t max_size, tmp_size; 980 982 REGFI_ENCODING from_encoding; 981 983 … … 1003 1005 { 1004 1006 ret_val->valuename_raw = talloc_realloc(ret_val, ret_val->valuename_raw, 1005 uint8 , ret_val->name_length+1);1007 uint8_t, ret_val->name_length+1); 1006 1008 ret_val->valuename_raw[ret_val->name_length] = '\0'; 1007 1009 ret_val->valuename = (char*)ret_val->valuename_raw; … … 1038 1040 * If !strict, the list may contain NULLs, VK records may point to NULL. 1039 1041 ******************************************************************************/ 1040 REGFI_VALUE_LIST* regfi_load_valuelist(REGFI_FILE* file, uint32 offset,1041 uint32 num_values, uint32max_size,1042 REGFI_VALUE_LIST* regfi_load_valuelist(REGFI_FILE* file, uint32_t offset, 1043 uint32_t num_values, uint32_t max_size, 1042 1044 bool strict) 1043 1045 { 1044 uint32 usable_num_values;1045 1046 if((num_values+1) * sizeof(uint32 ) > max_size)1046 uint32_t usable_num_values; 1047 1048 if((num_values+1) * sizeof(uint32_t) > max_size) 1047 1049 { 1048 1050 regfi_add_message(file, REGFI_MSG_WARN, "Number of values indicated by" … … 1052 1054 if(strict) 1053 1055 return NULL; 1054 usable_num_values = max_size/sizeof(uint32 ) - sizeof(uint32);1056 usable_num_values = max_size/sizeof(uint32_t) - sizeof(uint32_t); 1055 1057 } 1056 1058 else … … 1065 1067 * 1066 1068 ******************************************************************************/ 1067 REGFI_NK_REC* regfi_load_key(REGFI_FILE* file, uint32 offset,1069 REGFI_NK_REC* regfi_load_key(REGFI_FILE* file, uint32_t offset, 1068 1070 REGFI_ENCODING output_encoding, bool strict) 1069 1071 { 1070 1072 REGFI_NK_REC* nk; 1071 uint32 off;1072 int32 max_size, tmp_size;1073 uint32_t off; 1074 int32_t max_size, tmp_size; 1073 1075 REGFI_ENCODING from_encoding; 1074 1076 … … 1097 1099 if(from_encoding == output_encoding) 1098 1100 { 1099 nk->keyname_raw = talloc_realloc(nk, nk->keyname_raw, uint8 , nk->name_length+1);1101 nk->keyname_raw = talloc_realloc(nk, nk->keyname_raw, uint8_t, nk->name_length+1); 1100 1102 nk->keyname_raw[nk->name_length] = '\0'; 1101 1103 nk->keyname = (char*)nk->keyname_raw; … … 1196 1198 /****************************************************************************** 1197 1199 ******************************************************************************/ 1198 const REGFI_SK_REC* regfi_load_sk(REGFI_FILE* file, uint32 offset, bool strict)1200 const REGFI_SK_REC* regfi_load_sk(REGFI_FILE* file, uint32_t offset, bool strict) 1199 1201 { 1200 1202 REGFI_SK_REC* ret_val = NULL; 1201 int32 max_size;1203 int32_t max_size; 1202 1204 void* failure_ptr = NULL; 1203 1205 … … 1240 1242 { 1241 1243 REGFI_NK_REC* nk = NULL; 1242 uint32 cell_length;1243 uint32 cur_offset = hbin->file_off+REGFI_HBIN_HEADER_SIZE;1244 uint32 hbin_end = hbin->file_off+hbin->block_size;1244 uint32_t cell_length; 1245 uint32_t cur_offset = hbin->file_off+REGFI_HBIN_HEADER_SIZE; 1246 uint32_t hbin_end = hbin->file_off+hbin->block_size; 1245 1247 bool unalloc; 1246 1248 … … 1301 1303 REGFI_FILE* rb; 1302 1304 REGFI_HBIN* hbin = NULL; 1303 uint32 hbin_off, file_length, cache_secret;1305 uint32_t hbin_off, file_length, cache_secret; 1304 1306 bool rla; 1305 1307 … … 1397 1399 REGFI_NK_REC* nk = NULL; 1398 1400 REGFI_HBIN* hbin; 1399 uint32 root_offset, i, num_hbins;1401 uint32_t root_offset, i, num_hbins; 1400 1402 1401 1403 if(!file) … … 1584 1586 REGFI_NK_REC* subkey; 1585 1587 bool found = false; 1586 uint32 old_subkey = i->cur_subkey;1588 uint32_t old_subkey = i->cur_subkey; 1587 1589 1588 1590 if(subkey_name == NULL) … … 1618 1620 bool regfi_iterator_walk_path(REGFI_ITERATOR* i, const char** path) 1619 1621 { 1620 uint32 x;1622 uint32_t x; 1621 1623 if(path == NULL) 1622 1624 return false; … … 1671 1673 REGFI_NK_REC* regfi_iterator_cur_subkey(REGFI_ITERATOR* i) 1672 1674 { 1673 uint32 nk_offset;1675 uint32_t nk_offset; 1674 1676 1675 1677 /* see if there is anything left to report */ … … 1708 1710 REGFI_VK_REC* cur; 1709 1711 bool found = false; 1710 uint32 old_value = i->cur_value;1712 uint32_t old_value = i->cur_value; 1711 1713 1712 1714 /* XXX: cur->valuename can be NULL in the registry. … … 1754 1756 { 1755 1757 REGFI_VK_REC* ret_val = NULL; 1756 uint32 voffset;1758 uint32_t voffset; 1757 1759 1758 1760 if(i->cur_key->values != NULL && i->cur_key->values->elements != NULL) … … 1791 1793 { 1792 1794 REGFI_CLASSNAME* ret_val; 1793 uint8 * raw;1795 uint8_t* raw; 1794 1796 char* interpreted; 1795 uint32 offset;1796 int32 conv_size, max_size;1797 uint16 parse_length;1797 uint32_t offset; 1798 int32_t conv_size, max_size; 1799 uint16_t parse_length; 1798 1800 1799 1801 if(key->classname_off == REGFI_OFFSET_NONE || key->classname_length == 0) … … 1935 1937 *****************************************************************************/ 1936 1938 bool regfi_interpret_data(REGFI_FILE* file, REGFI_ENCODING string_encoding, 1937 uint32 type, REGFI_DATA* data)1938 { 1939 uint8 ** tmp_array;1940 uint8 * tmp_str;1941 int32 tmp_size;1942 uint32 i, j, array_size;1939 uint32_t type, REGFI_DATA* data) 1940 { 1941 uint8_t** tmp_array; 1942 uint8_t* tmp_str; 1943 int32_t tmp_size; 1944 uint32_t i, j, array_size; 1943 1945 1944 1946 if(data == NULL) … … 1951 1953 /* REG_LINK is a symbolic link, stored as a unicode string. */ 1952 1954 case REG_LINK: 1953 tmp_str = talloc_array(NULL, uint8 , data->size);1955 tmp_str = talloc_array(NULL, uint8_t, data->size); 1954 1956 if(tmp_str == NULL) 1955 1957 { … … 1974 1976 } 1975 1977 1976 tmp_str = talloc_realloc(NULL, tmp_str, uint8 , tmp_size);1978 tmp_str = talloc_realloc(NULL, tmp_str, uint8_t, tmp_size); 1977 1979 data->interpreted.string = tmp_str; 1978 1980 data->interpreted_size = tmp_size; … … 2010 2012 } 2011 2013 data->interpreted.qword = 2012 (uint64 )IVAL(data->raw, 0) + (((uint64)IVAL(data->raw, 4))<<32);2014 (uint64_t)IVAL(data->raw, 0) + (((uint64_t)IVAL(data->raw, 4))<<32); 2013 2015 data->interpreted_size = 8; 2014 2016 break; 2015 2017 2016 2018 case REG_MULTI_SZ: 2017 tmp_str = talloc_array(NULL, uint8 , data->size);2019 tmp_str = talloc_array(NULL, uint8_t, data->size); 2018 2020 if(tmp_str == NULL) 2019 2021 { … … 2042 2044 2043 2045 array_size = tmp_size+1; 2044 tmp_array = talloc_array(NULL, uint8 *, array_size);2046 tmp_array = talloc_array(NULL, uint8_t*, array_size); 2045 2047 if(tmp_array == NULL) 2046 2048 { … … 2058 2060 } 2059 2061 tmp_array[j] = NULL; 2060 tmp_array = talloc_realloc(NULL, tmp_array, uint8 *, j+1);2062 tmp_array = talloc_realloc(NULL, tmp_array, uint8_t*, j+1); 2061 2063 data->interpreted.multiple_string = tmp_array; 2062 2064 /* XXX: how meaningful is this? should we store number of strings instead? */ … … 2107 2109 * On error, returns a negative errno code. 2108 2110 *****************************************************************************/ 2109 int32 regfi_conv_charset(const char* input_charset, const char* output_charset,2110 uint8 * input, char* output,2111 uint32 input_len, uint32output_max)2111 int32_t regfi_conv_charset(const char* input_charset, const char* output_charset, 2112 uint8_t* input, char* output, 2113 uint32_t input_len, uint32_t output_max) 2112 2114 { 2113 2115 iconv_t conv_desc; … … 2144 2146 * buffer must be at least the size of a regf header (4096 bytes). 2145 2147 *******************************************************************/ 2146 static uint32 regfi_compute_header_checksum(uint8* buffer)2147 { 2148 uint32 checksum, x;2148 static uint32_t regfi_compute_header_checksum(uint8_t* buffer) 2149 { 2150 uint32_t checksum, x; 2149 2151 int i; 2150 2152 … … 2167 2169 REGFI_FILE* regfi_parse_regf(int fd, bool strict) 2168 2170 { 2169 uint8 file_header[REGFI_REGF_SIZE];2170 uint32 length;2171 uint8_t file_header[REGFI_REGF_SIZE]; 2172 uint32_t length; 2171 2173 REGFI_FILE* ret_val; 2172 2174 … … 2243 2245 * along with it's associated cells. 2244 2246 ******************************************************************************/ 2245 REGFI_HBIN* regfi_parse_hbin(REGFI_FILE* file, uint32 offset, bool strict)2247 REGFI_HBIN* regfi_parse_hbin(REGFI_FILE* file, uint32_t offset, bool strict) 2246 2248 { 2247 2249 REGFI_HBIN *hbin; 2248 uint8 hbin_header[REGFI_HBIN_HEADER_SIZE];2249 uint32 length;2250 uint8_t hbin_header[REGFI_HBIN_HEADER_SIZE]; 2251 uint32_t length; 2250 2252 2251 2253 if(offset >= file->file_length) … … 2315 2317 /******************************************************************* 2316 2318 *******************************************************************/ 2317 REGFI_NK_REC* regfi_parse_nk(REGFI_FILE* file, uint32 offset,2318 uint32 max_size, bool strict)2319 { 2320 uint8 nk_header[REGFI_NK_MIN_LENGTH];2319 REGFI_NK_REC* regfi_parse_nk(REGFI_FILE* file, uint32_t offset, 2320 uint32_t max_size, bool strict) 2321 { 2322 uint8_t nk_header[REGFI_NK_MIN_LENGTH]; 2321 2323 REGFI_NK_REC* ret_val; 2322 uint32 length,cell_length;2324 uint32_t length,cell_length; 2323 2325 bool unalloc = false; 2324 2326 … … 2432 2434 } 2433 2435 2434 ret_val->keyname_raw = talloc_array(ret_val, uint8 , ret_val->name_length);2436 ret_val->keyname_raw = talloc_array(ret_val, uint8_t, ret_val->name_length); 2435 2437 if(ret_val->keyname_raw == NULL) 2436 2438 { … … 2441 2443 /* Don't need to seek, should be at the right offset */ 2442 2444 length = ret_val->name_length; 2443 if((regfi_read(file->fd, (uint8 *)ret_val->keyname_raw, &length) != 0)2445 if((regfi_read(file->fd, (uint8_t*)ret_val->keyname_raw, &length) != 0) 2444 2446 || length != ret_val->name_length) 2445 2447 { … … 2454 2456 2455 2457 2456 uint8 * regfi_parse_classname(REGFI_FILE* file, uint32offset,2457 uint16 * name_length, uint32max_size, bool strict)2458 { 2459 uint8 * ret_val = NULL;2460 uint32 length;2461 uint32 cell_length;2458 uint8_t* regfi_parse_classname(REGFI_FILE* file, uint32_t offset, 2459 uint16_t* name_length, uint32_t max_size, bool strict) 2460 { 2461 uint8_t* ret_val = NULL; 2462 uint32_t length; 2463 uint32_t cell_length; 2462 2464 bool unalloc = false; 2463 2465 … … 2499 2501 } 2500 2502 2501 ret_val = talloc_array(NULL, uint8 , *name_length);2503 ret_val = talloc_array(NULL, uint8_t, *name_length); 2502 2504 if(ret_val != NULL) 2503 2505 { … … 2520 2522 /****************************************************************************** 2521 2523 *******************************************************************************/ 2522 REGFI_VK_REC* regfi_parse_vk(REGFI_FILE* file, uint32 offset,2523 uint32 max_size, bool strict)2524 REGFI_VK_REC* regfi_parse_vk(REGFI_FILE* file, uint32_t offset, 2525 uint32_t max_size, bool strict) 2524 2526 { 2525 2527 REGFI_VK_REC* ret_val; 2526 uint8 vk_header[REGFI_VK_MIN_LENGTH];2527 uint32 raw_data_size, length, cell_length;2528 uint8_t vk_header[REGFI_VK_MIN_LENGTH]; 2529 uint32_t raw_data_size, length, cell_length; 2528 2530 bool unalloc = false; 2529 2531 … … 2604 2606 cell_length+=8; 2605 2607 2606 ret_val->valuename_raw = talloc_array(ret_val, uint8 , ret_val->name_length);2608 ret_val->valuename_raw = talloc_array(ret_val, uint8_t, ret_val->name_length); 2607 2609 if(ret_val->valuename_raw == NULL) 2608 2610 { … … 2612 2614 2613 2615 length = ret_val->name_length; 2614 if((regfi_read(file->fd, (uint8 *)ret_val->valuename_raw, &length) != 0)2616 if((regfi_read(file->fd, (uint8_t*)ret_val->valuename_raw, &length) != 0) 2615 2617 || length != ret_val->name_length) 2616 2618 { … … 2638 2640 * 2639 2641 ******************************************************************************/ 2640 REGFI_BUFFER regfi_load_data(REGFI_FILE* file, uint32 voffset,2641 uint32 length, bool data_in_offset,2642 REGFI_BUFFER regfi_load_data(REGFI_FILE* file, uint32_t voffset, 2643 uint32_t length, bool data_in_offset, 2642 2644 bool strict) 2643 2645 { 2644 2646 REGFI_BUFFER ret_val; 2645 uint32 cell_length, offset;2646 int32 max_size;2647 uint32_t cell_length, offset; 2648 int32_t max_size; 2647 2649 bool unalloc; 2648 2650 … … 2744 2746 * Parses the common case data records stored in a single cell. 2745 2747 ******************************************************************************/ 2746 REGFI_BUFFER regfi_parse_data(REGFI_FILE* file, uint32 offset,2747 uint32 length, bool strict)2748 REGFI_BUFFER regfi_parse_data(REGFI_FILE* file, uint32_t offset, 2749 uint32_t length, bool strict) 2748 2750 { 2749 2751 REGFI_BUFFER ret_val; 2750 uint32 read_length;2752 uint32_t read_length; 2751 2753 2752 2754 ret_val.buf = NULL; … … 2760 2762 } 2761 2763 2762 if((ret_val.buf = talloc_array(NULL, uint8 , length)) == NULL)2764 if((ret_val.buf = talloc_array(NULL, uint8_t, length)) == NULL) 2763 2765 return ret_val; 2764 2766 ret_val.len = length; … … 2783 2785 * 2784 2786 ******************************************************************************/ 2785 REGFI_BUFFER regfi_parse_little_data(REGFI_FILE* file, uint32 voffset,2786 uint32 length, bool strict)2787 REGFI_BUFFER regfi_parse_little_data(REGFI_FILE* file, uint32_t voffset, 2788 uint32_t length, bool strict) 2787 2789 { 2788 2790 REGFI_BUFFER ret_val; 2789 uint8 i;2791 uint8_t i; 2790 2792 2791 2793 ret_val.buf = NULL; … … 2800 2802 } 2801 2803 2802 if((ret_val.buf = talloc_array(NULL, uint8 , length)) == NULL)2804 if((ret_val.buf = talloc_array(NULL, uint8_t, length)) == NULL) 2803 2805 return ret_val; 2804 2806 ret_val.len = length; 2805 2807 2806 2808 for(i = 0; i < length; i++) 2807 ret_val.buf[i] = (uint8 )((voffset >> i*8) & 0xFF);2809 ret_val.buf[i] = (uint8_t)((voffset >> i*8) & 0xFF); 2808 2810 2809 2811 return ret_val; … … 2812 2814 /****************************************************************************** 2813 2815 *******************************************************************************/ 2814 REGFI_BUFFER regfi_parse_big_data_header(REGFI_FILE* file, uint32 offset,2815 uint32 max_size, bool strict)2816 REGFI_BUFFER regfi_parse_big_data_header(REGFI_FILE* file, uint32_t offset, 2817 uint32_t max_size, bool strict) 2816 2818 { 2817 2819 REGFI_BUFFER ret_val; 2818 uint32 cell_length;2820 uint32_t cell_length; 2819 2821 bool unalloc; 2820 2822 2821 2823 /* XXX: do something with unalloc? */ 2822 ret_val.buf = (uint8 *)talloc_array(NULL, uint8, REGFI_BIG_DATA_MIN_LENGTH);2824 ret_val.buf = (uint8_t*)talloc_array(NULL, uint8_t, REGFI_BIG_DATA_MIN_LENGTH); 2823 2825 if(ret_val.buf == NULL) 2824 2826 goto fail; … … 2866 2868 * 2867 2869 ******************************************************************************/ 2868 uint32 * regfi_parse_big_data_indirect(REGFI_FILE* file, uint32offset,2869 uint16 num_chunks, bool strict)2870 { 2871 uint32 * ret_val;2872 uint32 indirect_length;2873 int32 max_size;2874 uint16 i;2870 uint32_t* regfi_parse_big_data_indirect(REGFI_FILE* file, uint32_t offset, 2871 uint16_t num_chunks, bool strict) 2872 { 2873 uint32_t* ret_val; 2874 uint32_t indirect_length; 2875 int32_t max_size; 2876 uint16_t i; 2875 2877 bool unalloc; 2876 2878 … … 2878 2880 2879 2881 max_size = regfi_calc_maxsize(file, offset); 2880 if((max_size < 0) || (num_chunks*sizeof(uint32 ) + 4 > max_size))2881 return NULL; 2882 2883 ret_val = (uint32 *)talloc_array(NULL, uint32, num_chunks);2882 if((max_size < 0) || (num_chunks*sizeof(uint32_t) + 4 > max_size)) 2883 return NULL; 2884 2885 ret_val = (uint32_t*)talloc_array(NULL, uint32_t, num_chunks); 2884 2886 if(ret_val == NULL) 2885 2887 goto fail; 2886 2888 2887 if(!regfi_parse_cell(file->fd, offset, (uint8 *)ret_val,2888 num_chunks*sizeof(uint32 ),2889 if(!regfi_parse_cell(file->fd, offset, (uint8_t*)ret_val, 2890 num_chunks*sizeof(uint32_t), 2889 2891 &indirect_length, &unalloc)) 2890 2892 { … … 2898 2900 for(i=0; i<num_chunks; i++) 2899 2901 { 2900 ret_val[i] = IVAL(ret_val, i*sizeof(uint32 ));2902 ret_val[i] = IVAL(ret_val, i*sizeof(uint32_t)); 2901 2903 if((ret_val[i] & 0x00000007) != 0) 2902 2904 goto fail; … … 2924 2926 * No data in range_list elements. 2925 2927 ******************************************************************************/ 2926 range_list* regfi_parse_big_data_cells(REGFI_FILE* file, uint32 * offsets,2927 uint16 num_chunks, bool strict)2928 { 2929 uint32 cell_length, chunk_offset;2928 range_list* regfi_parse_big_data_cells(REGFI_FILE* file, uint32_t* offsets, 2929 uint16_t num_chunks, bool strict) 2930 { 2931 uint32_t cell_length, chunk_offset; 2930 2932 range_list* ret_val; 2931 uint16 i;2933 uint16_t i; 2932 2934 bool unalloc; 2933 2935 … … 2965 2967 *******************************************************************************/ 2966 2968 REGFI_BUFFER regfi_load_big_data(REGFI_FILE* file, 2967 uint32 offset, uint32data_length,2968 uint32 cell_length, range_list* used_ranges,2969 uint32_t offset, uint32_t data_length, 2970 uint32_t cell_length, range_list* used_ranges, 2969 2971 bool strict) 2970 2972 { 2971 2973 REGFI_BUFFER ret_val; 2972 uint16 num_chunks, i;2973 uint32 read_length, data_left, tmp_len, indirect_offset;2974 uint32 * indirect_ptrs = NULL;2974 uint16_t num_chunks, i; 2975 uint32_t read_length, data_left, tmp_len, indirect_offset; 2976 uint32_t* indirect_ptrs = NULL; 2975 2977 REGFI_BUFFER bd_header; 2976 2978 range_list* bd_cells = NULL; … … 3048 3050 } 3049 3051 3050 if(lseek(file->fd, cell_info->offset+sizeof(uint32 ), SEEK_SET) == -1)3052 if(lseek(file->fd, cell_info->offset+sizeof(uint32_t), SEEK_SET) == -1) 3051 3053 { 3052 3054 regfi_add_message(file, REGFI_MSG_WARN, "Could not seek to chunk while " … … 3095 3097 REGFI_HBIN* hbin; 3096 3098 const range_list_element* hbins_elem; 3097 uint32 i, num_hbins, curr_off, cell_len;3099 uint32_t i, num_hbins, curr_off, cell_len; 3098 3100 bool is_unalloc; 3099 3101 … … 3142 3144 return ret_val; 3143 3145 } 3146 3147 3148 /* From lib/time.c */ 3149 3150 /**************************************************************************** 3151 Put a 8 byte filetime from a time_t 3152 This takes real GMT as input and converts to kludge-GMT 3153 ****************************************************************************/ 3154 void regfi_unix2nt_time(REGFI_NTTIME *nt, time_t t) 3155 { 3156 double d; 3157 3158 if (t==0) 3159 { 3160 nt->low = 0; 3161 nt->high = 0; 3162 return; 3163 } 3164 3165 if (t == TIME_T_MAX) 3166 { 3167 nt->low = 0xffffffff; 3168 nt->high = 0x7fffffff; 3169 return; 3170 } 3171 3172 if (t == -1) 3173 { 3174 nt->low = 0xffffffff; 3175 nt->high = 0xffffffff; 3176 return; 3177 } 3178 3179 /* this converts GMT to kludge-GMT */ 3180 /* XXX: This was removed due to difficult dependency requirements. 3181 * So far, times appear to be correct without this adjustment, but 3182 * that may be proven wrong with adequate testing. 3183 */ 3184 /* t -= TimeDiff(t) - get_serverzone(); */ 3185 3186 d = (double)(t); 3187 d += TIME_FIXUP_CONSTANT; 3188 d *= 1.0e7; 3189 3190 nt->high = (uint32_t)(d * (1.0/(4.0*(double)(1<<30)))); 3191 nt->low = (uint32_t)(d - ((double)nt->high)*4.0*(double)(1<<30)); 3192 } 3193 3194 3195 /**************************************************************************** 3196 Interpret an 8 byte "filetime" structure to a time_t 3197 It's originally in "100ns units since jan 1st 1601" 3198 3199 An 8 byte value of 0xffffffffffffffff will be returned as (time_t)0. 3200 3201 It appears to be kludge-GMT (at least for file listings). This means 3202 its the GMT you get by taking a localtime and adding the 3203 serverzone. This is NOT the same as GMT in some cases. This routine 3204 converts this to real GMT. 3205 ****************************************************************************/ 3206 time_t regfi_nt2unix_time(const REGFI_NTTIME* nt) 3207 { 3208 double d; 3209 time_t ret; 3210 /* The next two lines are a fix needed for the 3211 broken SCO compiler. JRA. */ 3212 time_t l_time_min = TIME_T_MIN; 3213 time_t l_time_max = TIME_T_MAX; 3214 3215 if (nt->high == 0 || (nt->high == 0xffffffff && nt->low == 0xffffffff)) 3216 return(0); 3217 3218 d = ((double)nt->high)*4.0*(double)(1<<30); 3219 d += (nt->low&0xFFF00000); 3220 d *= 1.0e-7; 3221 3222 /* now adjust by 369 years to make the secs since 1970 */ 3223 d -= TIME_FIXUP_CONSTANT; 3224 3225 if (d <= l_time_min) 3226 return (l_time_min); 3227 3228 if (d >= l_time_max) 3229 return (l_time_max); 3230 3231 ret = (time_t)(d+0.5); 3232 3233 /* this takes us from kludge-GMT to real GMT */ 3234 /* XXX: This was removed due to difficult dependency requirements. 3235 * So far, times appear to be correct without this adjustment, but 3236 * that may be proven wrong with adequate testing. 3237 */ 3238 /* 3239 ret -= get_serverzone(); 3240 ret += LocTimeDiff(ret); 3241 */ 3242 3243 return(ret); 3244 } 3245 3246 /* End of stuff from lib/time.c */ -
trunk/lib/void_stack.c
r150 r168 1 /* 1 /** 2 * @file 3 * 2 4 * This is a really simple implementation of a stack which stores chunks 3 * of memory of any type. It still needs work to eliminate memory 4 * leaks. 5 * of memory of any type. 5 6 * 6 7 * Copyright (C) 2005,2007,2009 Timothy D. Morgan -
trunk/lib/winsec.c
r148 r168 1 /* 1 /** 2 * @file 2 3 * This file contains refactored Samba code used to interpret Windows 3 4 * Security Descriptors. See:
Note: See TracChangeset
for help on using the changeset viewer.