- Timestamp:
- 12/06/09 20:00:58 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/regfi.c
r159 r160 1086 1086 } 1087 1087 1088 /* Get classname if it exists */1089 if(nk->classname_off != REGFI_OFFSET_NONE)1090 {1091 off = nk->classname_off + REGFI_REGF_SIZE;1092 max_size = regfi_calc_maxsize(file, off);1093 if(max_size >= 0)1094 {1095 nk->classname1096 = regfi_parse_classname(file, off, &nk->classname_length,1097 max_size, strict);1098 }1099 else1100 {1101 nk->classname = NULL;1102 regfi_add_message(file, REGFI_MSG_WARN, "Could not find hbin for class"1103 " name while parsing NK record at offset 0x%.8X.",1104 offset);1105 }1106 1107 if(nk->classname == NULL)1108 {1109 regfi_add_message(file, REGFI_MSG_WARN, "Could not parse class"1110 " name while parsing NK record at offset 0x%.8X.",1111 offset);1112 }1113 else1114 talloc_steal(nk, nk->classname);1115 }1116 1117 1088 return nk; 1118 1089 } … … 1685 1656 /****************************************************************************** 1686 1657 *****************************************************************************/ 1658 REGFI_CLASSNAME* regfi_iterator_fetch_classname(REGFI_ITERATOR* i, 1659 const REGFI_NK_REC* key) 1660 { 1661 REGFI_CLASSNAME* ret_val; 1662 uint8* raw; 1663 char* interpreted; 1664 uint32 offset; 1665 int32 conv_size, max_size; 1666 uint16 parse_length; 1667 1668 if(key->classname_off == REGFI_OFFSET_NONE || key->classname_length == 0) 1669 return NULL; 1670 1671 offset = key->classname_off + REGFI_REGF_SIZE; 1672 max_size = regfi_calc_maxsize(i->f, offset); 1673 if(max_size <= 0) 1674 return NULL; 1675 1676 parse_length = key->classname_length; 1677 raw = regfi_parse_classname(i->f, offset, &parse_length, max_size, true); 1678 1679 if(raw == NULL) 1680 { 1681 regfi_add_message(i->f, REGFI_MSG_WARN, "Could not parse class" 1682 " name at offset 0x%.8X for key record at offset 0x%.8X.", 1683 offset, key->offset); 1684 return NULL; 1685 } 1686 1687 ret_val = talloc(NULL, REGFI_CLASSNAME); 1688 if(ret_val == NULL) 1689 return NULL; 1690 1691 ret_val->raw = raw; 1692 ret_val->size = parse_length; 1693 talloc_steal(ret_val, raw); 1694 1695 interpreted = talloc_array(NULL, char, parse_length); 1696 1697 conv_size = regfi_conv_charset(i->string_encoding, 1698 raw, interpreted, 1699 parse_length, parse_length); 1700 if(conv_size < 0) 1701 { 1702 regfi_add_message(i->f, REGFI_MSG_WARN, "Error occurred while" 1703 " converting classname to charset %s. Error message: %s", 1704 i->string_encoding, strerror(-conv_size)); 1705 talloc_free(interpreted); 1706 ret_val->interpreted = NULL; 1707 } 1708 else 1709 { 1710 interpreted = talloc_realloc(NULL, interpreted, char, conv_size); 1711 ret_val->interpreted = interpreted; 1712 talloc_steal(ret_val, interpreted); 1713 } 1714 1715 return ret_val; 1716 } 1717 1718 1719 /****************************************************************************** 1720 *****************************************************************************/ 1687 1721 REGFI_DATA* regfi_iterator_fetch_data(REGFI_ITERATOR* i, 1688 1722 const REGFI_VK_REC* value) … … 1727 1761 } 1728 1762 1763 1764 /****************************************************************************** 1765 *****************************************************************************/ 1766 void regfi_free_classname(REGFI_CLASSNAME* classname) 1767 { 1768 talloc_free(classname); 1769 } 1729 1770 1730 1771 /****************************************************************************** … … 2275 2316 2276 2317 2277 char* regfi_parse_classname(REGFI_FILE* file, uint32 offset,2278 uint16* name_length, uint32 max_size, bool strict)2279 { 2280 char* ret_val = NULL;2318 uint8* regfi_parse_classname(REGFI_FILE* file, uint32 offset, 2319 uint16* name_length, uint32 max_size, bool strict) 2320 { 2321 uint8* ret_val = NULL; 2281 2322 uint32 length; 2282 2323 uint32 cell_length; … … 2320 2361 } 2321 2362 2322 ret_val = talloc_array(NULL, char, *name_length);2363 ret_val = talloc_array(NULL, uint8, *name_length); 2323 2364 if(ret_val != NULL) 2324 2365 { 2325 2366 length = *name_length; 2326 if((regfi_read(file->fd, (uint8*)ret_val, &length) != 0)2367 if((regfi_read(file->fd, ret_val, &length) != 0) 2327 2368 || length != *name_length) 2328 2369 { … … 2475 2516 * http://msdn2.microsoft.com/en-us/library/ms724872.aspx 2476 2517 */ 2477 /* 2478 XXX 2479 if(size > REGFI_VK_MAX_DATA_LENGTH) 2480 { 2481 *error_msg = (char*)malloc(82); 2482 if(*error_msg == NULL) 2483 return NULL; 2484 2485 sprintf(*error_msg, "WARN: value data size %d larger than " 2486 "%d, truncating...", size, REGFI_VK_MAX_DATA_LENGTH); 2487 size = REGFI_VK_MAX_DATA_LENGTH; 2488 } 2489 2490 */ 2518 /* XXX: add way to skip this check at user discression. */ 2519 if(length > REGFI_VK_MAX_DATA_LENGTH) 2520 { 2521 regfi_add_message(file, REGFI_MSG_WARN, "Value data size %d larger than " 2522 "%d, truncating...", length, REGFI_VK_MAX_DATA_LENGTH); 2523 length = REGFI_VK_MAX_DATA_LENGTH; 2524 } 2491 2525 2492 2526 if(data_in_offset)
Note: See TracChangeset
for help on using the changeset viewer.