Changeset 137


Ignore:
Timestamp:
01/23/09 17:58:43 (16 years ago)
Author:
tim
Message:

Added error messages to most parse functions in regfi

Relaxed validation requirements on NK types and missing value data

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/regfi.h

    r136 r137  
    111111#define REGFI_VK_MAX_DATA_LENGTH   1024*1024
    112112
     113
    113114/* NK record types */
     115/* XXX: This is starting to look like this is a flags field. 
     116 *      Need to decipher the meaning of each flag.
     117 */
    114118#define REGFI_NK_TYPE_LINKKEY      0x0010
    115119#define REGFI_NK_TYPE_NORMALKEY    0x0020
    116120 /* XXX: Unknown key type that shows up in Vista registries */
    117121#define REGFI_NK_TYPE_UNKNOWN1     0x1020
     122 /* XXX: Unknown key types that shows up in W2K3 registries */
     123#define REGFI_NK_TYPE_UNKNOWN2     0x4020
     124#define REGFI_NK_TYPE_UNKNOWN3     0x0000  /* XXX: This type seems to have UTF-16 names!!! */
    118125#define REGFI_NK_TYPE_ROOTKEY1     0x002c
    119126 /* XXX: Unknown root key type that shows up in Vista registries */
    120127#define REGFI_NK_TYPE_ROOTKEY2     0x00ac
     128
     129#if 0
     130/* Initial hypothesis of NK flags: */
     131#define REGFI_NK_FLAG_LINK         0x0010
     132/* The name will be in ASCII if this next bit is set, otherwise UTF-16LE */
     133#define REGFI_NK_FLAG_ASCIINAME    0x0020
     134/* These next two combine to form the "c" on both known root key types */
     135#define REGFI_NK_FLAG_ROOT1        0x0008
     136#define REGFI_NK_FLAG_ROOT2        0x0004
     137/* These next two show up on normal-seeming keys in Vista and W2K3 registries */
     138#define REGFI_NK_FLAG_UNKNOWN1     0x4000
     139#define REGFI_NK_FLAG_UNKNOWN2     0x1000
     140/* This next one shows up on root keys in some Vista "software" registries */
     141#define REGFI_NK_FLAG_UNKNOWN3     0x0080
     142#endif
     143
    121144
    122145
  • trunk/lib/regfi.c

    r136 r137  
    701701  if(!regfi_parse_cell(file->fd, offset, sk_header, REGFI_SK_MIN_LENGTH,
    702702                       &cell_length, &unalloc))
    703     return NULL;
     703  {
     704    regfi_add_message(file, "ERROR: Could not parse SK record cell"
     705                      " at offset 0x%.8X.", offset);
     706    return NULL;
     707  }
    704708   
    705709  if(sk_header[0] != 's' || sk_header[1] != 'k')
    706     return NULL;
    707  
     710  {
     711    regfi_add_message(file, "ERROR: Magic number mismatch in parsing SK record"
     712                      " at offset 0x%.8X.", offset);
     713    return NULL;
     714  }
     715
    708716  ret_val = (REGFI_SK_REC*)zalloc(sizeof(REGFI_SK_REC));
    709717  if(ret_val == NULL)
     
    721729     || (strict && ret_val->cell_size != (ret_val->cell_size & 0xFFFFFFF8)))
    722730  {
     731    regfi_add_message(file, "ERROR: Invalid cell size found while parsing SK"
     732                      " record at offset 0x%.8X.", offset);
    723733    free(ret_val);
    724734    return NULL;
     
    737747  if(ret_val->desc_size + REGFI_SK_MIN_LENGTH > ret_val->cell_size)
    738748  {
     749    regfi_add_message(file, "ERROR: Security descriptor too large for cell"
     750                      " while parsing SK record at offset 0x%.8X.", offset);
    739751    free(ret_val);
    740752    return NULL;
     
    752764     || length != ret_val->desc_size)
    753765  {
     766    regfi_add_message(file, "ERROR: Failed to read security descriptor"
     767                      " while parsing SK record at offset 0x%.8X.", offset);
    754768    free(ret_val);
    755769    return NULL;
     
    758772  if(!(ret_val->sec_desc = winsec_parse_desc(sec_desc_buf, ret_val->desc_size)))
    759773  {
     774    regfi_add_message(file, "ERROR: Failed to parse security descriptor"
     775                      " while parsing SK record at offset 0x%.8X.", offset);
    760776    free(sec_desc_buf);
    761777    free(ret_val);
     
    777793
    778794  if(!regfi_parse_cell(file->fd, offset, NULL, 0, &cell_length, &unalloc))
    779     return NULL;
     795  {
     796    regfi_add_message(file, "ERROR: Failed to read cell header"
     797                      " while parsing value list at offset 0x%.8X.", offset);
     798    return NULL;
     799  }
    780800
    781801  if(cell_length != (cell_length & 0xFFFFFFF8))
     
    786806  }
    787807  if((num_values * sizeof(uint32)) > cell_length-sizeof(uint32))
    788     return NULL;
     808  {
     809    regfi_add_message(file, "ERROR: Too many values found"
     810                      " while parsing value list at offset 0x%.8X.", offset);
     811    return NULL;
     812  }
    789813
    790814  read_len = num_values*sizeof(uint32);
     
    796820  if((regfi_read(file->fd, (uint8*)ret_val, &length) != 0) || length != read_len)
    797821  {
     822    regfi_add_message(file, "ERROR: Failed to read value pointers"
     823                      " while parsing value list at offset 0x%.8X.", offset);
    798824    free(ret_val);
    799825    return NULL;
     
    811837         || ((ret_val[i] & 0xFFFFFFF8) != ret_val[i]))
    812838      {
     839        regfi_add_message(file, "ERROR: Invalid value pointer (0x%.8X) found"
     840                          " while parsing value list at offset 0x%.8X.",
     841                          ret_val[i], offset);
    813842        free(ret_val);
    814843        return NULL;
     
    906935  {
    907936    regfi_add_message(file, "ERROR: Could not load NK record at"
    908                       " offset 0x%.8X.\n", offset);
     937                      " offset 0x%.8X.", offset);
    909938    return NULL;
    910939  }
     
    937966      {
    938967        regfi_add_message(file, "ERROR: Could not load value list"
    939                           " for NK record at offset 0x%.8X.\n",
     968                          " for NK record at offset 0x%.8X.",
    940969                          offset);
    941970        free(nk);
     
    10341063REGFI_FILE* regfi_open(const char* filename)
    10351064{
     1065  struct stat sbuf;
    10361066  REGFI_FILE* rb;
    10371067  REGFI_HBIN* hbin = NULL;
    1038   uint32 hbin_off;
     1068  uint32 hbin_off, file_length;
    10391069  int fd;
    10401070  bool rla;
     
    10471077  }
    10481078 
     1079  /* Determine file length.  Must be at least big enough
     1080   * for the header and one hbin.
     1081   */
     1082  if (fstat(fd, &sbuf) == -1)
     1083    return NULL;
     1084  file_length = sbuf.st_size;
     1085  if(file_length < REGFI_REGF_SIZE+REGFI_HBIN_ALLOC)
     1086    return NULL;
     1087
    10491088  /* read in an existing file */
    10501089  if ((rb = regfi_parse_regf(fd, true)) == NULL)
     
    10541093    return NULL;
    10551094  }
    1056  
     1095  rb->file_length = file_length; 
     1096
    10571097  rb->hbins = range_list_new();
    10581098  if(rb->hbins == NULL)
     
    10691109  while(hbin && rla)
    10701110  {
     1111    rla = range_list_add(rb->hbins, hbin->file_off, hbin->block_size, hbin);
    10711112    hbin_off = hbin->file_off + hbin->block_size;
    1072     rla = range_list_add(rb->hbins, hbin->file_off, hbin->block_size, hbin);
     1113    /*fprintf(stderr, "file_length=%.8X,hbin_off=%.8X,hbin->block_size=%.8X,hbin->next_block=%.8X\n",
     1114      file_length, hbin_off, hbin->block_size, hbin->next_block);*/
    10731115    hbin = regfi_parse_hbin(rb, hbin_off, true);
    10741116  }
     
    15501592  uint8 file_header[REGFI_REGF_SIZE];
    15511593  uint32 length;
    1552   uint32 file_length;
    1553   struct stat sbuf;
    15541594  REGFI_FILE* ret_val;
    1555 
    1556   /* Determine file length.  Must be at least big enough
    1557    * for the header and one hbin.
    1558    */
    1559   if (fstat(fd, &sbuf) == -1)
    1560     return NULL;
    1561   file_length = sbuf.st_size;
    1562   if(file_length < REGFI_REGF_SIZE+REGFI_HBIN_ALLOC)
    1563     return NULL;
    15641595
    15651596  ret_val = (REGFI_FILE*)zalloc(sizeof(REGFI_FILE));
     
    15681599
    15691600  ret_val->fd = fd;
    1570   ret_val->file_length = file_length;
    15711601
    15721602  length = REGFI_REGF_SIZE;
     
    16301660
    16311661  if(lseek(file->fd, offset, SEEK_SET) == -1)
    1632     return NULL;
     1662  {
     1663    regfi_add_message(file, "ERROR: Seek failed"
     1664                      " while parsing hbin at offset 0x%.8X.", offset);
     1665    return NULL;
     1666  }
    16331667
    16341668  length = REGFI_HBIN_HEADER_SIZE;
     
    16371671    return NULL;
    16381672
    1639 
    16401673  if(lseek(file->fd, offset, SEEK_SET) == -1)
    1641     return NULL;
     1674  {
     1675    regfi_add_message(file, "ERROR: Seek failed"
     1676                      " while parsing hbin at offset 0x%.8X.", offset);
     1677    return NULL;
     1678  }
    16421679
    16431680  if(!(hbin = (REGFI_HBIN*)zalloc(sizeof(REGFI_HBIN))))
     
    16481685  if(strict && (memcmp(hbin->magic, "hbin", 4) != 0))
    16491686  {
     1687    /* XXX: add this back in when we have configurable verbosity. */
     1688    /*    regfi_add_message(file, "INFO: Magic number mismatch (%.2X %.2X %.2X %.2X)"
     1689                      " while parsing hbin at offset 0x%.8X.", hbin->magic[0],
     1690                      hbin->magic[1], hbin->magic[2], hbin->magic[3], offset); */
    16501691    free(hbin);
    16511692    return NULL;
     
    16541695  hbin->first_hbin_off = IVAL(hbin_header, 0x4);
    16551696  hbin->block_size = IVAL(hbin_header, 0x8);
     1697    /*fprintf(stderr, "hbin->block_size field => %.8X\n", IVAL(hbin_header, 0x8));*/
     1698  /*  hbin->block_size = IVAL(hbin_header, 0x8);*/
    16561699  /* this should be the same thing as hbin->block_size but just in case */
    16571700  hbin->next_block = IVAL(hbin_header, 0x1C);
     
    16671710     || (hbin->block_size & 0xFFFFF000) != hbin->block_size)
    16681711  {
     1712    regfi_add_message(file, "ERROR: The hbin offset is not aligned"
     1713                      " or runs off the end of the file"
     1714                      " while parsing hbin at offset 0x%.8X.", offset);
    16691715    free(hbin);
    16701716    return NULL;
     
    16891735  if(!regfi_parse_cell(file->fd, offset, nk_header, REGFI_NK_MIN_LENGTH,
    16901736                       &cell_length, &unalloc))
    1691      return NULL;
    1692  
     1737  {
     1738    regfi_add_message(file, "ERROR: Could not parse cell header"
     1739                      " while parsing NK record at offset 0x%.8X.", offset);
     1740    return NULL;
     1741  }
     1742
    16931743  /* A bit of validation before bothering to allocate memory */
    16941744  if((nk_header[0x0] != 'n') || (nk_header[0x1] != 'k'))
    16951745  {
    16961746    regfi_add_message(file, "ERROR: Magic number mismatch in parsing NK record"
    1697                       " at offset 0x%.8X.\n", offset);
     1747                      " at offset 0x%.8X.", offset);
    16981748    return NULL;
    16991749  }
     
    17031753  {
    17041754    regfi_add_message(file, "ERROR: Failed to allocate memory while"
    1705                       " parsing NK record at offset 0x%.8X.\n", offset);
     1755                      " parsing NK record at offset 0x%.8X.", offset);
    17061756    return NULL;
    17071757  }
     
    17161766  {
    17171767    regfi_add_message(file, "ERROR: A length check failed while parsing"
    1718                       " NK record at offset 0x%.8X.\n", offset);
     1768                      " NK record at offset 0x%.8X.", offset);
    17191769    free(ret_val);
    17201770    return NULL;
     
    17281778     && (ret_val->key_type != REGFI_NK_TYPE_ROOTKEY2)
    17291779     && (ret_val->key_type != REGFI_NK_TYPE_LINKKEY)
    1730      && (ret_val->key_type != REGFI_NK_TYPE_UNKNOWN1))
    1731   {
    1732     regfi_add_message(file, "ERROR: Unknown key type (0x%.4X) while parsing"
    1733                       " NK record at offset 0x%.8X.\n", ret_val->key_type,
     1780     && (ret_val->key_type != REGFI_NK_TYPE_UNKNOWN1)
     1781     && (ret_val->key_type != REGFI_NK_TYPE_UNKNOWN2)
     1782     && (ret_val->key_type != REGFI_NK_TYPE_UNKNOWN3))
     1783  {
     1784    regfi_add_message(file, "WARN: Unknown key type (0x%.4X) while parsing"
     1785                      " NK record at offset 0x%.8X.", ret_val->key_type,
    17341786                      offset);
    1735     free(ret_val);
    1736     return NULL;
    17371787  }
    17381788
     
    17751825    if(strict)
    17761826    {
     1827      regfi_add_message(file, "ERROR: Contents too large for cell"
     1828                        " while parsing NK record at offset 0x%.8X.", offset);
    17771829      free(ret_val);
    17781830      return NULL;
     
    18051857     || length != ret_val->name_length)
    18061858  {
     1859    regfi_add_message(file, "ERROR: Failed to read key name"
     1860                      " while parsing NK record at offset 0x%.8X.", offset);
    18071861    free(ret_val->keyname);
    18081862    free(ret_val);
     
    18231877    }
    18241878    else
     1879    {
    18251880      ret_val->classname = NULL;
    1826     /*
     1881      regfi_add_message(file, "WARN: Could not find hbin for class name"
     1882                        " while parsing NK record at offset 0x%.8X.", offset);
     1883    }
     1884    /* XXX: Should add this back and make it more strict?
    18271885    if(strict && ret_val->classname == NULL)
    18281886        return NULL;
    18291887    */
    18301888  }
    1831 
     1889  /*
     1890if(ret_val->key_type == 0x0000 || ret_val->key_type == 0x4020)
     1891{
     1892  fprintf(stderr, "INFO: keyname=%s,classname=%s,unalloc=%d,num_subkeys=%d,num_values=%d\n",
     1893          ret_val->keyname,ret_val->classname,unalloc,ret_val->num_subkeys,ret_val->num_values);
     1894}
     1895  */
    18321896  return ret_val;
    18331897}
     
    18461910  {
    18471911    if(!regfi_parse_cell(file->fd, offset, NULL, 0, &cell_length, &unalloc))
     1912    {
     1913      regfi_add_message(file, "ERROR: Could not parse cell header"
     1914                        " while parsing class name at offset 0x%.8X.", offset);
    18481915        return NULL;
     1916    }
    18491917
    18501918    if((cell_length & 0xFFFFFFF8) != cell_length)
     1919    {
     1920      regfi_add_message(file, "ERROR: Cell length not a multiple of 8"
     1921                        " while parsing class name at offset 0x%.8X.", offset);
    18511922      return NULL;
    1852    
     1923    }
     1924
    18531925    if(cell_length > max_size)
    18541926    {
     1927      regfi_add_message(file, "WARN: Cell stretches past hbin boundary"
     1928                        " while parsing class name at offset 0x%.8X.", offset);
    18551929      if(strict)
    18561930        return NULL;
     
    18601934    if((cell_length - 4) < *name_length)
    18611935    {
     1936      regfi_add_message(file, "WARN: Class name is larger than cell_length"
     1937                        " while parsing class name at offset 0x%.8X.", offset);
    18621938      if(strict)
    18631939        return NULL;
     
    18721948         || length != *name_length)
    18731949      {
     1950        regfi_add_message(file, "ERROR: Could not read class name"
     1951                          " while parsing class name at offset 0x%.8X.", offset);
    18741952        free(ret_val);
    18751953        return NULL;
    18761954      }
    1877 
    1878       /*printf("==> cell_length=%d, classname_length=%d, max_bytes_subkeyclassname=%d\n", cell_length, ret_val->classname_length, ret_val->max_bytes_subkeyclassname);*/
    18791955    }
    18801956  }
     
    18981974  if(!regfi_parse_cell(file->fd, offset, vk_header, REGFI_VK_MIN_LENGTH,
    18991975                       &cell_length, &unalloc))
    1900     return NULL;
     1976  {
     1977    regfi_add_message(file, "ERROR: Could not parse cell header"
     1978                      " while parsing VK record at offset 0x%.8X.", offset);
     1979    return NULL;
     1980  }
    19011981
    19021982  ret_val = (REGFI_VK_REC*)zalloc(sizeof(REGFI_VK_REC));
     
    19121992     || ret_val->cell_size != (ret_val->cell_size & 0xFFFFFFF8))
    19131993  {
     1994    regfi_add_message(file, "ERROR: Invalid cell size encountered"
     1995                      " while parsing VK record at offset 0x%.8X.", offset);
    19141996    free(ret_val);
    19151997    return NULL;
     
    19242006     *      0xFFFF.
    19252007     */
     2008    regfi_add_message(file, "ERROR: Magic number mismatch"
     2009                      " while parsing VK record at offset 0x%.8X.", offset);
    19262010    free(ret_val);
    19272011    return NULL;
     
    19412025    if(ret_val->name_length + REGFI_VK_MIN_LENGTH + 4 > ret_val->cell_size)
    19422026    {
     2027      regfi_add_message(file, "WARN: Name too long for remaining cell space"
     2028                        " while parsing VK record at offset 0x%.8X.", offset);
    19432029      if(strict)
    19442030      {
     
    19662052       || length != ret_val->name_length)
    19672053    {
     2054      regfi_add_message(file, "ERROR: Could not read value name"
     2055                        " while parsing VK record at offset 0x%.8X.", offset);
    19682056      free(ret_val->valuename);
    19692057      free(ret_val);
     
    20042092      }
    20052093      else
     2094      {
     2095        regfi_add_message(file, "WARN: Could not find hbin for data"
     2096                          " while parsing VK record at offset 0x%.8X.", offset);
    20062097        ret_val->data = NULL;
    2007     }
    2008 
    2009     if(strict && (ret_val->data == NULL))
    2010     {
    2011       free(ret_val->valuename);
    2012       free(ret_val);
    2013       return NULL;
     2098      }
     2099    }
     2100
     2101    if(ret_val->data == NULL)
     2102    {
     2103      regfi_add_message(file, "WARN: Could not parse data record"
     2104                        " while parsing VK record at offset 0x%.8X.", offset);
    20142105    }
    20152106  }
     
    20272118  bool unalloc;
    20282119
    2029   /* The data is stored in the offset if the size <= 4 */
     2120  /* The data is typically stored in the offset if the size <= 4 */
    20302121  if (length & REGFI_VK_DATA_IN_OFFSET)
    20312122  {
    20322123    length = length & ~REGFI_VK_DATA_IN_OFFSET;
    20332124    if(length > 4)
     2125    {
     2126      regfi_add_message(file, "ERROR: Data in offset but length > 4"
     2127                        " while parsing data record at offset 0x%.8X.",
     2128                        offset);
    20342129      return NULL;
     2130    }
    20352131
    20362132    if((ret_val = (uint8*)zalloc(sizeof(uint8)*length)) == NULL)
     
    20442140    if(!regfi_parse_cell(file->fd, offset, NULL, 0,
    20452141                         &cell_length, &unalloc))
     2142    {
     2143      regfi_add_message(file, "ERROR: Could not parse cell while"
     2144                        " parsing data record at offset 0x%.8X.", offset);
    20462145      return NULL;
     2146    }
    20472147
    20482148    if((cell_length & 0xFFFFFFF8) != cell_length)
     2149    {
     2150      regfi_add_message(file, "ERROR: Cell length not multiple of 8"
     2151                        " while parsing data record at offset 0x%.8X.",
     2152                        offset);
    20492153      return NULL;
     2154    }
    20502155
    20512156    if(cell_length > max_size)
    20522157    {
     2158      regfi_add_message(file, "WARN: Cell extends past hbin boundary"
     2159                        " while parsing data record at offset 0x%.8X.",
     2160                        offset);
    20532161      if(strict)
    20542162        return NULL;
     
    20632171       *      such as 53392.
    20642172       */
     2173      regfi_add_message(file, "WARN: Data length (0x%.8X) larger than"
     2174                        " remaining cell length (0x%.8X)"
     2175                        " while parsing data record at offset 0x%.8X.",
     2176                        length, cell_length - 4, offset);
    20652177      if(strict)
    20662178        return NULL;
     
    20762188       || read_length != length)
    20772189    {
     2190      regfi_add_message(file, "ERROR: Could not read data block while"
     2191                        " parsing data record at offset 0x%.8X.", offset);
    20782192      free(ret_val);
    20792193      return NULL;
  • trunk/src/common.c

    r136 r137  
    3838}
    3939
     40void printMsgs(REGFI_ITERATOR* iter)
     41{
     42  char* msgs = regfi_get_messages(iter->f);
     43  if(msgs != NULL)
     44  {
     45    fprintf(stderr, "%s", msgs);
     46    free(msgs);
     47  }
     48}
     49
    4050
    4151/* Returns a newly malloc()ed string which contains original buffer,
     
    205215 * is the responsibility of the caller to free both a non-NULL return
    206216 * value, and a non-NULL (*error_msg).
     217 */
     218/* XXX: Part of this function's logic should be pushed into the regfi API.
     219 *      The structures should be parsed and stored with VK records and only
     220 *      escaped/encoded later in reglookup and reglookup-recover.
    207221 */
    208222static char* data_to_ascii(unsigned char* datap, uint32 len, uint32 type,
  • trunk/src/reglookup.c

    r136 r137  
    6767  if(size > REGFI_VK_MAX_DATA_LENGTH)
    6868  {
    69     fprintf(stderr, "WARNING: value data size %d larger than "
     69    fprintf(stderr, "WARN: value data size %d larger than "
    7070            "%d, truncating...\n", size, REGFI_VK_MAX_DATA_LENGTH);
    7171    size = REGFI_VK_MAX_DATA_LENGTH;
     
    9090  {
    9191    if(conv_error == NULL)
    92       fprintf(stderr, "WARNING: Could not quote value for '%s/%s'.  "
     92      fprintf(stderr, "WARN: Could not quote value for '%s/%s'.  "
    9393              "Memory allocation failure likely.\n", prefix, quoted_name);
    9494    else if(print_verbose)
    95       fprintf(stderr, "WARNING: Could not quote value for '%s/%s'.  "
     95      fprintf(stderr, "WARN: Could not quote value for '%s/%s'.  "
    9696              "Returned error: %s\n", prefix, quoted_name, conv_error);
    9797  }
     
    129129
    130130
    131 
    132 /* XXX: Each chunk must be unquoted after it is split out.
    133  *      Quoting syntax may need to be standardized and pushed into the API
    134  *      to deal with this issue and others.
    135  */
    136131char** splitPath(const char* s)
    137132{
     
    200195
    201196/* Returns a quoted path from an iterator's stack */
    202 /* XXX: Some way should be found to integrate this into regfi's API
    203  *      The problem is that the escaping is sorta reglookup-specific.
    204  */
    205197char* iter2Path(REGFI_ITERATOR* i)
    206198{
     
    273265
    274266
    275 void printValueList(REGFI_ITERATOR* i, char* prefix)
     267void printValueList(REGFI_ITERATOR* iter, char* prefix)
    276268{
    277269  const REGFI_VK_REC* value;
    278270
    279   value = regfi_iterator_first_value(i);
     271  value = regfi_iterator_first_value(iter);
    280272  while(value != NULL)
    281273  {
    282274    if(!type_filter_enabled || (value->type == type_filter))
    283275      printValue(value, prefix);
    284     value = regfi_iterator_next_value(i);
    285   }
    286 }
    287 
    288 
    289 void printKey(REGFI_ITERATOR* i, char* full_path)
     276    value = regfi_iterator_next_value(iter);
     277    printMsgs(iter);
     278  }
     279}
     280
     281
     282void printKey(REGFI_ITERATOR* iter, char* full_path)
    290283{
    291284  static char empty_str[1] = "";
     
    300293  struct tm* tmp_time_s = NULL;
    301294  const REGFI_SK_REC* sk;
    302   const REGFI_NK_REC* k = regfi_iterator_cur_key(i);
     295  const REGFI_NK_REC* k = regfi_iterator_cur_key(iter);
    303296
    304297  *tmp_time = nt_time_to_unix(&k->mtime);
     
    306299  strftime(mtime, sizeof(mtime), "%Y-%m-%d %H:%M:%S", tmp_time_s);
    307300
    308   if(print_security && (sk=regfi_iterator_cur_sk(i)))
     301  if(print_security && (sk=regfi_iterator_cur_sk(iter)))
    309302  {
    310303    owner = regfi_get_owner(sk->sec_desc);
     
    340333      {
    341334        if(print_verbose)
    342           fprintf(stderr, "WARNING: While converting classname"
     335          fprintf(stderr, "WARN: While converting classname"
    343336                  " for key '%s': %s.\n", full_path, error_msg);
    344337        free(error_msg);
     
    348341      quoted_classname = empty_str;
    349342
     343    printMsgs(iter);
    350344    printf("%s,KEY,,%s,%s,%s,%s,%s,%s\n", full_path, mtime,
    351345           owner, group, sacl, dacl, quoted_classname);
     
    373367  const REGFI_NK_REC* sub = NULL;
    374368  char* path = NULL;
    375   char* msgs = NULL;
    376369  int key_type = regfi_type_str2val("KEY");
    377370  bool print_this = true;
     
    379372  root = cur = regfi_iterator_cur_key(iter);
    380373  sub = regfi_iterator_first_subkey(iter);
    381   msgs = regfi_get_messages(iter->f);
    382   if(msgs != NULL)
    383     fprintf(stderr, "%s", msgs);
     374  printMsgs(iter);
     375
    384376  if(root == NULL)
    385377    bailOut(EX_DATAERR, "ERROR: root cannot be NULL.\n");
     
    392384      if(path == NULL)
    393385        bailOut(EX_OSERR, "ERROR: Could not construct iterator's path.\n");
    394      
     386
    395387      if(!type_filter_enabled || (key_type == type_filter))
    396388        printKey(iter, path);
     
    407399        /* We're done with this sub-tree, going up and hitting other branches. */
    408400        if(!regfi_iterator_up(iter))
     401        {
     402          printMsgs(iter);
    409403          bailOut(EX_DATAERR, "ERROR: could not traverse iterator upward.\n");
    410        
     404        }
     405
    411406        cur = regfi_iterator_cur_key(iter);
    412407        if(cur == NULL)
     408        {
     409          printMsgs(iter);
    413410          bailOut(EX_DATAERR, "ERROR: unexpected NULL for key.\n");
    414        
     411        }
     412
    415413        sub = regfi_iterator_next_subkey(iter);
    416414      }
     
    422420       */
    423421      if(!regfi_iterator_down(iter))
     422      {
     423        printMsgs(iter);
    424424        bailOut(EX_DATAERR, "ERROR: could not traverse iterator downward.\n");
     425      }
    425426
    426427      cur = sub;
     
    428429      print_this = true;
    429430    }
     431    printMsgs(iter);
    430432  } while(!((cur == root) && (sub == NULL)));
    431433
     
    479481  if(!regfi_iterator_walk_path(iter, tmp_path))
    480482  {
     483    printMsgs(iter);
    481484    free(tmp_path);
    482485    return 0;
     
    489492
    490493    value = regfi_iterator_cur_value(iter);
     494    printMsgs(iter);
    491495    tmp_path_joined = iter2Path(iter);
    492496
     
    503507  else if(regfi_iterator_find_subkey(iter, path[i]))
    504508  {
     509    printMsgs(iter);
    505510    if(print_verbose)
    506511      fprintf(stderr, "VERBOSE: Found final path element as key.\n");
    507512
    508513    if(!regfi_iterator_down(iter))
     514    {
     515      printMsgs(iter);
    509516      bailOut(EX_DATAERR, "ERROR: Unexpected error on traversing path filter key.\n");
     517    }
    510518
    511519    return 2;
    512520  }
     521  printMsgs(iter);
    513522
    514523  if(print_verbose)
     
    625634  {
    626635    retr_path_ret = retrievePath(iter, path);
     636    printMsgs(iter);
    627637    freePath(path);
    628638
    629639    if(retr_path_ret == 0)
    630       fprintf(stderr, "WARNING: specified path not found.\n");
     640      fprintf(stderr, "WARN: specified path not found.\n");
    631641    else if (retr_path_ret == 2)
    632642      printKeyTree(iter);
Note: See TracChangeset for help on using the changeset viewer.