Changeset 113 for trunk/lib


Ignore:
Timestamp:
05/04/08 14:29:02 (17 years ago)
Author:
tim
Message:

fixed some VK record parsing bugs

added more strict checking on unallocated ranges

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/range_list.c

    r111 r113  
    320320  return true;
    321321}
     322
     323
     324bool range_list_has_range(range_list* rl, uint32_t start, uint32_t length)
     325{
     326  int32_t idx1, idx2;
     327
     328  idx1 = range_list_find(rl, start);
     329  if(idx1 < 0)
     330    return false;
     331
     332  idx2 = range_list_find(rl, start+length);
     333  if(idx2 < 0)
     334    return false;
     335
     336  if(idx1 == idx2)
     337    return true;
     338
     339  while(idx1 != idx2)
     340  {
     341    if(rl->elements[idx1]->offset + rl->elements[idx1]->length
     342       != rl->elements[idx1+1]->offset)
     343      return false;
     344    idx1++;
     345  }
     346
     347  return true;
     348}
  • trunk/lib/regfi.c

    r111 r113  
    16651665  if(ret_val->flag & VK_FLAG_NAME_PRESENT)
    16661666  {
    1667     if(ret_val->name_length + REGFI_VK_MIN_LENGTH > ret_val->cell_size)
     1667    if(ret_val->name_length + REGFI_VK_MIN_LENGTH + 4 > ret_val->cell_size)
    16681668    {
    16691669      if(strict)
     
    16731673      }
    16741674      else
    1675         ret_val->name_length = ret_val->cell_size - REGFI_VK_MIN_LENGTH;
     1675        ret_val->name_length = ret_val->cell_size - REGFI_VK_MIN_LENGTH - 4;
    16761676    }
    16771677
    16781678    /* Round up to the next multiple of 8 */
    1679     length = (ret_val->name_length + REGFI_NK_MIN_LENGTH) & 0xFFFFFFF8;
    1680     if(length < ret_val->name_length + REGFI_NK_MIN_LENGTH)
    1681       length+=8;
     1679    cell_length = (ret_val->name_length + REGFI_VK_MIN_LENGTH + 4) & 0xFFFFFFF8;
     1680    if(cell_length < ret_val->name_length + REGFI_VK_MIN_LENGTH + 4)
     1681      cell_length+=8;
    16821682
    16831683    ret_val->valuename = (char*)zalloc(sizeof(char)*(ret_val->name_length+1));
     
    16871687      return NULL;
    16881688    }
    1689    
    1690     /* Don't need to seek, should be at the right offset */
     1689
    16911690    length = ret_val->name_length;
    16921691    if((regfi_read(file->fd, (uint8*)ret_val->valuename, &length) != 0)
     
    17001699  }
    17011700  else
    1702     length = REGFI_VK_MIN_LENGTH;
     1701    cell_length = REGFI_VK_MIN_LENGTH + 4;
    17031702
    17041703  if(unalloc)
    17051704  {
    17061705    /* If cell_size is still greater, truncate. */
    1707     if(length < ret_val->cell_size)
    1708       ret_val->cell_size = length;
     1706    if(cell_length < ret_val->cell_size)
     1707      ret_val->cell_size = cell_length;
    17091708  }
    17101709
     
    18161815        break;
    18171816     
    1818       if((cell_len == 0) || ((cell_len & 0xFFFFFFFC) != cell_len))
     1817      if((cell_len == 0) || ((cell_len & 0xFFFFFFF8) != cell_len))
    18191818        /* TODO: should report an error here. */
    18201819        break;
Note: See TracChangeset for help on using the changeset viewer.