Changeset 118 for trunk/src


Ignore:
Timestamp:
08/03/08 19:26:16 (16 years ago)
Author:
tim
Message:

improved security record extraction
other minor cleanups

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/reglookup-recover.c

    • Property svn:keywords set to Id
    r117 r118  
    1515 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
    1616 *
    17  * $Id: $
     17 * $Id$
    1818 */
    1919
     
    296296  uint32 max_length;
    297297
     298  /* The path_stack size limit should guarantee that we don't recurse forever. */
    298299  virt_offset = nk->parent_off;
    299300  while(virt_offset != REGF_OFFSET_NONE)
    300301  { 
    301     /* TODO: Need to add checks for infinite loops and/or add depth limit */
    302302    hbin = regfi_lookup_hbin(f, virt_offset);
    303303    if(hbin == NULL)
     
    372372
    373373
    374 /*
    375 void dump_cell(int fd, uint32 offset)
    376 {
    377   uint8* buf;
    378   uint32 length, j;
    379   int32 cell_length;
    380 
    381   if((lseek(fd, offset, SEEK_SET)) == -1)
    382     exit(8);
    383  
    384   length = 4;
    385   regfi_read(fd, (void*)&cell_length, &length);
    386   if(cell_length < 0)
    387     cell_length *= -1;
    388 
    389   buf = (uint8*)malloc(cell_length);
    390   if(buf == NULL)
    391     exit(9);
    392   if((lseek(fd, offset, SEEK_SET)) == -1)
    393     exit(8);
    394 
    395   length = cell_length;
    396   regfi_read(fd, buf, &length);
    397   for(j=0; j < length; j++)
    398   {
    399     printf("%.2X", buf[j]);
    400     if(j%4 == 3)
    401       printf(" ");
    402   }
    403   printf("\n");
    404   free(buf);
    405 }
    406 */
    407 
    408374static void usage(void)
    409375{
     
    544510        off = nk->values_off + REGF_BLOCKSIZE;
    545511        max_length = hbin->block_size + hbin->file_off - off;
    546         /* TODO: This is kind of a hack.  We parse all value-lists, VK records,
    547          *       and data records without regard for current allocation status. 
    548          *       On the off chance that such a record correctly parsed but is
    549          *       actually a reallocated structure used by something else, we
    550          *       simply prune it after the fact.  Would be faster to check this
    551          *       up front somehow.
     512        /* XXX: This is a hack.  We parse all value-lists, VK records,
     513         *      and data records without regard for current allocation status. 
     514         *      On the off chance that such a record correctly parsed but is
     515         *      actually a reallocated structure used by something else, we
     516         *      simply prune it after the fact.  Would be faster to check this
     517         *      up front somehow.
    552518         */
    553519        nk->values = regfi_load_valuelist(f, off, nk->num_values, max_length,
     
    706672
    707673
     674/* NOTE: unalloc_sks should be an empty range_list. */
    708675int extractSKs(REGF_FILE* f,
    709676               range_list* unalloc_cells,
     
    729696          return 20;
    730697        }
    731        
    732         if(removeRange(unalloc_cells, sk->offset, sk->cell_size))
    733         {
    734           /* TODO: This ugly hack is needed because unalloc_cells is changing
    735            *       underneath us when we find things.  Need a better approach
    736            *       so we can parse things single-pass.
    737            */
    738           i = 0;
    739           break;
    740         }
    741         else
    742           return 30;
     698        j+=sk->cell_size-8;
    743699      }
    744700    }
     701  }
     702
     703  for(i=0; i<range_list_size(unalloc_sks); i++)
     704  {
     705    cur_elem = range_list_get(unalloc_sks, i);
     706    if(!removeRange(unalloc_cells, cur_elem->offset, cur_elem->length))
     707      return 30;
    745708  }
    746709
Note: See TracChangeset for help on using the changeset viewer.