Changeset 102 for trunk/src/reglookup.c


Ignore:
Timestamp:
04/02/08 22:30:26 (16 years ago)
Author:
tim
Message:

simplified root key search routines

rewrote sk record parsing

fixed nasty bug in parsing data-in-offset

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/reglookup.c

    r97 r102  
    248248
    249249    snprintf(ascii, ascii_max, "0x%.2X%.2X%.2X%.2X",
    250              datap[0], datap[1], datap[2], datap[3]);
     250             datap[3], datap[2], datap[1], datap[0]);
    251251    return ascii;
    252252    break;
     
    259259
    260260    snprintf(ascii, ascii_max, "0x%.2X%.2X%.2X%.2X",
    261              datap[3], datap[2], datap[1], datap[0]);
     261             datap[0], datap[1], datap[2], datap[3]);
    262262    return ascii;
    263263    break;
     
    277277
    278278  /* XXX: this MULTI_SZ parser is pretty inefficient.  Should be
    279    *      redone with fewer malloc calls and better string concatenation.
     279   *      redone with fewer malloc calls and better string concatenation.
     280   *      Also, gives lame output when "\0\0" is the string.
    280281   */
    281282  case REG_MULTI_SZ:
     
    532533  const char* str_type = NULL;
    533534  uint32 size;
    534   uint8 tmp_buf[4];
    535 
    536   /* Thanks Microsoft for making this process so straight-forward!!! */
    537   /* XXX: this logic should be abstracted  and pushed into the regfi
    538    *      interface.  This includes the size limits.
     535
     536  /* Microsoft's documentation indicates that "available memory" is
     537   * the limit on value sizes.  Annoying.  We limit it to 1M which
     538   * should rarely be exceeded, unless the file is corrupt or
     539   * malicious. For more info, see:
     540   *   http://msdn2.microsoft.com/en-us/library/ms724872.aspx
    539541   */
    540   size = (vk->data_size & ~VK_DATA_IN_OFFSET);
    541   if(vk->data_size & VK_DATA_IN_OFFSET)
    542   {
    543     tmp_buf[0] = (uint8)((vk->data_off >> 3) & 0xFF);
    544     tmp_buf[1] = (uint8)((vk->data_off >> 2) & 0xFF);
    545     tmp_buf[2] = (uint8)((vk->data_off >> 1) & 0xFF);
    546     tmp_buf[3] = (uint8)(vk->data_off & 0xFF);
    547     if(size > 4)
    548     {
    549       fprintf(stderr, "WARNING: value stored in offset larger than 4. "
    550               "Truncating...\n");
    551       size = 4;
    552     }
    553     quoted_value = data_to_ascii(tmp_buf, 4, vk->type, &conv_error);
    554   }
    555   else
    556   {
    557     /* Microsoft's documentation indicates that "available memory" is
    558      * the limit on value sizes.  Annoying.  We limit it to 1M which
    559      * should rarely be exceeded, unless the file is corrupt or
    560      * malicious. For more info, see:
    561      *   http://msdn2.microsoft.com/en-us/library/ms724872.aspx
    562      */
    563     if(size > VK_MAX_DATA_LENGTH)
    564     {
    565       fprintf(stderr, "WARNING: value data size %d larger than "
    566               "%d, truncating...\n", size, VK_MAX_DATA_LENGTH);
    567       size = VK_MAX_DATA_LENGTH;
    568     }
    569 
    570     quoted_value = data_to_ascii(vk->data, vk->data_size,
    571                                  vk->type, &conv_error);
    572   }
     542  if(size > VK_MAX_DATA_LENGTH)
     543  {
     544    fprintf(stderr, "WARNING: value data size %d larger than "
     545            "%d, truncating...\n", size, VK_MAX_DATA_LENGTH);
     546    size = VK_MAX_DATA_LENGTH;
     547  }
     548 
     549  quoted_value = data_to_ascii(vk->data, vk->data_size,
     550                               vk->type, &conv_error);
     551
    573552 
    574553  /* XXX: Sometimes value names can be NULL in registry.  Need to
Note: See TracChangeset for help on using the changeset viewer.