Ignore:
Timestamp:
03/01/09 21:17:46 (15 years ago)
Author:
tim
Message:

integrated talloc into most of the rest of the regfi library
fixed a length validation issue

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/reglookup-recover.c

    r149 r150  
    1515 * You should have received a copy of the GNU General Public License
    1616 * along with this program; if not, write to the Free Software
    17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
     17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    1818 *
    1919 * $Id$
     
    8484    quoted_name = malloc(1*sizeof(char));
    8585    if(quoted_name == NULL)
    86       bailOut(REGLOOKUP_EXIT_OSERR, "ERROR: Could not allocate sufficient memory.\n");
     86      bailOut(REGLOOKUP_EXIT_OSERR,
     87              "ERROR: Could not allocate sufficient memory.\n");
    8788    quoted_name[0] = '\0';
    8889
     
    297298          virt_offset = cur_ancestor->parent_off;
    298299       
    299         path_element = (struct name_holder*)malloc(sizeof(struct name_holder));
     300        path_element = talloc(path_stack, struct name_holder);
    300301        if(path_element != NULL)
    301302          path_element->quoted_name = quote_string(cur_ancestor->keyname,
     
    305306           || !void_stack_push(path_stack, path_element))
    306307        {
    307           free(cur_ancestor->keyname);
    308           free(cur_ancestor);
    309           void_stack_free_deep(path_stack);
     308          /* XXX: Need to add a warning here */
     309          regfi_free_key(cur_ancestor);
     310          void_stack_free(path_stack);
    310311          return NULL;
    311312        }
     
    318319        ret_val_size += path_element->length + 1;
    319320
    320         regfi_key_free(cur_ancestor);
     321        regfi_free_key(cur_ancestor);
    321322      }
    322323    }
     
    328329  if(ret_val == NULL)
    329330  {
    330     void_stack_free_deep(path_stack);
     331    void_stack_free(path_stack);
    331332    return NULL;
    332333  }
     
    340341    ret_val_used += path_element->length + 1;
    341342    free(path_element->quoted_name);
    342     free(path_element);
     343    talloc_free(path_element);
    343344  }
    344345  void_stack_free(path_stack);
     
    532533  REGFI_NK_REC* key;
    533534  uint32 i, j;
     535  int error_code = 0;
    534536
    535537  for(i=0; i < range_list_size(unalloc_cells); i++)
     
    550552        {
    551553          fprintf(stderr, "ERROR: Couldn't add key to unalloc_keys.\n");
    552           return 20;
     554          error_code = 20;
     555          goto fail;
    553556        }
     557        talloc_steal(unalloc_keys, key);
    554558        j+=key->cell_size-8;
    555559      }
     
    561565    cur_elem = range_list_get(unalloc_keys, i);
    562566    if(!removeRange(unalloc_cells, cur_elem->offset, cur_elem->length))
    563       return 30;
     567    {
     568      error_code = 30;
     569      goto fail;
     570    }
    564571  }
    565572
    566573  return 0;
     574
     575 fail:
     576  regfi_free_key(key);
     577  return error_code;
    567578}
    568579
     
    611622             * so prune it.
    612623             */
    613             free(nk->values->elements);
    614             free(nk->values);
     624            talloc_free(nk->values);
    615625            nk->values = NULL;
    616626          }
     
    639649                                     vk->cell_size, vk))
    640650                  {
    641                     free(vk);
     651                    talloc_free(vk);
    642652                    return 30;
    643653                  }
     
    647657                }
    648658                else
    649                   free(vk);
     659                  talloc_free(vk);
    650660              }
    651661            }
Note: See TracChangeset for help on using the changeset viewer.