Changeset 136 for trunk/src


Ignore:
Timestamp:
01/23/09 12:29:51 (16 years ago)
Author:
tim
Message:

fixed various integer issues and memory allocation issues

polished error message functions and added initial messages in a few places

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/common.c

    r134 r136  
    5252
    5353  unsigned int buf_len = sizeof(char)*(len+1);
    54   char* ret_val = malloc(buf_len);
     54  char* ret_val = NULL;
    5555  char* tmp_buf;
    5656
     57  if(buf_len > 0)
     58    ret_val = malloc(buf_len);
    5759  if(ret_val == NULL)
    5860    return NULL;
     
    155157{
    156158  char* ret_val;
    157   char* ascii;
     159  char* ascii = NULL;
    158160  char* tmp_err;
    159161  int ret_err;
    160162  *error_msg = NULL;
    161163
    162   ascii = malloc(length+1);
     164  if(length+1 > 0)
     165    ascii = malloc(length+1);
    163166  if(ascii == NULL)
    164167  {
     
    175178    free(ascii);
    176179    tmp_err = strerror(-ret_err);
    177     *error_msg = (char*)malloc(54+strlen(tmp_err));
     180    *error_msg = (char*)malloc(61+strlen(tmp_err));
    178181    if(*error_msg == NULL)
    179     {
    180       free(ascii);
    181       return NULL;
    182     }
     182      return NULL;
    183183
    184184    sprintf(*error_msg,
     
    305305    {
    306306      tmp_err = strerror(-ret_err);
    307       *error_msg = (char*)malloc(54+strlen(tmp_err));
     307      *error_msg = (char*)malloc(61+strlen(tmp_err));
    308308      if(*error_msg == NULL)
     309      {
     310        free(ascii_tmp);
    309311        return NULL;
     312      }
     313
    310314      sprintf(*error_msg, "MULTI_SZ unicode conversion"
    311315              " failed with '%s'. Quoting as binary.", tmp_err);
  • trunk/src/reglookup-recover.c

    r135 r136  
    9999  if(print_parsedraw)
    100100    free(quoted_raw);
     101  free(quoted_name);
    101102}
    102103
     
    829830      tmp_path = (char*)malloc(strlen(parent_paths[i])+strlen(tmp_name)+2);
    830831      if(tmp_path == NULL)
     832      {
     833        free(tmp_name);
    831834        return 10;
     835      }
     836
    832837      sprintf(tmp_path, "%s/%s", parent_paths[i], tmp_name);
    833838      for(j=0; j < tmp_key->num_values; j++)
  • trunk/src/reglookup.c

    r135 r136  
    255255      if((new_buf = realloc(buf, buf_len)) == NULL)
    256256      {
     257        free(name);
    257258        free(buf);
    258259        free(iter);
     
    372373  const REGFI_NK_REC* sub = NULL;
    373374  char* path = NULL;
     375  char* msgs = NULL;
    374376  int key_type = regfi_type_str2val("KEY");
    375377  bool print_this = true;
     
    377379  root = cur = regfi_iterator_cur_key(iter);
    378380  sub = regfi_iterator_first_subkey(iter);
    379  
     381  msgs = regfi_get_messages(iter->f);
     382  if(msgs != NULL)
     383    fprintf(stderr, "%s", msgs);
    380384  if(root == NULL)
    381385    bailOut(EX_DATAERR, "ERROR: root cannot be NULL.\n");
     
    455459  /* Strip any potential value name at end of path */
    456460  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);
    459462      i++)
    460     tmp_path[i] = path[i];
    461 
     463  { tmp_path[i] = path[i]; }
    462464  tmp_path[i] = NULL;
    463465
     
    471473    if(print_verbose)
    472474      fprintf(stderr, "VERBOSE: Found final path element as root key.\n");
     475    free(tmp_path);
    473476    return 2;
    474477  }
Note: See TracChangeset for help on using the changeset viewer.