Changeset 172 for trunk/src


Ignore:
Timestamp:
03/07/10 22:04:34 (14 years ago)
Author:
tim
Message:

reorganized name interpretation code to correct issues in reglookup-recover

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/common.c

    r171 r172  
    310310  return NULL;
    311311}
     312
     313
     314static char* get_quoted_keyname(const REGFI_NK_REC* nk)
     315{
     316  char* ret_val;
     317
     318  if(nk->keyname == NULL)
     319    ret_val = quote_buffer(nk->keyname_raw, nk->name_length, key_special_chars);
     320  else
     321    ret_val = quote_string(nk->keyname, key_special_chars);
     322
     323  return ret_val;
     324}
     325
     326
     327static char* get_quoted_valuename(const REGFI_VK_REC* vk)
     328{
     329  char* ret_val;
     330
     331  if(vk->valuename == NULL)
     332    ret_val = quote_buffer(vk->valuename_raw, vk->name_length,
     333                           key_special_chars);
     334  else
     335    ret_val = quote_string(vk->valuename, key_special_chars);
     336
     337  return ret_val;
     338}
  • trunk/src/reglookup-recover.c

    r168 r172  
    7979  strftime(mtime, sizeof(mtime), "%Y-%m-%d %H:%M:%S", tmp_time_s);
    8080
    81   quoted_name = quote_string(nk->keyname, key_special_chars);
     81  /* XXX: Add command line option to choose output encoding */
     82  regfi_interpret_keyname(f, nk, REGFI_ENCODING_ASCII, true);
     83
     84  quoted_name = get_quoted_keyname(nk);
    8285  if (quoted_name == NULL)
    8386  {
     
    104107
    105108
    106 void printValue(REGFI_FILE* f, const REGFI_VK_REC* vk, const char* prefix)
     109void printValue(REGFI_FILE* f, REGFI_VK_REC* vk, const char* prefix)
    107110{
    108111  char* quoted_value = NULL;
     
    112115  const char* str_type = NULL;
    113116
    114   quoted_name = quote_string(vk->valuename, key_special_chars);
     117  /* XXX: Add command line option to choose output encoding */
     118  regfi_interpret_valuename(f, vk, REGFI_ENCODING_ASCII, true);
     119 
     120  quoted_name = get_quoted_valuename(vk);
    115121  if (quoted_name == NULL)
    116122  { /* Value names are NULL when we're looking at the "(default)" value.
     
    120126     * this value.
    121127     */
    122     quoted_name = malloc(1*sizeof(char));
     128    quoted_name = strdup("");
    123129    if(quoted_name == NULL)
    124130      bailOut(REGLOOKUP_EXIT_OSERR, "ERROR: Could not allocate sufficient memory.\n");
    125     quoted_name[0] = '\0';
    126   }
     131  }
     132
    127133  /* XXX: Add command line option to choose output encoding */
    128134  if(vk->data != NULL
     
    278284        path_element = talloc(path_stack, REGFI_BUFFER);
    279285        if(path_element != NULL)
    280           path_element->buf = (uint8_t*)quote_string(cur_ancestor->keyname,
    281                                                    key_special_chars);
     286        {
     287          /* XXX: Add command line option to choose output encoding */
     288          regfi_interpret_keyname(f, cur_ancestor, REGFI_ENCODING_ASCII, true);
    282289         
     290          path_element->buf = (uint8_t*)get_quoted_keyname(cur_ancestor);
     291        }
     292 
    283293        if(path_element == NULL || path_element->buf == NULL
    284294           || !void_stack_push(path_stack, path_element))
     
    929939    if(tmp_key->num_values > 0 && tmp_key->values != NULL)
    930940    {
    931       tmp_name = quote_string(tmp_key->keyname, key_special_chars);
     941      /* XXX: Add command line option to choose output encoding */
     942      regfi_interpret_keyname(f, tmp_key, REGFI_ENCODING_ASCII, true);
     943
     944      tmp_name = get_quoted_keyname(tmp_key);
    932945      tmp_path = (char*)malloc(strlen(parent_paths[i])+strlen(tmp_name)+2);
    933946      if(tmp_path == NULL)
  • trunk/src/reglookup.c

    r170 r172  
    6363  struct tm* tmp_time_s = NULL;
    6464
    65   if(vk->valuename == NULL)
    66     quoted_name = quote_buffer(vk->valuename_raw, vk->name_length,
    67                                key_special_chars);
    68   else
    69     quoted_name = quote_string(vk->valuename, key_special_chars);
     65  quoted_name = get_quoted_valuename(vk);
    7066  if (quoted_name == NULL)
    7167  { /* Value names are NULL when we're looking at the "(default)" value.
     
    248244      tmp_key = cur->nk;
    249245
    250     if(tmp_key->keyname == NULL)
    251       name = quote_buffer(i->cur_key->keyname_raw, i->cur_key->name_length,
    252                           key_special_chars);
    253     else
    254       name = quote_string(tmp_key->keyname, key_special_chars);
     246    name = get_quoted_keyname(tmp_key);
    255247
    256248    buf[buf_len-buf_left-1] = '/';
Note: See TracChangeset for help on using the changeset viewer.