- Timestamp:
- 08/19/08 19:31:33 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/regfi.c
r125 r126 1510 1510 1511 1511 1512 1512 /******************************************************************* 1513 *******************************************************************/ 1513 1514 REGF_NK_REC* regfi_parse_nk(REGF_FILE* file, uint32 offset, 1514 1515 uint32 max_size, bool strict) … … 1635 1636 ret_val->keyname[ret_val->name_length] = '\0'; 1636 1637 1637 1638 /***/ 1639 1640 if(ret_val->classname_length > 0 1641 && ret_val->classname_off != REGF_OFFSET_NONE 1642 && ret_val->classname_off == (ret_val->classname_off & 0xFFFFFFF8)) 1643 { 1644 ret_val->classname = (char*)zalloc(ret_val->classname_length+1); 1645 if(ret_val->classname != NULL) 1646 { 1647 if(!regfi_parse_cell(file->fd, ret_val->classname_off+REGF_BLOCKSIZE, 1648 (uint8*)ret_val->classname, ret_val->classname_length, 1649 &cell_length, &unalloc) 1650 || (cell_length < ret_val->classname_length) 1651 || (strict && unalloc)) 1638 if(ret_val->classname_off != REGF_OFFSET_NONE) 1639 { 1640 ret_val->classname 1641 = regfi_parse_classname(file, ret_val->classname_off+REGF_BLOCKSIZE, 1642 &ret_val->classname_length, strict); 1643 /* 1644 if(strict && ret_val->classname == NULL) 1645 return NULL; 1646 */ 1647 } 1648 1649 return ret_val; 1650 } 1651 1652 1653 /*******************************************************************/ 1654 /* XXX: Not currently validating against hbin length. */ 1655 /*******************************************************************/ 1656 char* regfi_parse_classname(REGF_FILE* file, uint32 offset, 1657 uint16* name_length, bool strict) 1658 { 1659 char* ret_val = NULL; 1660 uint32 length; 1661 uint32 cell_length; 1662 bool unalloc = false; 1663 1664 if(*name_length > 0 && offset != REGF_OFFSET_NONE 1665 && offset == (offset & 0xFFFFFFF8)) 1666 { 1667 if(!regfi_parse_cell(file->fd, offset, NULL, 0, &cell_length, &unalloc)) 1668 return NULL; 1669 1670 if(cell_length < *name_length) 1671 { 1672 if(strict) 1673 return NULL; 1674 *name_length = cell_length & 0xFFFFFFF8; 1675 } 1676 1677 ret_val = (char*)zalloc(*name_length); 1678 if(ret_val != NULL) 1679 { 1680 length = *name_length; 1681 if((regfi_read(file->fd, (uint8*)ret_val, &length) != 0) 1682 || length != *name_length) 1652 1683 { 1653 /* Being careful not to reject the whole key here even when 1654 * strict and things are obviously wrong, since it appears 1655 * they're commonly obviously wrong. 1656 */ 1657 free(ret_val->classname); 1658 ret_val->classname = NULL; 1659 return ret_val; 1684 free(ret_val); 1685 return NULL; 1660 1686 } 1661 1687 1662 ret_val->classname[ret_val->classname_length] = '\0';1663 1688 /*printf("==> cell_length=%d, classname_length=%d, max_bytes_subkeyclassname=%d\n", cell_length, ret_val->classname_length, ret_val->max_bytes_subkeyclassname);*/ 1664 1689 } 1665 1690 } 1666 /***/1667 1668 1691 1669 1692 return ret_val; 1670 1693 } 1671 1672 1694 1673 1695
Note: See TracChangeset
for help on using the changeset viewer.