Changeset 138
- Timestamp:
- 02/08/09 14:53:48 (16 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/reglookup-recover.1.docbook
r119 r138 26 26 reglookup-recover attempts to scour a Windows registry hive for 27 27 deleted data structures and outputs those found in a CSV-like format. 28 print them out to stdout in a CSV-like format.29 28 </para> 30 29 </refsect1> … … 43 42 <listitem> 44 43 <para> 45 Verbose output. (Currently does little to nothing.)44 Verbose output. 46 45 </para> 47 46 </listitem> -
trunk/doc/reglookup.1.docbook
r125 r138 137 137 <listitem> 138 138 <para> 139 Verbose output. (Currently does little to nothing.)139 Verbose output. 140 140 </para> 141 141 </listitem> … … 298 298 </para> 299 299 <para> 300 Verbose output is not working.301 </para>302 <para>303 300 The SID conversions haven't been carefully checked for accuracy. 304 301 </para> -
trunk/include/regfi.h
r137 r138 53 53 54 54 /******************************************************************************/ 55 /* Macros */ 56 55 56 /* regfi library error message types */ 57 #define REGFI_MSG_INFO 0x0001 58 #define REGFI_MSG_WARN 0x0004 59 #define REGFI_MSG_ERROR 0x0010 60 57 61 /* Registry data types */ 58 62 #define REG_NONE 0 … … 281 285 /* Run-time information */ 282 286 /************************/ 283 int fd; /* file descriptor */ 284 285 /* Experimental hbin lists */ 287 /* file descriptor */ 288 int fd; 289 290 /* For sanity checking (not part of the registry header) */ 291 uint32 file_length; 292 293 /* Metadata about hbins */ 286 294 range_list* hbins; 287 295 … … 289 297 char* last_message; 290 298 291 /* For sanity checking (not part of the registry header)*/292 uint 32 file_length;299 /* Mask for error message types that will be stored. */ 300 uint16 msg_mask; 293 301 294 302 … … 359 367 */ 360 368 char* regfi_get_messages(REGFI_FILE* file); 369 void regfi_set_message_mask(REGFI_FILE* file, uint16 mask); 361 370 362 371 REGFI_ITERATOR* regfi_iterator_new(REGFI_FILE* fh); … … 458 467 REGFI_SUBKEY_LIST** lists, 459 468 bool strict); 460 void regfi_add_message(REGFI_FILE* file, const char* fmt, ...); 469 void regfi_add_message(REGFI_FILE* file, uint16 msg_type, 470 const char* fmt, ...); 461 471 #endif /* _REGFI_H */ -
trunk/lib/regfi.c
r137 r138 37 37 /****************************************************************************** 38 38 ******************************************************************************/ 39 void regfi_add_message(REGFI_FILE* file, const char* fmt, ...)39 void regfi_add_message(REGFI_FILE* file, uint16 msg_type, const char* fmt, ...) 40 40 { 41 41 /* XXX: This function is not particularly efficient, 42 42 * but then it is mostly used during errors. 43 43 */ 44 /* XXX: Should we add support for filtering by levels of severity? */45 44 uint32 buf_size, buf_used; 46 45 char* new_msg; 47 46 va_list args; 48 47 49 if(file->last_message == NULL) 50 buf_used = 0; 51 else 52 buf_used = strlen(file->last_message); 53 54 buf_size = buf_used+strlen(fmt)+2+128; 55 new_msg = realloc(file->last_message, buf_size); 56 if(new_msg == NULL) 57 /* XXX: should we report this? */ 58 return; 59 60 va_start(args, fmt); 61 vsnprintf(new_msg+buf_used, buf_size-buf_used, fmt, args); 62 va_end(args); 63 strncat(new_msg, "\n", buf_size-1); 64 65 file->last_message = new_msg; 48 if((file->msg_mask & msg_type) != 0) 49 { 50 if(file->last_message == NULL) 51 buf_used = 0; 52 else 53 buf_used = strlen(file->last_message); 54 55 buf_size = buf_used+strlen(fmt)+160; 56 new_msg = realloc(file->last_message, buf_size); 57 if(new_msg == NULL) 58 /* XXX: should we report this? */ 59 return; 60 61 switch (msg_type) 62 { 63 case REGFI_MSG_INFO: 64 strcpy(new_msg+buf_used, "INFO: "); 65 buf_used += 6; 66 break; 67 case REGFI_MSG_WARN: 68 strcpy(new_msg+buf_used, "WARN: "); 69 buf_used += 6; 70 break; 71 case REGFI_MSG_ERROR: 72 strcpy(new_msg+buf_used, "ERROR: "); 73 buf_used += 7; 74 break; 75 } 76 77 va_start(args, fmt); 78 vsnprintf(new_msg+buf_used, buf_size-buf_used, fmt, args); 79 va_end(args); 80 strncat(new_msg, "\n", buf_size-1); 81 82 file->last_message = new_msg; 83 } 66 84 } 67 85 … … 75 93 76 94 return ret_val; 95 } 96 97 98 void regfi_set_message_mask(REGFI_FILE* file, uint16 mask) 99 { 100 file->msg_mask = mask; 77 101 } 78 102 … … 702 726 &cell_length, &unalloc)) 703 727 { 704 regfi_add_message(file, "ERROR:Could not parse SK record cell"728 regfi_add_message(file, REGFI_MSG_WARN, "Could not parse SK record cell" 705 729 " at offset 0x%.8X.", offset); 706 730 return NULL; … … 709 733 if(sk_header[0] != 's' || sk_header[1] != 'k') 710 734 { 711 regfi_add_message(file, "ERROR: Magic number mismatch in parsing SK record"712 " at offset 0x%.8X.", offset);735 regfi_add_message(file, REGFI_MSG_WARN, "Magic number mismatch in parsing" 736 " SK record at offset 0x%.8X.", offset); 713 737 return NULL; 714 738 } … … 729 753 || (strict && ret_val->cell_size != (ret_val->cell_size & 0xFFFFFFF8))) 730 754 { 731 regfi_add_message(file, "ERROR: Invalid cell size found while parsing SK"732 " record at offset 0x%.8X.", offset);755 regfi_add_message(file, REGFI_MSG_WARN, "Invalid cell size found while" 756 " parsing SK record at offset 0x%.8X.", offset); 733 757 free(ret_val); 734 758 return NULL; … … 747 771 if(ret_val->desc_size + REGFI_SK_MIN_LENGTH > ret_val->cell_size) 748 772 { 749 regfi_add_message(file, "ERROR: Security descriptor too large for cell" 750 " while parsing SK record at offset 0x%.8X.", offset); 773 regfi_add_message(file, REGFI_MSG_ERROR, "Security descriptor too large for" 774 " cell while parsing SK record at offset 0x%.8X.", 775 offset); 751 776 free(ret_val); 752 777 return NULL; … … 764 789 || length != ret_val->desc_size) 765 790 { 766 regfi_add_message(file, "ERROR: Failed to read security descriptor" 767 " while parsing SK record at offset 0x%.8X.", offset); 791 regfi_add_message(file, REGFI_MSG_ERROR, "Failed to read security" 792 " descriptor while parsing SK record at offset 0x%.8X.", 793 offset); 768 794 free(ret_val); 769 795 return NULL; … … 772 798 if(!(ret_val->sec_desc = winsec_parse_desc(sec_desc_buf, ret_val->desc_size))) 773 799 { 774 regfi_add_message(file, "ERROR: Failed to parse security descriptor" 775 " while parsing SK record at offset 0x%.8X.", offset); 800 regfi_add_message(file, REGFI_MSG_ERROR, "Failed to parse security" 801 " descriptor while parsing SK record at offset 0x%.8X.", 802 offset); 776 803 free(sec_desc_buf); 777 804 free(ret_val); … … 794 821 if(!regfi_parse_cell(file->fd, offset, NULL, 0, &cell_length, &unalloc)) 795 822 { 796 regfi_add_message(file, "ERROR:Failed to read cell header"823 regfi_add_message(file, REGFI_MSG_ERROR, "Failed to read cell header" 797 824 " while parsing value list at offset 0x%.8X.", offset); 798 825 return NULL; … … 807 834 if((num_values * sizeof(uint32)) > cell_length-sizeof(uint32)) 808 835 { 809 regfi_add_message(file, "ERROR:Too many values found"836 regfi_add_message(file, REGFI_MSG_ERROR, "Too many values found" 810 837 " while parsing value list at offset 0x%.8X.", offset); 811 838 return NULL; … … 820 847 if((regfi_read(file->fd, (uint8*)ret_val, &length) != 0) || length != read_len) 821 848 { 822 regfi_add_message(file, "ERROR:Failed to read value pointers"849 regfi_add_message(file, REGFI_MSG_ERROR, "Failed to read value pointers" 823 850 " while parsing value list at offset 0x%.8X.", offset); 824 851 free(ret_val); … … 837 864 || ((ret_val[i] & 0xFFFFFFF8) != ret_val[i])) 838 865 { 839 regfi_add_message(file, "ERROR: Invalid value pointer (0x%.8X) found"840 " while parsing value list at offset 0x%.8X.",841 ret_val[i], offset);866 regfi_add_message(file, REGFI_MSG_ERROR, "Invalid value pointer" 867 " (0x%.8X) found while parsing value list at offset" 868 " 0x%.8X.", ret_val[i], offset); 842 869 free(ret_val); 843 870 return NULL; … … 934 961 if ((nk = regfi_parse_nk(file, offset, max_length, true)) == NULL) 935 962 { 936 regfi_add_message(file, "ERROR:Could not load NK record at"963 regfi_add_message(file, REGFI_MSG_ERROR, "Could not load NK record at" 937 964 " offset 0x%.8X.", offset); 938 965 return NULL; … … 965 992 if(strict && nk->values == NULL) 966 993 { 967 regfi_add_message(file, "ERROR:Could not load value list"994 regfi_add_message(file, REGFI_MSG_ERROR, "Could not load value list" 968 995 " for NK record at offset 0x%.8X.", 969 996 offset); … … 1111 1138 rla = range_list_add(rb->hbins, hbin->file_off, hbin->block_size, hbin); 1112 1139 hbin_off = hbin->file_off + hbin->block_size; 1113 /*fprintf(stderr, "file_length=%.8X,hbin_off=%.8X,hbin->block_size=%.8X,hbin->next_block=%.8X\n",1114 file_length, hbin_off, hbin->block_size, hbin->next_block);*/1115 1140 hbin = regfi_parse_hbin(rb, hbin_off, true); 1116 1141 } 1142 1143 /* Default message mask */ 1144 rb->msg_mask = REGFI_MSG_ERROR|REGFI_MSG_WARN; 1117 1145 1118 1146 /* success */ … … 1661 1689 if(lseek(file->fd, offset, SEEK_SET) == -1) 1662 1690 { 1663 regfi_add_message(file, "ERROR:Seek failed"1691 regfi_add_message(file, REGFI_MSG_ERROR, "Seek failed" 1664 1692 " while parsing hbin at offset 0x%.8X.", offset); 1665 1693 return NULL; … … 1673 1701 if(lseek(file->fd, offset, SEEK_SET) == -1) 1674 1702 { 1675 regfi_add_message(file, "ERROR:Seek failed"1703 regfi_add_message(file, REGFI_MSG_ERROR, "Seek failed" 1676 1704 " while parsing hbin at offset 0x%.8X.", offset); 1677 1705 return NULL; … … 1685 1713 if(strict && (memcmp(hbin->magic, "hbin", 4) != 0)) 1686 1714 { 1687 /* XXX: add this back in when we have configurable verbosity. */1688 /* regfi_add_message(file, "INFO: Magic number mismatch (%.2X %.2X %.2X %.2X)"1689 " while parsing hbin at offset 0x%.8X.", hbin->magic[0],1690 hbin->magic[ 1], hbin->magic[2], hbin->magic[3], offset); */1715 regfi_add_message(file, REGFI_MSG_INFO, "Magic number mismatch " 1716 "(%.2X %.2X %.2X %.2X) while parsing hbin at offset" 1717 " 0x%.8X.", hbin->magic[0], hbin->magic[1], 1718 hbin->magic[2], hbin->magic[3], offset); 1691 1719 free(hbin); 1692 1720 return NULL; … … 1695 1723 hbin->first_hbin_off = IVAL(hbin_header, 0x4); 1696 1724 hbin->block_size = IVAL(hbin_header, 0x8); 1697 /*fprintf(stderr, "hbin->block_size field => %.8X\n", IVAL(hbin_header, 0x8));*/1698 /* hbin->block_size = IVAL(hbin_header, 0x8);*/1699 1725 /* this should be the same thing as hbin->block_size but just in case */ 1700 1726 hbin->next_block = IVAL(hbin_header, 0x1C); … … 1710 1736 || (hbin->block_size & 0xFFFFF000) != hbin->block_size) 1711 1737 { 1712 regfi_add_message(file, "ERROR:The hbin offset is not aligned"1738 regfi_add_message(file, REGFI_MSG_ERROR, "The hbin offset is not aligned" 1713 1739 " or runs off the end of the file" 1714 1740 " while parsing hbin at offset 0x%.8X.", offset); … … 1736 1762 &cell_length, &unalloc)) 1737 1763 { 1738 regfi_add_message(file, "ERROR:Could not parse cell header"1764 regfi_add_message(file, REGFI_MSG_WARN, "Could not parse cell header" 1739 1765 " while parsing NK record at offset 0x%.8X.", offset); 1740 1766 return NULL; … … 1744 1770 if((nk_header[0x0] != 'n') || (nk_header[0x1] != 'k')) 1745 1771 { 1746 regfi_add_message(file, "ERROR: Magic number mismatch in parsing NK record"1747 " at offset 0x%.8X.", offset);1772 regfi_add_message(file, REGFI_MSG_WARN, "Magic number mismatch in parsing" 1773 " NK record at offset 0x%.8X.", offset); 1748 1774 return NULL; 1749 1775 } … … 1752 1778 if(ret_val == NULL) 1753 1779 { 1754 regfi_add_message(file, "ERROR:Failed to allocate memory while"1780 regfi_add_message(file, REGFI_MSG_ERROR, "Failed to allocate memory while" 1755 1781 " parsing NK record at offset 0x%.8X.", offset); 1756 1782 return NULL; … … 1765 1791 || (strict && ret_val->cell_size != (ret_val->cell_size & 0xFFFFFFF8))) 1766 1792 { 1767 regfi_add_message(file, "ERROR: A length check failed while parsing"1768 " NK record at offset 0x%.8X.", offset);1793 regfi_add_message(file, REGFI_MSG_ERROR, "A length check failed while" 1794 " parsing NK record at offset 0x%.8X.", offset); 1769 1795 free(ret_val); 1770 1796 return NULL; … … 1782 1808 && (ret_val->key_type != REGFI_NK_TYPE_UNKNOWN3)) 1783 1809 { 1784 regfi_add_message(file, "WARN: Unknown key type (0x%.4X) while parsing"1785 " NK record at offset 0x%.8X.", ret_val->key_type,1786 offset);1810 regfi_add_message(file, REGFI_MSG_WARN, "Unknown key type (0x%.4X) while" 1811 " parsing NK record at offset 0x%.8X.", 1812 ret_val->key_type, offset); 1787 1813 } 1788 1814 … … 1825 1851 if(strict) 1826 1852 { 1827 regfi_add_message(file, "ERROR:Contents too large for cell"1853 regfi_add_message(file, REGFI_MSG_ERROR, "Contents too large for cell" 1828 1854 " while parsing NK record at offset 0x%.8X.", offset); 1829 1855 free(ret_val); … … 1857 1883 || length != ret_val->name_length) 1858 1884 { 1859 regfi_add_message(file, "ERROR:Failed to read key name"1885 regfi_add_message(file, REGFI_MSG_ERROR, "Failed to read key name" 1860 1886 " while parsing NK record at offset 0x%.8X.", offset); 1861 1887 free(ret_val->keyname); … … 1879 1905 { 1880 1906 ret_val->classname = NULL; 1881 regfi_add_message(file, "WARN: Could not find hbin for class name" 1882 " while parsing NK record at offset 0x%.8X.", offset); 1907 regfi_add_message(file, REGFI_MSG_WARN, "Could not find hbin for class" 1908 " name while parsing NK record at offset 0x%.8X.", 1909 offset); 1883 1910 } 1884 1911 /* XXX: Should add this back and make it more strict? … … 1887 1914 */ 1888 1915 } 1889 /* 1890 if(ret_val->key_type == 0x0000 || ret_val->key_type == 0x4020) 1891 { 1892 fprintf(stderr, "INFO: keyname=%s,classname=%s,unalloc=%d,num_subkeys=%d,num_values=%d\n", 1893 ret_val->keyname,ret_val->classname,unalloc,ret_val->num_subkeys,ret_val->num_values); 1894 } 1895 */ 1916 1896 1917 return ret_val; 1897 1918 } … … 1911 1932 if(!regfi_parse_cell(file->fd, offset, NULL, 0, &cell_length, &unalloc)) 1912 1933 { 1913 regfi_add_message(file, "ERROR:Could not parse cell header"1934 regfi_add_message(file, REGFI_MSG_WARN, "Could not parse cell header" 1914 1935 " while parsing class name at offset 0x%.8X.", offset); 1915 1936 return NULL; … … 1918 1939 if((cell_length & 0xFFFFFFF8) != cell_length) 1919 1940 { 1920 regfi_add_message(file, "ERROR:Cell length not a multiple of 8"1941 regfi_add_message(file, REGFI_MSG_ERROR, "Cell length not a multiple of 8" 1921 1942 " while parsing class name at offset 0x%.8X.", offset); 1922 1943 return NULL; … … 1925 1946 if(cell_length > max_size) 1926 1947 { 1927 regfi_add_message(file, "WARN: Cell stretches past hbin boundary" 1928 " while parsing class name at offset 0x%.8X.", offset); 1948 regfi_add_message(file, REGFI_MSG_WARN, "Cell stretches past hbin " 1949 "boundary while parsing class name at offset 0x%.8X.", 1950 offset); 1929 1951 if(strict) 1930 1952 return NULL; … … 1934 1956 if((cell_length - 4) < *name_length) 1935 1957 { 1936 regfi_add_message(file, "WARN: Class name is larger than cell_length" 1937 " while parsing class name at offset 0x%.8X.", offset); 1958 regfi_add_message(file, REGFI_MSG_WARN, "Class name is larger than" 1959 " cell_length while parsing class name at offset" 1960 " 0x%.8X.", offset); 1938 1961 if(strict) 1939 1962 return NULL; … … 1948 1971 || length != *name_length) 1949 1972 { 1950 regfi_add_message(file, "ERROR:Could not read class name"1973 regfi_add_message(file, REGFI_MSG_ERROR, "Could not read class name" 1951 1974 " while parsing class name at offset 0x%.8X.", offset); 1952 1975 free(ret_val); … … 1975 1998 &cell_length, &unalloc)) 1976 1999 { 1977 regfi_add_message(file, "ERROR:Could not parse cell header"2000 regfi_add_message(file, REGFI_MSG_WARN, "Could not parse cell header" 1978 2001 " while parsing VK record at offset 0x%.8X.", offset); 1979 2002 return NULL; … … 1992 2015 || ret_val->cell_size != (ret_val->cell_size & 0xFFFFFFF8)) 1993 2016 { 1994 regfi_add_message(file, "ERROR:Invalid cell size encountered"2017 regfi_add_message(file, REGFI_MSG_WARN, "Invalid cell size encountered" 1995 2018 " while parsing VK record at offset 0x%.8X.", offset); 1996 2019 free(ret_val); … … 2006 2029 * 0xFFFF. 2007 2030 */ 2008 regfi_add_message(file, "ERROR:Magic number mismatch"2031 regfi_add_message(file, REGFI_MSG_WARN, "Magic number mismatch" 2009 2032 " while parsing VK record at offset 0x%.8X.", offset); 2010 2033 free(ret_val); … … 2025 2048 if(ret_val->name_length + REGFI_VK_MIN_LENGTH + 4 > ret_val->cell_size) 2026 2049 { 2027 regfi_add_message(file, "WARN: Name too long for remaining cell space" 2028 " while parsing VK record at offset 0x%.8X.", offset); 2050 regfi_add_message(file, REGFI_MSG_WARN, "Name too long for remaining cell" 2051 " space while parsing VK record at offset 0x%.8X.", 2052 offset); 2029 2053 if(strict) 2030 2054 { … … 2052 2076 || length != ret_val->name_length) 2053 2077 { 2054 regfi_add_message(file, "ERROR:Could not read value name"2078 regfi_add_message(file, REGFI_MSG_ERROR, "Could not read value name" 2055 2079 " while parsing VK record at offset 0x%.8X.", offset); 2056 2080 free(ret_val->valuename); … … 2093 2117 else 2094 2118 { 2095 regfi_add_message(file, "WARN:Could not find hbin for data"2119 regfi_add_message(file, REGFI_MSG_WARN, "Could not find hbin for data" 2096 2120 " while parsing VK record at offset 0x%.8X.", offset); 2097 2121 ret_val->data = NULL; … … 2101 2125 if(ret_val->data == NULL) 2102 2126 { 2103 regfi_add_message(file, "WARN:Could not parse data record"2127 regfi_add_message(file, REGFI_MSG_WARN, "Could not parse data record" 2104 2128 " while parsing VK record at offset 0x%.8X.", offset); 2105 2129 } … … 2124 2148 if(length > 4) 2125 2149 { 2126 regfi_add_message(file, "ERROR:Data in offset but length > 4"2150 regfi_add_message(file, REGFI_MSG_ERROR, "Data in offset but length > 4" 2127 2151 " while parsing data record at offset 0x%.8X.", 2128 2152 offset); … … 2141 2165 &cell_length, &unalloc)) 2142 2166 { 2143 regfi_add_message(file, "ERROR:Could not parse cell while"2167 regfi_add_message(file, REGFI_MSG_WARN, "Could not parse cell while" 2144 2168 " parsing data record at offset 0x%.8X.", offset); 2145 2169 return NULL; … … 2148 2172 if((cell_length & 0xFFFFFFF8) != cell_length) 2149 2173 { 2150 regfi_add_message(file, "ERROR:Cell length not multiple of 8"2174 regfi_add_message(file, REGFI_MSG_WARN, "Cell length not multiple of 8" 2151 2175 " while parsing data record at offset 0x%.8X.", 2152 2176 offset); … … 2156 2180 if(cell_length > max_size) 2157 2181 { 2158 regfi_add_message(file, "WARN:Cell extends past hbin boundary"2182 regfi_add_message(file, REGFI_MSG_WARN, "Cell extends past hbin boundary" 2159 2183 " while parsing data record at offset 0x%.8X.", 2160 2184 offset); … … 2171 2195 * such as 53392. 2172 2196 */ 2173 regfi_add_message(file, "WARN:Data length (0x%.8X) larger than"2197 regfi_add_message(file, REGFI_MSG_WARN, "Data length (0x%.8X) larger than" 2174 2198 " remaining cell length (0x%.8X)" 2175 2199 " while parsing data record at offset 0x%.8X.", … … 2188 2212 || read_length != length) 2189 2213 { 2190 regfi_add_message(file, "ERROR:Could not read data block while"2214 regfi_add_message(file, REGFI_MSG_ERROR, "Could not read data block while" 2191 2215 " parsing data record at offset 0x%.8X.", offset); 2192 2216 free(ret_val); -
trunk/src/common.c
r137 r138 38 38 } 39 39 40 void printMsgs(REGFI_ ITERATOR* iter)41 { 42 char* msgs = regfi_get_messages( iter->f);40 void printMsgs(REGFI_FILE* f) 41 { 42 char* msgs = regfi_get_messages(f); 43 43 if(msgs != NULL) 44 44 { … … 46 46 free(msgs); 47 47 } 48 } 49 50 void clearMsgs(REGFI_FILE* f) 51 { 52 char* msgs = regfi_get_messages(f); 53 if(msgs != NULL) 54 free(msgs); 48 55 } 49 56 -
trunk/src/reglookup-recover.c
r136 r138 2 2 * This program attempts to recover deleted data structures in a registry hive. 3 3 * 4 * Copyright (C) 2008 Timothy D. Morgan4 * Copyright (C) 2008-2009 Timothy D. Morgan 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify … … 87 87 quoted_name[0] = '\0'; 88 88 89 fprintf(stderr, "WARN ING: NULL key name in NK record at offset %.8X.\n",89 fprintf(stderr, "WARN: NULL key name in NK record at offset %.8X.\n", 90 90 nk->offset); 91 91 } … … 125 125 if(size > REGFI_VK_MAX_DATA_LENGTH) 126 126 { 127 fprintf(stderr, "WARN ING: value data size %d larger than "127 fprintf(stderr, "WARN: value data size %d larger than " 128 128 "%d, truncating...\n", size, REGFI_VK_MAX_DATA_LENGTH); 129 129 size = REGFI_VK_MAX_DATA_LENGTH; … … 153 153 154 154 if(conv_error == NULL) 155 fprintf(stderr, "WARN ING: Could not quote value for '%s/%s'. "155 fprintf(stderr, "WARN: Could not quote value for '%s/%s'. " 156 156 "Memory allocation failure likely.\n", prefix, quoted_name); 157 157 else if(print_verbose) 158 fprintf(stderr, "WARN ING: Could not quote value for '%s/%s'. "158 fprintf(stderr, "WARN: Could not quote value for '%s/%s'. " 159 159 "Returned error: %s\n", prefix, quoted_name, conv_error); 160 160 } 161 161 /* XXX: should these always be printed? */ 162 162 else if(conv_error != NULL && print_verbose) 163 fprintf(stderr, " VERBOSE: While quoting value for '%s/%s', "163 fprintf(stderr, "INFO: While quoting value for '%s/%s', " 164 164 "warning returned: %s\n", prefix, quoted_name, conv_error); 165 165 … … 279 279 cur_ancestor = regfi_parse_nk(f, virt_offset+REGFI_REGF_SIZE, 280 280 max_length, true); 281 printMsgs(f); 282 281 283 if(cur_ancestor == NULL) 282 284 virt_offset = REGFI_OFFSET_NONE; … … 426 428 for(i=0; i < range_list_size(unalloc_cells); i++) 427 429 { 430 printMsgs(f); 428 431 cur_elem = range_list_get(unalloc_cells, i); 429 432 for(j=0; cur_elem->length > REGFI_NK_MIN_LENGTH … … 432 435 key = regfi_parse_nk(f, cur_elem->offset+j, 433 436 cur_elem->length-j, false); 437 printMsgs(f); 438 434 439 if(key != NULL) 435 440 { … … 587 592 for(i=0; i < range_list_size(unalloc_cells); i++) 588 593 { 594 printMsgs(f); 589 595 cur_elem = range_list_get(unalloc_cells, i); 590 596 for(j=0; j <= cur_elem->length; j+=8) … … 592 598 vk = regfi_parse_vk(f, cur_elem->offset+j, 593 599 cur_elem->length-j, false); 600 printMsgs(f); 601 594 602 if(vk != NULL) 595 603 { … … 654 662 for(i=0; i < range_list_size(unalloc_cells); i++) 655 663 { 664 printMsgs(f); 656 665 cur_elem = range_list_get(unalloc_cells, i); 657 666 for(j=0; j <= cur_elem->length; j+=8) … … 659 668 sk = regfi_parse_sk(f, cur_elem->offset+j, 660 669 cur_elem->length-j, false); 670 printMsgs(f); 671 661 672 if(sk != NULL) 662 673 { … … 741 752 bailOut(EX_NOINPUT, ""); 742 753 } 754 if(print_verbose) 755 regfi_set_message_mask(f, REGFI_MSG_ERROR|REGFI_MSG_WARN|REGFI_MSG_INFO); 756 else 757 regfi_set_message_mask(f, REGFI_MSG_ERROR); 743 758 744 759 if(print_header) -
trunk/src/reglookup.c
r137 r138 86 86 } 87 87 88 quoted_value = data_to_ascii(vk->data, size, vk->type, &conv_error); 89 if(quoted_value == NULL) 90 { 91 if(conv_error == NULL) 92 fprintf(stderr, "WARN: Could not quote value for '%s/%s'. " 93 "Memory allocation failure likely.\n", prefix, quoted_name); 94 else if(print_verbose) 95 fprintf(stderr, "WARN: Could not quote value for '%s/%s'. " 96 "Returned error: %s\n", prefix, quoted_name, conv_error); 97 } 98 else if(conv_error != NULL && print_verbose) 99 fprintf(stderr, "VERBOSE: While quoting value for '%s/%s', " 100 "warning returned: %s\n", prefix, quoted_name, conv_error); 88 if(vk->data == NULL) 89 { 90 if(print_verbose) 91 fprintf(stderr, "INFO: While quoting value for '%s/%s', " 92 "data pointer was NULL.\n", prefix, quoted_name); 93 } 94 else 95 { 96 quoted_value = data_to_ascii(vk->data, size, vk->type, &conv_error); 97 if(quoted_value == NULL) 98 { 99 if(conv_error == NULL) 100 fprintf(stderr, "WARN: Could not quote value for '%s/%s'. " 101 "Memory allocation failure likely.\n", prefix, quoted_name); 102 else 103 fprintf(stderr, "WARN: Could not quote value for '%s/%s'. " 104 "Returned error: %s\n", prefix, quoted_name, conv_error); 105 } 106 else if(conv_error != NULL && print_verbose) 107 fprintf(stderr, "INFO: While quoting value for '%s/%s', " 108 "warning returned: %s\n", prefix, quoted_name, conv_error); 109 } 101 110 102 111 str_type = regfi_type_val2str(vk->type); … … 275 284 printValue(value, prefix); 276 285 value = regfi_iterator_next_value(iter); 277 printMsgs(iter );286 printMsgs(iter->f); 278 287 } 279 288 } … … 333 342 { 334 343 if(print_verbose) 335 fprintf(stderr, " WARN: While converting classname"344 fprintf(stderr, "INFO: While converting classname" 336 345 " for key '%s': %s.\n", full_path, error_msg); 337 346 free(error_msg); … … 341 350 quoted_classname = empty_str; 342 351 343 printMsgs(iter );352 printMsgs(iter->f); 344 353 printf("%s,KEY,,%s,%s,%s,%s,%s,%s\n", full_path, mtime, 345 354 owner, group, sacl, dacl, quoted_classname); … … 372 381 root = cur = regfi_iterator_cur_key(iter); 373 382 sub = regfi_iterator_first_subkey(iter); 374 printMsgs(iter );383 printMsgs(iter->f); 375 384 376 385 if(root == NULL) … … 400 409 if(!regfi_iterator_up(iter)) 401 410 { 402 printMsgs(iter );411 printMsgs(iter->f); 403 412 bailOut(EX_DATAERR, "ERROR: could not traverse iterator upward.\n"); 404 413 } … … 407 416 if(cur == NULL) 408 417 { 409 printMsgs(iter );418 printMsgs(iter->f); 410 419 bailOut(EX_DATAERR, "ERROR: unexpected NULL for key.\n"); 411 420 } … … 421 430 if(!regfi_iterator_down(iter)) 422 431 { 423 printMsgs(iter );432 printMsgs(iter->f); 424 433 bailOut(EX_DATAERR, "ERROR: could not traverse iterator downward.\n"); 425 434 } … … 429 438 print_this = true; 430 439 } 431 printMsgs(iter );440 printMsgs(iter->f); 432 441 } while(!((cur == root) && (sub == NULL))); 433 442 434 443 if(print_verbose) 435 fprintf(stderr, " VERBOSE: Finished printing key tree.\n");444 fprintf(stderr, "INFO: Finished printing key tree.\n"); 436 445 } 437 446 … … 467 476 468 477 if(print_verbose) 469 fprintf(stderr, " VERBOSE: Attempting to retrieve specified path: %s\n",478 fprintf(stderr, "INFO: Attempting to retrieve specified path: %s\n", 470 479 path_filter); 471 480 … … 474 483 { 475 484 if(print_verbose) 476 fprintf(stderr, " VERBOSE: Found final path element as root key.\n");485 fprintf(stderr, "INFO: Found final path element as root key.\n"); 477 486 free(tmp_path); 478 487 return 2; … … 481 490 if(!regfi_iterator_walk_path(iter, tmp_path)) 482 491 { 483 printMsgs(iter );492 printMsgs(iter->f); 484 493 free(tmp_path); 485 494 return 0; … … 489 498 { 490 499 if(print_verbose) 491 fprintf(stderr, " VERBOSE: Found final path element as value.\n");500 fprintf(stderr, "INFO: Found final path element as value.\n"); 492 501 493 502 value = regfi_iterator_cur_value(iter); 494 printMsgs(iter );503 printMsgs(iter->f); 495 504 tmp_path_joined = iter2Path(iter); 496 505 … … 507 516 else if(regfi_iterator_find_subkey(iter, path[i])) 508 517 { 509 printMsgs(iter );518 printMsgs(iter->f); 510 519 if(print_verbose) 511 fprintf(stderr, " VERBOSE: Found final path element as key.\n");520 fprintf(stderr, "INFO: Found final path element as key.\n"); 512 521 513 522 if(!regfi_iterator_down(iter)) 514 523 { 515 printMsgs(iter );524 printMsgs(iter->f); 516 525 bailOut(EX_DATAERR, "ERROR: Unexpected error on traversing path filter key.\n"); 517 526 } … … 519 528 return 2; 520 529 } 521 printMsgs(iter );530 printMsgs(iter->f); 522 531 523 532 if(print_verbose) 524 fprintf(stderr, " VERBOSE: Could not find last element of path.\n");533 fprintf(stderr, "INFO: Could not find last element of path.\n"); 525 534 526 535 return 0; … … 616 625 } 617 626 627 if(print_verbose) 628 regfi_set_message_mask(f, REGFI_MSG_INFO|REGFI_MSG_WARN|REGFI_MSG_ERROR); 629 618 630 iter = regfi_iterator_new(f); 619 631 if(iter == NULL) … … 634 646 { 635 647 retr_path_ret = retrievePath(iter, path); 636 printMsgs(iter );648 printMsgs(iter->f); 637 649 freePath(path); 638 650
Note: See TracChangeset
for help on using the changeset viewer.