Changeset 168 for trunk/lib/regfi.c


Ignore:
Timestamp:
03/02/10 19:08:42 (14 years ago)
Author:
tim
Message:

merged remaining smb_deps items into regfi

began formatting API comments for use with doxygen

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/regfi.c

    r167 r168  
    2424 */
    2525
     26/** @file */
     27
    2628#include "regfi.h"
    2729
     
    3941/******************************************************************************
    4042 ******************************************************************************/
    41 void regfi_add_message(REGFI_FILE* file, uint16 msg_type, const char* fmt, ...)
     43void regfi_add_message(REGFI_FILE* file, uint16_t msg_type, const char* fmt, ...)
    4244{
    4345  /* XXX: This function is not particularly efficient,
    4446   *      but then it is mostly used during errors.
    4547   */
    46   uint32 buf_size, buf_used;
     48  uint32_t buf_size, buf_used;
    4749  char* new_msg;
    4850  va_list args;
     
    98100
    99101
    100 void regfi_set_message_mask(REGFI_FILE* file, uint16 mask)
     102void regfi_set_message_mask(REGFI_FILE* file, uint16_t mask)
    101103{
    102104  file->msg_mask = mask;
     
    154156/* Security descriptor formatting functions  */
    155157
    156 const char* regfi_ace_type2str(uint8 type)
     158const char* regfi_ace_type2str(uint8_t type)
    157159{
    158160  static const char* map[7]
     
    174176 *   http://msdn2.microsoft.com/en-us/library/aa772242.aspx
    175177 */
    176 char* regfi_ace_flags2str(uint8 flags)
     178char* regfi_ace_flags2str(uint8_t flags)
    177179{
    178180  static const char* flag_map[32] =
     
    189191  char* ret_val = malloc(35*sizeof(char));
    190192  char* fo = ret_val;
    191   uint32 i;
    192   uint8 f;
     193  uint32_t i;
     194  uint8_t f;
    193195
    194196  if(ret_val == NULL)
     
    223225
    224226
    225 char* regfi_ace_perms2str(uint32 perms)
    226 {
    227   uint32 i, p;
     227char* regfi_ace_perms2str(uint32_t perms)
     228{
     229  uint32_t i, p;
    228230  /* This is more than is needed by a fair margin. */
    229231  char* ret_val = malloc(350*sizeof(char));
     
    304306char* regfi_sid2str(WINSEC_DOM_SID* sid)
    305307{
    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;
    309311  char* ret_val = malloc(size);
    310312 
     
    326328char* regfi_get_acl(WINSEC_ACL* acl)
    327329{
    328   uint32 i, extra, size = 0;
     330  uint32_t i, extra, size = 0;
    329331  const char* type_str;
    330332  char* flags_str;
     
    425427 * returned as 0, then EOF was encountered immediately
    426428 *****************************************************************************/
    427 uint32 regfi_read(int fd, uint8* buf, uint32* length)
    428 {
    429   uint32 rsize = 0;
    430   uint32 rret = 0;
     429uint32_t regfi_read(int fd, uint8_t* buf, uint32_t* length)
     430{
     431  uint32_t rsize = 0;
     432  uint32_t rret = 0;
    431433
    432434  do
     
    449451 *
    450452 *****************************************************************************/
    451 bool regfi_parse_cell(int fd, uint32 offset, uint8* hdr, uint32 hdr_len,
    452                       uint32* cell_length, bool* unalloc)
    453 {
    454   uint32 length;
    455   int32 raw_length;
    456   uint8 tmp[4];
     453bool 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];
    457459
    458460  if(lseek(fd, offset, SEEK_SET) == -1)
     
    493495 * The offset is a virtual file offset.
    494496 ******************************************************************************/
    495 static bool regfi_offset_in_hbin(const REGFI_HBIN* hbin, uint32 voffset)
     497static bool regfi_offset_in_hbin(const REGFI_HBIN* hbin, uint32_t voffset)
    496498{
    497499  if(!hbin)
     
    511513 * block for it.  NULL if one doesn't exist.
    512514 ******************************************************************************/
    513 const REGFI_HBIN* regfi_lookup_hbin(REGFI_FILE* file, uint32 offset)
     515const REGFI_HBIN* regfi_lookup_hbin(REGFI_FILE* file, uint32_t offset)
    514516{
    515517  return (const REGFI_HBIN*)range_list_find_data(file->hbins, offset);
     
    523525 * (Since cells can only be ~2^31 in size, this works out.)
    524526 ******************************************************************************/
    525 int32 regfi_calc_maxsize(REGFI_FILE* file, uint32 offset)
     527int32_t regfi_calc_maxsize(REGFI_FILE* file, uint32_t offset)
    526528{
    527529  const REGFI_HBIN* hbin = regfi_lookup_hbin(file, offset);
     
    535537/******************************************************************************
    536538 ******************************************************************************/
    537 REGFI_SUBKEY_LIST* regfi_load_subkeylist(REGFI_FILE* file, uint32 offset,
    538                                          uint32 num_keys, uint32 max_size,
     539REGFI_SUBKEY_LIST* regfi_load_subkeylist(REGFI_FILE* file, uint32_t offset,
     540                                         uint32_t num_keys, uint32_t max_size,
    539541                                         bool strict)
    540542{
     
    568570/******************************************************************************
    569571 ******************************************************************************/
    570 REGFI_SUBKEY_LIST* regfi_load_subkeylist_aux(REGFI_FILE* file, uint32 offset,
    571                                              uint32 max_size, bool strict,
    572                                              uint8 depth_left)
     572REGFI_SUBKEY_LIST* regfi_load_subkeylist_aux(REGFI_FILE* file, uint32_t offset,
     573                                             uint32_t max_size, bool strict,
     574                                             uint8_t depth_left)
    573575{
    574576  REGFI_SUBKEY_LIST* ret_val;
    575577  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;
    578580
    579581  if(depth_left == 0)
     
    616618/******************************************************************************
    617619 ******************************************************************************/
    618 REGFI_SUBKEY_LIST* regfi_parse_subkeylist(REGFI_FILE* file, uint32 offset,
    619                                           uint32 max_size, bool strict)
     620REGFI_SUBKEY_LIST* regfi_parse_subkeylist(REGFI_FILE* file, uint32_t offset,
     621                                          uint32_t max_size, bool strict)
    620622{
    621623  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];
    625627  bool unalloc;
    626628  bool recursive_type;
     
    647649  {
    648650    recursive_type = true;
    649     elem_size = sizeof(uint32);
     651    elem_size = sizeof(uint32_t);
    650652  }
    651653  else if(buf[0] == 'l' && buf[1] == 'i')
    652     elem_size = sizeof(uint32);
     654    elem_size = sizeof(uint32_t);
    653655  else if((buf[0] == 'l') && (buf[1] == 'f' || buf[1] == 'h'))
    654656    elem_size = sizeof(REGFI_SUBKEY_LIST_ELEM);
     
    676678
    677679  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)
    679681  {
    680682    regfi_add_message(file, REGFI_MSG_WARN, "Number of elements too large for"
     
    683685    if(strict)
    684686      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);
    686688  }
    687689
     
    691693    goto fail;
    692694
    693   elements = (uint8*)malloc(length);
     695  elements = (uint8_t*)malloc(length);
    694696  if(elements == NULL)
    695697    goto fail;
     
    699701    goto fail;
    700702
    701   if(elem_size == sizeof(uint32))
     703  if(elem_size == sizeof(uint32_t))
    702704  {
    703705    for (i=0; i < ret_val->num_children; i++)
     
    729731/*******************************************************************
    730732 *******************************************************************/
    731 REGFI_SUBKEY_LIST* regfi_merge_subkeylists(uint16 num_lists,
     733REGFI_SUBKEY_LIST* regfi_merge_subkeylists(uint16_t num_lists,
    732734                                           REGFI_SUBKEY_LIST** lists,
    733735                                           bool strict)
    734736{
    735   uint32 i,j,k;
     737  uint32_t i,j,k;
    736738  REGFI_SUBKEY_LIST* ret_val;
    737739
     
    785787 *
    786788 ******************************************************************************/
    787 REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32 offset, uint32 max_size,
     789REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32_t offset, uint32_t max_size,
    788790                             bool strict)
    789791{
    790792  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];
    794796  bool unalloc = false;
    795797
     
    855857  }
    856858
    857   sec_desc_buf = (uint8*)malloc(ret_val->desc_size);
     859  sec_desc_buf = (uint8_t*)malloc(ret_val->desc_size);
    858860  if(sec_desc_buf == NULL)
    859861    goto fail;
     
    889891
    890892
    891 REGFI_VALUE_LIST* regfi_parse_valuelist(REGFI_FILE* file, uint32 offset,
    892                                         uint32 num_values, bool strict)
     893REGFI_VALUE_LIST* regfi_parse_valuelist(REGFI_FILE* file, uint32_t offset,
     894                                        uint32_t num_values, bool strict)
    893895{
    894896  REGFI_VALUE_LIST* ret_val;
    895   uint32 i, cell_length, length, read_len;
     897  uint32_t i, cell_length, length, read_len;
    896898  bool unalloc;
    897899
     
    912914  }
    913915
    914   if((num_values * sizeof(uint32)) > cell_length-sizeof(uint32))
     916  if((num_values * sizeof(uint32_t)) > cell_length-sizeof(uint32_t))
    915917  {
    916918    regfi_add_message(file, REGFI_MSG_WARN, "Too many values found"
     
    918920    if(strict)
    919921      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);
    924926  ret_val = talloc(NULL, REGFI_VALUE_LIST);
    925927  if(ret_val == NULL)
     
    935937
    936938  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)
    938940     || length != read_len)
    939941  {
     
    973975/******************************************************************************
    974976 ******************************************************************************/
    975 REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32 offset,
     977REGFI_VK_REC* regfi_load_value(REGFI_FILE* file, uint32_t offset,
    976978                               REGFI_ENCODING output_encoding, bool strict)
    977979{
    978980  REGFI_VK_REC* ret_val = NULL;
    979   int32 max_size, tmp_size;
     981  int32_t max_size, tmp_size;
    980982  REGFI_ENCODING from_encoding;
    981983
     
    10031005  {
    10041006    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);
    10061008    ret_val->valuename_raw[ret_val->name_length] = '\0';
    10071009    ret_val->valuename = (char*)ret_val->valuename_raw;
     
    10381040 * If !strict, the list may contain NULLs, VK records may point to NULL.
    10391041 ******************************************************************************/
    1040 REGFI_VALUE_LIST* regfi_load_valuelist(REGFI_FILE* file, uint32 offset,
    1041                                        uint32 num_values, uint32 max_size,
     1042REGFI_VALUE_LIST* regfi_load_valuelist(REGFI_FILE* file, uint32_t offset,
     1043                                       uint32_t num_values, uint32_t max_size,
    10421044                                       bool strict)
    10431045{
    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)
    10471049  {
    10481050    regfi_add_message(file, REGFI_MSG_WARN, "Number of values indicated by"
     
    10521054    if(strict)
    10531055      return NULL;
    1054     usable_num_values = max_size/sizeof(uint32) - sizeof(uint32);
     1056    usable_num_values = max_size/sizeof(uint32_t) - sizeof(uint32_t);
    10551057  }
    10561058  else
     
    10651067 *
    10661068 ******************************************************************************/
    1067 REGFI_NK_REC* regfi_load_key(REGFI_FILE* file, uint32 offset,
     1069REGFI_NK_REC* regfi_load_key(REGFI_FILE* file, uint32_t offset,
    10681070                             REGFI_ENCODING output_encoding, bool strict)
    10691071{
    10701072  REGFI_NK_REC* nk;
    1071   uint32 off;
    1072   int32 max_size, tmp_size;
     1073  uint32_t off;
     1074  int32_t max_size, tmp_size;
    10731075  REGFI_ENCODING from_encoding;
    10741076
     
    10971099  if(from_encoding == output_encoding)
    10981100  {
    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);
    11001102    nk->keyname_raw[nk->name_length] = '\0';
    11011103    nk->keyname = (char*)nk->keyname_raw;
     
    11961198/******************************************************************************
    11971199 ******************************************************************************/
    1198 const REGFI_SK_REC* regfi_load_sk(REGFI_FILE* file, uint32 offset, bool strict)
     1200const REGFI_SK_REC* regfi_load_sk(REGFI_FILE* file, uint32_t offset, bool strict)
    11991201{
    12001202  REGFI_SK_REC* ret_val = NULL;
    1201   int32 max_size;
     1203  int32_t max_size;
    12021204  void* failure_ptr = NULL;
    12031205 
     
    12401242{
    12411243  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;
    12451247  bool unalloc;
    12461248
     
    13011303  REGFI_FILE* rb;
    13021304  REGFI_HBIN* hbin = NULL;
    1303   uint32 hbin_off, file_length, cache_secret;
     1305  uint32_t hbin_off, file_length, cache_secret;
    13041306  bool rla;
    13051307
     
    13971399  REGFI_NK_REC* nk = NULL;
    13981400  REGFI_HBIN* hbin;
    1399   uint32 root_offset, i, num_hbins;
     1401  uint32_t root_offset, i, num_hbins;
    14001402 
    14011403  if(!file)
     
    15841586  REGFI_NK_REC* subkey;
    15851587  bool found = false;
    1586   uint32 old_subkey = i->cur_subkey;
     1588  uint32_t old_subkey = i->cur_subkey;
    15871589
    15881590  if(subkey_name == NULL)
     
    16181620bool regfi_iterator_walk_path(REGFI_ITERATOR* i, const char** path)
    16191621{
    1620   uint32 x;
     1622  uint32_t x;
    16211623  if(path == NULL)
    16221624    return false;
     
    16711673REGFI_NK_REC* regfi_iterator_cur_subkey(REGFI_ITERATOR* i)
    16721674{
    1673   uint32 nk_offset;
     1675  uint32_t nk_offset;
    16741676
    16751677  /* see if there is anything left to report */
     
    17081710  REGFI_VK_REC* cur;
    17091711  bool found = false;
    1710   uint32 old_value = i->cur_value;
     1712  uint32_t old_value = i->cur_value;
    17111713
    17121714  /* XXX: cur->valuename can be NULL in the registry. 
     
    17541756{
    17551757  REGFI_VK_REC* ret_val = NULL;
    1756   uint32 voffset;
     1758  uint32_t voffset;
    17571759
    17581760  if(i->cur_key->values != NULL && i->cur_key->values->elements != NULL)
     
    17911793{
    17921794  REGFI_CLASSNAME* ret_val;
    1793   uint8* raw;
     1795  uint8_t* raw;
    17941796  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;
    17981800
    17991801  if(key->classname_off == REGFI_OFFSET_NONE || key->classname_length == 0)
     
    19351937 *****************************************************************************/
    19361938bool 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;
    19431945
    19441946  if(data == NULL)
     
    19511953  /* REG_LINK is a symbolic link, stored as a unicode string. */
    19521954  case REG_LINK:
    1953     tmp_str = talloc_array(NULL, uint8, data->size);
     1955    tmp_str = talloc_array(NULL, uint8_t, data->size);
    19541956    if(tmp_str == NULL)
    19551957    {
     
    19741976    }
    19751977
    1976     tmp_str = talloc_realloc(NULL, tmp_str, uint8, tmp_size);
     1978    tmp_str = talloc_realloc(NULL, tmp_str, uint8_t, tmp_size);
    19771979    data->interpreted.string = tmp_str;
    19781980    data->interpreted_size = tmp_size;
     
    20102012    }
    20112013    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);
    20132015    data->interpreted_size = 8;
    20142016    break;
    20152017   
    20162018  case REG_MULTI_SZ:
    2017     tmp_str = talloc_array(NULL, uint8, data->size);
     2019    tmp_str = talloc_array(NULL, uint8_t, data->size);
    20182020    if(tmp_str == NULL)
    20192021    {
     
    20422044
    20432045    array_size = tmp_size+1;
    2044     tmp_array = talloc_array(NULL, uint8*, array_size);
     2046    tmp_array = talloc_array(NULL, uint8_t*, array_size);
    20452047    if(tmp_array == NULL)
    20462048    {
     
    20582060    }
    20592061    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);
    20612063    data->interpreted.multiple_string = tmp_array;
    20622064    /* XXX: how meaningful is this?  should we store number of strings instead? */
     
    21072109 * On error, returns a negative errno code.
    21082110 *****************************************************************************/
    2109 int32 regfi_conv_charset(const char* input_charset, const char* output_charset,
    2110                          uint8* input, char* output,
    2111                          uint32 input_len, uint32 output_max)
     2111int32_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)
    21122114{
    21132115  iconv_t conv_desc;
     
    21442146 * buffer must be at least the size of a regf header (4096 bytes).
    21452147 *******************************************************************/
    2146 static uint32 regfi_compute_header_checksum(uint8* buffer)
    2147 {
    2148   uint32 checksum, x;
     2148static uint32_t regfi_compute_header_checksum(uint8_t* buffer)
     2149{
     2150  uint32_t checksum, x;
    21492151  int i;
    21502152
     
    21672169REGFI_FILE* regfi_parse_regf(int fd, bool strict)
    21682170{
    2169   uint8 file_header[REGFI_REGF_SIZE];
    2170   uint32 length;
     2171  uint8_t file_header[REGFI_REGF_SIZE];
     2172  uint32_t length;
    21712173  REGFI_FILE* ret_val;
    21722174
     
    22432245 * along with it's associated cells.
    22442246 ******************************************************************************/
    2245 REGFI_HBIN* regfi_parse_hbin(REGFI_FILE* file, uint32 offset, bool strict)
     2247REGFI_HBIN* regfi_parse_hbin(REGFI_FILE* file, uint32_t offset, bool strict)
    22462248{
    22472249  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;
    22502252 
    22512253  if(offset >= file->file_length)
     
    23152317/*******************************************************************
    23162318 *******************************************************************/
    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];
     2319REGFI_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];
    23212323  REGFI_NK_REC* ret_val;
    2322   uint32 length,cell_length;
     2324  uint32_t length,cell_length;
    23232325  bool unalloc = false;
    23242326
     
    24322434  }
    24332435
    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);
    24352437  if(ret_val->keyname_raw == NULL)
    24362438  {
     
    24412443  /* Don't need to seek, should be at the right offset */
    24422444  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)
    24442446     || length != ret_val->name_length)
    24452447  {
     
    24542456
    24552457
    2456 uint8* regfi_parse_classname(REGFI_FILE* file, uint32 offset,
    2457                              uint16* name_length, uint32 max_size, bool strict)
    2458 {
    2459   uint8* ret_val = NULL;
    2460   uint32 length;
    2461   uint32 cell_length;
     2458uint8_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;
    24622464  bool unalloc = false;
    24632465
     
    24992501    }
    25002502   
    2501     ret_val = talloc_array(NULL, uint8, *name_length);
     2503    ret_val = talloc_array(NULL, uint8_t, *name_length);
    25022504    if(ret_val != NULL)
    25032505    {
     
    25202522/******************************************************************************
    25212523*******************************************************************************/
    2522 REGFI_VK_REC* regfi_parse_vk(REGFI_FILE* file, uint32 offset,
    2523                              uint32 max_size, bool strict)
     2524REGFI_VK_REC* regfi_parse_vk(REGFI_FILE* file, uint32_t offset,
     2525                             uint32_t max_size, bool strict)
    25242526{
    25252527  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;
    25282530  bool unalloc = false;
    25292531
     
    26042606      cell_length+=8;
    26052607
    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);
    26072609    if(ret_val->valuename_raw == NULL)
    26082610    {
     
    26122614
    26132615    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)
    26152617       || length != ret_val->name_length)
    26162618    {
     
    26382640 *
    26392641 ******************************************************************************/
    2640 REGFI_BUFFER regfi_load_data(REGFI_FILE* file, uint32 voffset,
    2641                              uint32 length, bool data_in_offset,
     2642REGFI_BUFFER regfi_load_data(REGFI_FILE* file, uint32_t voffset,
     2643                             uint32_t length, bool data_in_offset,
    26422644                             bool strict)
    26432645{
    26442646  REGFI_BUFFER ret_val;
    2645   uint32 cell_length, offset;
    2646   int32 max_size;
     2647  uint32_t cell_length, offset;
     2648  int32_t max_size;
    26472649  bool unalloc;
    26482650 
     
    27442746 * Parses the common case data records stored in a single cell.
    27452747 ******************************************************************************/
    2746 REGFI_BUFFER regfi_parse_data(REGFI_FILE* file, uint32 offset,
    2747                               uint32 length, bool strict)
     2748REGFI_BUFFER regfi_parse_data(REGFI_FILE* file, uint32_t offset,
     2749                              uint32_t length, bool strict)
    27482750{
    27492751  REGFI_BUFFER ret_val;
    2750   uint32 read_length;
     2752  uint32_t read_length;
    27512753
    27522754  ret_val.buf = NULL;
     
    27602762  }
    27612763
    2762   if((ret_val.buf = talloc_array(NULL, uint8, length)) == NULL)
     2764  if((ret_val.buf = talloc_array(NULL, uint8_t, length)) == NULL)
    27632765    return ret_val;
    27642766  ret_val.len = length;
     
    27832785 *
    27842786 ******************************************************************************/
    2785 REGFI_BUFFER regfi_parse_little_data(REGFI_FILE* file, uint32 voffset,
    2786                                      uint32 length, bool strict)
     2787REGFI_BUFFER regfi_parse_little_data(REGFI_FILE* file, uint32_t voffset,
     2788                                     uint32_t length, bool strict)
    27872789{
    27882790  REGFI_BUFFER ret_val;
    2789   uint8 i;
     2791  uint8_t i;
    27902792
    27912793  ret_val.buf = NULL;
     
    28002802  }
    28012803
    2802   if((ret_val.buf = talloc_array(NULL, uint8, length)) == NULL)
     2804  if((ret_val.buf = talloc_array(NULL, uint8_t, length)) == NULL)
    28032805    return ret_val;
    28042806  ret_val.len = length;
    28052807 
    28062808  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);
    28082810
    28092811  return ret_val;
     
    28122814/******************************************************************************
    28132815*******************************************************************************/
    2814 REGFI_BUFFER regfi_parse_big_data_header(REGFI_FILE* file, uint32 offset,
    2815                                          uint32 max_size, bool strict)
     2816REGFI_BUFFER regfi_parse_big_data_header(REGFI_FILE* file, uint32_t offset,
     2817                                         uint32_t max_size, bool strict)
    28162818{
    28172819  REGFI_BUFFER ret_val;
    2818   uint32 cell_length;
     2820  uint32_t cell_length;
    28192821  bool unalloc;
    28202822
    28212823  /* 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);
    28232825  if(ret_val.buf == NULL)
    28242826    goto fail;
     
    28662868 *
    28672869 ******************************************************************************/
    2868 uint32* regfi_parse_big_data_indirect(REGFI_FILE* file, uint32 offset,
    2869                                       uint16 num_chunks, bool strict)
    2870 {
    2871   uint32* ret_val;
    2872   uint32 indirect_length;
    2873   int32 max_size;
    2874   uint16 i;
     2870uint32_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;
    28752877  bool unalloc;
    28762878
     
    28782880
    28792881  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);
    28842886  if(ret_val == NULL)
    28852887    goto fail;
    28862888
    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),
    28892891                       &indirect_length, &unalloc))
    28902892  {
     
    28982900  for(i=0; i<num_chunks; i++)
    28992901  {
    2900     ret_val[i] = IVAL(ret_val, i*sizeof(uint32));
     2902    ret_val[i] = IVAL(ret_val, i*sizeof(uint32_t));
    29012903    if((ret_val[i] & 0x00000007) != 0)
    29022904      goto fail;
     
    29242926 *  No data in range_list elements.
    29252927 ******************************************************************************/
    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;
     2928range_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;
    29302932  range_list* ret_val;
    2931   uint16 i;
     2933  uint16_t i;
    29322934  bool unalloc;
    29332935 
     
    29652967*******************************************************************************/
    29662968REGFI_BUFFER regfi_load_big_data(REGFI_FILE* file,
    2967                                  uint32 offset, uint32 data_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,
    29692971                                 bool strict)
    29702972{
    29712973  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;
    29752977  REGFI_BUFFER bd_header;
    29762978  range_list* bd_cells = NULL;
     
    30483050    }
    30493051
    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)
    30513053    {
    30523054      regfi_add_message(file, REGFI_MSG_WARN, "Could not seek to chunk while "
     
    30953097  REGFI_HBIN* hbin;
    30963098  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;
    30983100  bool is_unalloc;
    30993101
     
    31423144  return ret_val;
    31433145}
     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****************************************************************************/
     3154void 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****************************************************************************/
     3206time_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 */
Note: See TracChangeset for help on using the changeset viewer.