- Timestamp:
- 01/23/09 12:29:51 (16 years ago)
- Location:
- trunk/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.