Changeset 159 for trunk/src/reglookup.c


Ignore:
Timestamp:
12/06/09 15:09:01 (14 years ago)
Author:
tim
Message:

began rearranging data parsing. Moved charater set conversion and basic parsing logic into regfi

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/reglookup.c

    r158 r159  
    5050
    5151
    52 void printValue(const REGFI_VK_REC* vk, char* prefix)
    53 {
     52void printValue(REGFI_ITERATOR* iter, const REGFI_VK_REC* vk, char* prefix)
     53{
     54  REGFI_DATA* data;
    5455  char* quoted_value = NULL;
    5556  char* quoted_name = NULL;
    5657  char* conv_error = NULL;
    5758  const char* str_type = NULL;
    58   uint32 size = vk->data_size;
    59 
    60   /* Microsoft's documentation indicates that "available memory" is
    61    * the limit on value sizes.  Annoying.  We limit it to 1M which
    62    * should rarely be exceeded, unless the file is corrupt or
    63    * malicious. For more info, see:
    64    *   http://msdn2.microsoft.com/en-us/library/ms724872.aspx
    65    */
    66   if(size > REGFI_VK_MAX_DATA_LENGTH)
    67   {
    68     fprintf(stderr, "WARN: value data size %d larger than "
    69             "%d, truncating...\n", size, REGFI_VK_MAX_DATA_LENGTH);
    70     size = REGFI_VK_MAX_DATA_LENGTH;
    71   }
    72  
     59
    7360  quoted_name = quote_string(vk->valuename, key_special_chars);
    7461  if (quoted_name == NULL)
     
    8471    quoted_name[0] = '\0';
    8572  }
    86 
    87   if(vk->data == NULL)
    88   {
    89     if(print_verbose)
    90       fprintf(stderr, "INFO: While quoting value for '%s/%s', "
    91               "data pointer was NULL.\n", prefix, quoted_name);
    92   }
    93   else
    94   {
    95     quoted_value = data_to_ascii(vk->data, size, vk->type, &conv_error);
     73 
     74  data = regfi_iterator_fetch_data(iter, vk);
     75
     76  printMsgs(iter->f);
     77  if(data != NULL)
     78  {
     79    quoted_value = data_to_ascii(data, &conv_error);
    9680    if(quoted_value == NULL)
    9781    {
     
    10387                "Returned error: %s\n", prefix, quoted_name, conv_error);
    10488    }
    105     else if(conv_error != NULL && print_verbose)
    106       fprintf(stderr, "INFO: While quoting value for '%s/%s', "
     89    else if(conv_error != NULL)
     90      fprintf(stderr, "WARN: While quoting value for '%s/%s', "
    10791              "warning returned: %s\n", prefix, quoted_name, conv_error);
     92    regfi_free_data(data);
    10893  }
    10994
     
    281266  {
    282267    if(!type_filter_enabled || (value->type == type_filter))
    283       printValue(value, prefix);
     268      printValue(iter, value, prefix);
    284269    regfi_free_value(value);
    285270    value = regfi_iterator_next_value(iter);
     
    511496
    512497    if(!type_filter_enabled || (value->type == type_filter))
    513       printValue(value, tmp_path_joined);
     498      printValue(iter, value, tmp_path_joined);
    514499
    515500    regfi_free_value(value);
     
    632617    regfi_set_message_mask(f, REGFI_MSG_INFO|REGFI_MSG_WARN|REGFI_MSG_ERROR);
    633618
    634   iter = regfi_iterator_new(f);
     619  /* XXX: add command line option to choose output encoding */
     620  iter = regfi_iterator_new(f, 0);
    635621  if(iter == NULL)
    636622  {
Note: See TracChangeset for help on using the changeset viewer.