- Timestamp:
- 01/23/09 12:29:51 (16 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/regfi.h
r135 r136 36 36 #include <stdio.h> 37 37 #include <stdbool.h> 38 #include <stdarg.h> 38 39 #include <string.h> 39 40 #include <errno.h> … … 70 71 /* XXX: Has MS defined a REG_QWORD_BE? */ 71 72 /* Not a real type in the registry */ 72 #define REG_KEY 73 #define REG_KEY 0x7FFFFFFF 73 74 74 75 #define REGFI_REGF_SIZE 0x1000 /* "regf" header block size */ … … 325 326 int regfi_close(REGFI_FILE* r); 326 327 327 /* regfi_get_message : Get errors, warnings, and/or verbose information328 * relating to processing of the given registry file.328 /* regfi_get_messages: Get errors, warnings, and/or verbose information 329 * relating to processing of the given registry file. 329 330 * 330 331 * Arguments: … … 334 335 * A newly allocated char* which must be free()d by the caller. 335 336 */ 336 char* regfi_get_message (REGFI_FILE* file);337 char* regfi_get_messages(REGFI_FILE* file); 337 338 338 339 REGFI_ITERATOR* regfi_iterator_new(REGFI_FILE* fh); … … 434 435 REGFI_SUBKEY_LIST** lists, 435 436 bool strict); 436 void regfi_add_message(REGFI_FILE* file, const char* error);437 void regfi_add_message(REGFI_FILE* file, const char* fmt, ...); 437 438 #endif /* _REGFI_H */ -
trunk/lib/lru_cache.c
r122 r136 236 236 return false; 237 237 } 238 else 239 e->index = tmp_index; 238 240 } 239 241 else -
trunk/lib/regfi.c
r135 r136 37 37 /****************************************************************************** 38 38 ******************************************************************************/ 39 void regfi_add_message(REGFI_FILE* file, const char* error)40 { 41 /* XXX: This function is not particularly efficient, 39 void regfi_add_message(REGFI_FILE* file, const char* fmt, ...) 40 { 41 /* XXX: This function is not particularly efficient, 42 42 * but then it is mostly used during errors. 43 43 */ 44 uint32 length; 45 char* tmp; 44 /* XXX: Should we add support for filtering by levels of severity? */ 45 uint32 buf_size, buf_used; 46 char* new_msg; 47 va_list args; 46 48 47 49 if(file->last_message == NULL) 48 length= 0;50 buf_used = 0; 49 51 else 50 length = strlen(error); 51 52 tmp = realloc(file->last_message, length+strlen(file->last_message)+2); 53 if(tmp == NULL) 54 /* XXX: should we do something else here? */ 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? */ 55 58 return; 56 59 57 if(length > 0) 58 strcat(tmp, "\n"); 59 strcat(tmp, error); 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; 60 66 } 61 67 … … 63 69 /****************************************************************************** 64 70 ******************************************************************************/ 65 char* regfi_get_message (REGFI_FILE* file)71 char* regfi_get_messages(REGFI_FILE* file) 66 72 { 67 73 char* ret_val = file->last_message; … … 310 316 /* XXX: this is slow */ 311 317 extra = strlen(sid_str) + strlen(type_str) 312 + strlen(perms_str) + strlen(flags_str) +5;318 + strlen(perms_str) + strlen(flags_str) + 5; 313 319 tmp_val = realloc(ret_val, size+extra); 314 320 … … 316 322 { 317 323 free(ret_val); 324 ret_val = NULL; 318 325 failed = true; 319 326 } … … 840 847 return NULL; 841 848 842 ret_val = (REGFI_VK_REC**)zalloc(sizeof(REGFI_VK_REC*) * num_values);849 ret_val = (REGFI_VK_REC**)zalloc(sizeof(REGFI_VK_REC*) * usable_num_values); 843 850 if(ret_val == NULL) 844 851 { … … 1375 1382 const REGFI_SK_REC* regfi_iterator_cur_sk(REGFI_ITERATOR* i) 1376 1383 { 1377 REGFI_SK_REC* ret_val ;1384 REGFI_SK_REC* ret_val = NULL; 1378 1385 REGFI_HBIN* hbin; 1379 1386 uint32 max_length, off; … … 1982 1989 if(ret_val->data_in_offset) 1983 1990 { 1984 ret_val->data = regfi_parse_data(file, data_offset,1991 ret_val->data = regfi_parse_data(file, ret_val->data_off, 1985 1992 raw_data_size, 4, strict); 1986 1993 } … … 2030 2037 return NULL; 2031 2038 2032 offset = offset - REGFI_REGF_SIZE;2033 2039 for(i = 0; i < length; i++) 2034 2040 ret_val[i] = (uint8)((offset >> i*8) & 0xFF); -
trunk/lib/smb_deps.c
r134 r136 33 33 { 34 34 void* ret_val = NULL; 35 if(( ret_val = (void*)malloc(size)) != NULL)35 if((size > 0) && (ret_val = (void*)malloc(size)) != NULL) 36 36 memset(ret_val, 0, size); 37 37 38 return ret_val; 38 39 } -
trunk/src/common.c
r134 r136 52 52 53 53 unsigned int buf_len = sizeof(char)*(len+1); 54 char* ret_val = malloc(buf_len);54 char* ret_val = NULL; 55 55 char* tmp_buf; 56 56 57 if(buf_len > 0) 58 ret_val = malloc(buf_len); 57 59 if(ret_val == NULL) 58 60 return NULL; … … 155 157 { 156 158 char* ret_val; 157 char* ascii ;159 char* ascii = NULL; 158 160 char* tmp_err; 159 161 int ret_err; 160 162 *error_msg = NULL; 161 163 162 ascii = malloc(length+1); 164 if(length+1 > 0) 165 ascii = malloc(length+1); 163 166 if(ascii == NULL) 164 167 { … … 175 178 free(ascii); 176 179 tmp_err = strerror(-ret_err); 177 *error_msg = (char*)malloc( 54+strlen(tmp_err));180 *error_msg = (char*)malloc(61+strlen(tmp_err)); 178 181 if(*error_msg == NULL) 179 { 180 free(ascii); 181 return NULL; 182 } 182 return NULL; 183 183 184 184 sprintf(*error_msg, … … 305 305 { 306 306 tmp_err = strerror(-ret_err); 307 *error_msg = (char*)malloc( 54+strlen(tmp_err));307 *error_msg = (char*)malloc(61+strlen(tmp_err)); 308 308 if(*error_msg == NULL) 309 { 310 free(ascii_tmp); 309 311 return NULL; 312 } 313 310 314 sprintf(*error_msg, "MULTI_SZ unicode conversion" 311 315 " failed with '%s'. Quoting as binary.", tmp_err); -
trunk/src/reglookup-recover.c
r135 r136 99 99 if(print_parsedraw) 100 100 free(quoted_raw); 101 free(quoted_name); 101 102 } 102 103 … … 829 830 tmp_path = (char*)malloc(strlen(parent_paths[i])+strlen(tmp_name)+2); 830 831 if(tmp_path == NULL) 832 { 833 free(tmp_name); 831 834 return 10; 835 } 836 832 837 sprintf(tmp_path, "%s/%s", parent_paths[i], tmp_name); 833 838 for(j=0; j < tmp_key->num_values; j++) -
trunk/src/reglookup.c
r135 r136 255 255 if((new_buf = realloc(buf, buf_len)) == NULL) 256 256 { 257 free(name); 257 258 free(buf); 258 259 free(iter); … … 372 373 const REGFI_NK_REC* sub = NULL; 373 374 char* path = NULL; 375 char* msgs = NULL; 374 376 int key_type = regfi_type_str2val("KEY"); 375 377 bool print_this = true; … … 377 379 root = cur = regfi_iterator_cur_key(iter); 378 380 sub = regfi_iterator_first_subkey(iter); 379 381 msgs = regfi_get_messages(iter->f); 382 if(msgs != NULL) 383 fprintf(stderr, "%s", msgs); 380 384 if(root == NULL) 381 385 bailOut(EX_DATAERR, "ERROR: root cannot be NULL.\n"); … … 455 459 /* Strip any potential value name at end of path */ 456 460 for(i=0; 457 (path[i] != NULL) && (path[i+1] != NULL) 458 && (i < REGFI_MAX_DEPTH+1+1); 461 (path[i] != NULL) && (path[i+1] != NULL) && (i < REGFI_MAX_DEPTH+1); 459 462 i++) 460 tmp_path[i] = path[i]; 461 463 { tmp_path[i] = path[i]; } 462 464 tmp_path[i] = NULL; 463 465 … … 471 473 if(print_verbose) 472 474 fprintf(stderr, "VERBOSE: Found final path element as root key.\n"); 475 free(tmp_path); 473 476 return 2; 474 477 }
Note: See TracChangeset
for help on using the changeset viewer.