Changeset 147


Ignore:
Timestamp:
02/22/09 14:31:52 (16 years ago)
Author:
tim
Message:

added talloc library

incorporated talloc into winsec and lru_cache modules

introduced talloc into SK caching system

Location:
trunk
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile

    r145 r147  
    1313OPTS=-std=gnu89 -pedantic -Wall -ggdb
    1414#OPTS=-std=gnu89 -pedantic -Wall
    15 INC=-I/usr/local/include
     15INC:=-I$(PWD)/include -I/usr/local/include
    1616LIB=-L/usr/local/lib -lm
    1717BIN_EXT=
  • trunk/include/lru_cache.h

    r122 r147  
    11/*
    2  * Copyright (C) 2008 Timothy D. Morgan
     2 * Copyright (C) 2008-2009 Timothy D. Morgan
    33 *
    44 * This program is free software; you can redistribute it and/or modify
     
    2727#include <string.h>
    2828#include <unistd.h>
     29#include "talloc.h"
    2930
    3031struct lru_cache_element;
     
    5051  lru_cache_element* newest;
    5152  lru_cache_element** table;
    52   bool free_data;
     53  bool talloc_data;
    5354} lru_cache;
    5455
    5556
    56 lru_cache* lru_cache_create(uint32_t max_keys, uint32_t secret, bool free_data);
     57lru_cache* lru_cache_create(uint32_t max_keys, uint32_t secret);
     58lru_cache* lru_cache_create_ctx(void* talloc_ctx, uint32_t max_keys,
     59                                uint32_t secret, bool talloc_data);
    5760void lru_cache_destroy(lru_cache* ht);
    5861
    59 /* Returns a pointer to the old, replaced data stored at index. 
    60  * Returns NULL if no entry was overwritten.
     62/*
     63 *
    6164 */
    6265bool lru_cache_update(lru_cache* ht, const void* index,
  • trunk/include/regfi.h

    r146 r147  
    4646#include <assert.h>
    4747
     48#include "talloc.h"
    4849#include "smb_deps.h"
    4950#include "winsec.h"
     
    8485#define REG_KEY                    0x7FFFFFFF
    8586
    86 #define REGFI_REGF_SIZE            0x1000 /* "regf" header block size */
    87 #define REGFI_HBIN_ALLOC           0x1000 /* Minimum allocation unit for HBINs */
    8887#define REGFI_MAX_DEPTH            512
    8988#define REGFI_OFFSET_NONE          0xffffffff
     
    9392
    9493/* Header sizes and magic number lengths for various records */
     94#define REGFI_HBIN_ALLOC           0x1000 /* Minimum allocation unit for HBINs */
     95#define REGFI_REGF_SIZE            0x1000 /* "regf" header block size */
    9596#define REGFI_REGF_MAGIC_SIZE      4
    9697#define REGFI_HBIN_MAGIC_SIZE      4
     
    107108 *      been reported that Windows timestamps are never more than a
    108109 *      certain granularity (250ms?), which could be used to help
    109  *      eliminate false positives.  Would need to validate this and
     110 *      eliminate false positives.  Would need to verify this and
    110111 *      perhaps conservatively implement a check.
    111112 */
  • trunk/include/winsec.h

    r134 r147  
    4242
    4343#include "smb_deps.h"
     44#include "talloc.h"
    4445
    4546
     
    145146} WINSEC_DESC;
    146147
     148WINSEC_DESC* winsec_parse_descriptor(const uint8_t* buf, uint32_t buf_len);
     149void winsec_free_descriptor(WINSEC_DESC* desc);
    147150
    148 /* XXX: Need API functions to deallocate these structures */
    149 WINSEC_DESC* winsec_parse_desc(const uint8_t* buf, uint32_t buf_len);
    150 WINSEC_ACL* winsec_parse_acl(const uint8_t* buf, uint32_t buf_len);
    151 WINSEC_ACE* winsec_parse_ace(const uint8_t* buf, uint32_t buf_len);
    152 WINSEC_DOM_SID* winsec_parse_dom_sid(const uint8_t* buf, uint32_t buf_len);
    153 WINSEC_UUID* winsec_parse_uuid(const uint8_t* buf, uint32_t buf_len);
     151WINSEC_DESC* winsec_parse_desc(void* talloc_ctx,
     152                               const uint8_t* buf, uint32_t buf_len);
     153WINSEC_ACL* winsec_parse_acl(void* talloc_ctx,
     154                             const uint8_t* buf, uint32_t buf_len);
     155WINSEC_ACE* winsec_parse_ace(void* talloc_ctx,
     156                             const uint8_t* buf, uint32_t buf_len);
     157WINSEC_DOM_SID* winsec_parse_dom_sid(void* talloc_ctx,
     158                                     const uint8_t* buf, uint32_t buf_len);
     159WINSEC_UUID* winsec_parse_uuid(void* talloc_ctx,
     160                               const uint8_t* buf, uint32_t buf_len);
    154161
    155162size_t winsec_sid_size(const WINSEC_DOM_SID* sid);
  • trunk/lib/Makefile

    r132 r147  
    33################################################################################
    44
    5 FILES=regfi.o smb_deps.o winsec.o void_stack.o range_list.o lru_cache.o
     5FILES=regfi.o smb_deps.o winsec.o void_stack.o range_list.o lru_cache.o talloc.o
    66
    77all: $(FILES)
     
    2525        $(CC) $(CFLAGS) $(OPTS) $(INC) -c -o $@ lru_cache.c
    2626
     27talloc.o: talloc.c
     28        $(CC) $(CFLAGS) $(OPTS) $(INC) -c -o $@ talloc.c
     29
    2730clean:
    2831        rm -f $(FILES)
  • trunk/lib/lru_cache.c

    r146 r147  
    11/*
    2  * Copyright (C) 2008 Timothy D. Morgan
     2 * Copyright (C) 2008-2009 Timothy D. Morgan
    33 *
    44 * This program is free software; you can redistribute it and/or modify
     
    1818 */
    1919
    20 #include "../include/lru_cache.h"
     20#include "lru_cache.h"
    2121
    2222
     
    9797#endif
    9898
    99 lru_cache* lru_cache_create(uint32_t max_keys, uint32_t secret, bool free_data)
     99
     100lru_cache* lru_cache_create(uint32_t max_keys, uint32_t secret)
     101{
     102  return lru_cache_create_ctx(NULL, max_keys, secret, false);
     103}
     104
     105
     106lru_cache* lru_cache_create_ctx(void* talloc_ctx, uint32_t max_keys,
     107                                uint32_t secret, bool talloc_data)
    100108{
    101109  lru_cache* ret_val;
    102110
    103   ret_val = (lru_cache*)malloc(sizeof(lru_cache));
     111  ret_val = talloc(talloc_ctx, lru_cache);
    104112  if(ret_val == NULL)
    105113    return NULL;
     
    114122  }
    115123
    116   ret_val->table
    117     = (lru_cache_element**)malloc(sizeof(lru_cache_element*)
    118                                   * ret_val->num_buckets);
     124  ret_val->table = talloc_array(ret_val,
     125                                lru_cache_element*, ret_val->num_buckets);
    119126  if(ret_val->table == NULL)
    120127  {
    121     free(ret_val);
     128    talloc_free(ret_val);
    122129    return NULL;
    123130  }
     
    127134  ret_val->max_keys = max_keys;
    128135  ret_val->secret = secret;
    129   ret_val->free_data = free_data;
     136  ret_val->talloc_data = talloc_data;
    130137  ret_val->num_keys = 0;
    131138  memset(ret_val->table, 0, ret_val->num_buckets*sizeof(lru_cache_element*));
     
    137144void lru_cache_destroy(lru_cache* ht)
    138145{
    139   lru_cache_element* cur;
    140   lru_cache_element* last = NULL;
    141  
    142   for(cur=ht->oldest; cur != NULL; last=cur,cur=cur->newer)
    143   {
    144     if(last != NULL)
    145     {
    146       if(ht->free_data)
    147         free(last->data);
    148       free(last->index);
    149       free(last);
    150     }
    151   }
    152   free(ht->table);
    153146  ht->secret = 0;
    154   free(ht);
     147  talloc_free(ht);
    155148}
    156149
     
    179172     * so remove it from the list for now.
    180173     */
    181     if(ht->free_data)
    182       free(e->data);
     174    if(ht->talloc_data)
     175      talloc_free(e->data);
    183176
    184177    if(e->newer == NULL)
     
    226219      e->next = NULL;
    227220
    228       if(ht->free_data)
    229         free(e->data);
    230 
    231       tmp_index = realloc(e->index, index_len);
     221      if(ht->talloc_data)
     222        talloc_free(e->data);
     223
     224      tmp_index = talloc_realloc_size(e, e->index, index_len);
    232225      if(tmp_index == NULL)
    233226      {
    234         free(e->index);
    235         free(e);
     227        talloc_free(e);
    236228        return false;
    237229      }
     
    242234    { /* Brand new element because we have room to spare. */
    243235
    244       e = (lru_cache_element*)malloc(sizeof(lru_cache_element));
     236      e = talloc(ht->table, lru_cache_element);
    245237      if(e == NULL)
    246238        return false;
    247239     
    248       e->index = malloc(index_len);
     240      e->index = talloc_size(e, index_len);
    249241      if(e->index == NULL)
    250242      {
    251         free(e);
     243        talloc_free(e);
    252244        return false;
    253245      }
     
    264256  }
    265257  e->data = data;
     258  if(ht->talloc_data)
     259    talloc_steal(e, e->data);
    266260
    267261  /* Finally, let's insert the element to the newest position in the LRU list.*/
     
    336330    return false;
    337331
    338   if(ht->free_data)
    339     free(cur->data);
    340 
    341332  /* Detach from list */
    342333  if(cur->newer == NULL)
     
    356347    last->next = cur->next;
    357348
    358   free(cur->index);
    359   free(cur);
     349  talloc_free(cur);
    360350 
    361351  /* Removing entry, decrement counters. */
  • trunk/lib/range_list.c

    r145 r147  
    11/*
    2  * Copyright (C) 2008 Timothy D. Morgan
     2 * Copyright (C) 2008-2009 Timothy D. Morgan
    33 *
    44 * This program is free software; you can redistribute it and/or modify
     
    1919
    2020#include <math.h>
    21 #include "../include/range_list.h"
     21#include "range_list.h"
    2222
    2323
  • trunk/lib/regfi.c

    r146 r147  
    2424 */
    2525
    26 #include "../include/regfi.h"
     26#include "regfi.h"
    2727
    2828
     
    762762
    763763
    764 /*******************************************************************
    765  *******************************************************************/
    766 REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32 offset, uint32 max_size, bool strict)
     764/******************************************************************************
     765 *
     766 ******************************************************************************/
     767REGFI_SK_REC* regfi_parse_sk(REGFI_FILE* file, uint32 offset, uint32 max_size,
     768                             bool strict)
    767769{
    768770  REGFI_SK_REC* ret_val;
    769   uint8* sec_desc_buf;
     771  uint8* sec_desc_buf = NULL;
    770772  uint32 cell_length, length;
    771   /*prs_struct ps;*/
    772773  uint8 sk_header[REGFI_SK_MIN_LENGTH];
    773774  bool unalloc = false;
     
    788789  }
    789790
    790   ret_val = (REGFI_SK_REC*)zalloc(sizeof(REGFI_SK_REC));
     791  /*  ret_val = (REGFI_SK_REC*)zalloc(sizeof(REGFI_SK_REC));*/
     792  ret_val = talloc(NULL, REGFI_SK_REC);
    791793  if(ret_val == NULL)
    792794    return NULL;
     
    805807    regfi_add_message(file, REGFI_MSG_WARN, "Invalid cell size found while"
    806808                      " parsing SK record at offset 0x%.8X.", offset);
    807     free(ret_val);
    808     return NULL;
     809    goto fail;
    809810  }
    810811
     
    824825                      " are not a multiple of 8 while parsing SK record at"
    825826                      " offset 0x%.8X.", offset);
    826     free(ret_val);
    827     return NULL;
     827    goto fail;
    828828  }
    829829
     
    833833                      " cell while parsing SK record at offset 0x%.8X.",
    834834                      offset);
    835     free(ret_val);
    836     return NULL;
    837   }
    838 
    839   sec_desc_buf = (uint8*)zalloc(ret_val->desc_size);
    840   if(ret_val == NULL)
    841   {
    842     free(ret_val);
    843     return NULL;
    844   }
     835    goto fail;
     836  }
     837
     838  sec_desc_buf = (uint8*)malloc(ret_val->desc_size);
     839  if(sec_desc_buf == NULL)
     840    goto fail;
    845841
    846842  length = ret_val->desc_size;
     
    851847                      " descriptor while parsing SK record at offset 0x%.8X.",
    852848                      offset);
    853     free(ret_val);
    854     return NULL;
    855   }
    856 
    857   if(!(ret_val->sec_desc = winsec_parse_desc(sec_desc_buf, ret_val->desc_size)))
     849    goto fail;
     850  }
     851
     852  if(!(ret_val->sec_desc = winsec_parse_desc(ret_val, sec_desc_buf,
     853                                                  ret_val->desc_size)))
    858854  {
    859855    regfi_add_message(file, REGFI_MSG_ERROR, "Failed to parse security"
    860856                      " descriptor while parsing SK record at offset 0x%.8X.",
    861857                      offset);
     858    goto fail;
     859  }
     860
     861  free(sec_desc_buf);
     862  return ret_val;
     863
     864 fail:
     865  if(sec_desc_buf != NULL)
    862866    free(sec_desc_buf);
    863     free(ret_val);
    864     return NULL;
    865   }
    866   free(sec_desc_buf);
    867 
    868 
    869   return ret_val;
     867  talloc_free(ret_val);
     868  return NULL;
    870869}
    871870
     
    11471146  const REGFI_HBIN* hbin;
    11481147  uint32 max_length;
    1149 
     1148  void* failure_ptr = NULL;
     1149 
    11501150  /* First look if we have already parsed it */
    11511151  ret_val = (REGFI_SK_REC*)lru_cache_find(file->sk_cache, &offset, 4);
     
    11651165    if(ret_val == NULL)
    11661166    { /* Cache the parse failure and bail out. */
    1167       lru_cache_update(file->sk_cache, &offset, 4, (void*)REGFI_OFFSET_NONE);
     1167      failure_ptr = talloc(NULL, uint32_t);
     1168      if(failure_ptr == NULL)
     1169        return NULL;
     1170      *(uint32_t*)failure_ptr = REGFI_OFFSET_NONE;
     1171      lru_cache_update(file->sk_cache, &offset, 4, failure_ptr);
    11681172      return NULL;
    11691173    }
     
    12871291
    12881292  /* Cache an unlimited number of SK records.  Typically there are very few. */
    1289   rb->sk_cache = lru_cache_create(0, cache_secret, true);
     1293  rb->sk_cache = lru_cache_create_ctx(NULL, 0, cache_secret, true);
    12901294
    12911295  /* Default message mask */
     
    13141318  range_list_free(file->hbins);
    13151319
     1320 
    13161321  if(file->sk_cache != NULL)
    13171322    lru_cache_destroy(file->sk_cache);
  • trunk/lib/smb_deps.c

    r136 r147  
    2424 */
    2525
    26 #include "../include/smb_deps.h"
     26#include "smb_deps.h"
    2727
    2828
  • trunk/lib/void_stack.c

    r111 r147  
    2222 */
    2323
    24 #include "../include/void_stack.h"
     24#include "void_stack.h"
    2525
    2626void_stack* void_stack_new(unsigned short max_size)
  • trunk/lib/winsec.c

    r134 r147  
    2424 */
    2525
    26 #include "../include/winsec.h"
    27 
     26#include "winsec.h"
     27
     28
     29/******************************************************************************
     30 * Non-talloc() interface for parsing a descriptor.
     31 ******************************************************************************/
     32WINSEC_DESC* winsec_parse_descriptor(const uint8_t* buf, uint32_t buf_len)
     33{
     34  return winsec_parse_desc(NULL, buf, buf_len);
     35}
     36
     37
     38/******************************************************************************
     39 * Free a descriptor.  Not needed if using talloc and a parent context is freed.
     40 ******************************************************************************/
     41void winsec_free_descriptor(WINSEC_DESC* desc)
     42{
     43  talloc_free(desc);
     44}
    2845
    2946
     
    3148 * Parses a WINSEC_DESC structure and substructures.
    3249 ******************************************************************************/
    33 WINSEC_DESC* winsec_parse_desc(const uint8_t* buf, uint32_t buf_len)
     50WINSEC_DESC* winsec_parse_desc(void* talloc_ctx,
     51                               const uint8_t* buf, uint32_t buf_len)
    3452{
    3553  WINSEC_DESC* ret_val;
     
    3755  if (buf == NULL || buf_len <  WINSEC_DESC_HEADER_SIZE)
    3856    return NULL;
    39 
     57  /*
    4058  if((ret_val = (WINSEC_DESC*)zalloc(sizeof(WINSEC_DESC))) == NULL)
     59    return NULL;
     60  */
     61  if((ret_val = talloc(talloc_ctx, WINSEC_DESC)) == NULL)
    4162    return NULL;
    4263
     
    6182     || (ret_val->off_dacl >= buf_len))
    6283  {
    63     free(ret_val);
     84    talloc_free(ret_val);
    6485    return NULL;
    6586  }
     
    6788  if(ret_val->off_owner_sid != 0)
    6889  {
    69     ret_val->owner_sid = winsec_parse_dom_sid(buf + ret_val->off_owner_sid,
     90    ret_val->owner_sid = winsec_parse_dom_sid(ret_val,
     91                                              buf + ret_val->off_owner_sid,
    7092                                              buf_len - ret_val->off_owner_sid);
    7193    if(ret_val->owner_sid == NULL)
    7294    {
    73       free(ret_val);
     95      talloc_free(ret_val);
    7496      return NULL;
    7597    }
     
    78100  if (ret_val->off_grp_sid != 0)
    79101  {
    80     ret_val->grp_sid = winsec_parse_dom_sid(buf + ret_val->off_grp_sid,
     102    ret_val->grp_sid = winsec_parse_dom_sid(ret_val, buf + ret_val->off_grp_sid,
    81103                                            buf_len - ret_val->off_grp_sid);
    82104    if(ret_val->grp_sid == NULL)
    83105    {
    84       if(ret_val->owner_sid != NULL)
    85         free(ret_val->owner_sid);
    86       free(ret_val);
     106      talloc_free(ret_val);
    87107      return NULL;
    88108    }
     
    91111  if ((ret_val->control & WINSEC_DESC_SACL_PRESENT) && ret_val->off_sacl)
    92112  {
    93     ret_val->sacl = winsec_parse_acl(buf + ret_val->off_sacl,
     113    ret_val->sacl = winsec_parse_acl(ret_val, buf + ret_val->off_sacl,
    94114                                     buf_len - ret_val->off_sacl);
    95115    if(ret_val->sacl == NULL)
    96116    {
    97       if(ret_val->owner_sid != NULL)
    98         free(ret_val->owner_sid);
    99       if(ret_val->grp_sid != NULL)
    100         free(ret_val->grp_sid);
    101       free(ret_val);
     117      talloc_free(ret_val);
    102118      return NULL;
    103119    }
     
    106122  if ((ret_val->control & WINSEC_DESC_DACL_PRESENT) && ret_val->off_dacl != 0)
    107123  {
    108     ret_val->dacl = winsec_parse_acl(buf + ret_val->off_dacl,
     124    ret_val->dacl = winsec_parse_acl(ret_val, buf + ret_val->off_dacl,
    109125                                     buf_len - ret_val->off_dacl);
    110126    if(ret_val->dacl == NULL)
    111127    {
    112       if(ret_val->owner_sid != NULL)
    113         free(ret_val->owner_sid);
    114       if(ret_val->grp_sid != NULL)
    115         free(ret_val->grp_sid);
    116       if(ret_val->sacl != NULL)
    117         free(ret_val->sacl);
    118       free(ret_val);
     128      talloc_free(ret_val);
    119129      return NULL;
    120130    }
     
    128138 * Parses a WINSEC_ACL structure and all substructures.
    129139 ******************************************************************************/
    130 WINSEC_ACL* winsec_parse_acl(const uint8_t* buf, uint32_t buf_len)
     140WINSEC_ACL* winsec_parse_acl(void* talloc_ctx,
     141                             const uint8_t* buf, uint32_t buf_len)
    131142{
    132143  uint32_t i, offset;
     
    139150  if (buf == NULL || buf_len < 8)
    140151    return NULL;
    141 
     152  /*
    142153  if((ret_val = (WINSEC_ACL*)zalloc(sizeof(WINSEC_ACL))) == NULL)
     154    return NULL;
     155  */
     156  if((ret_val = talloc(talloc_ctx, WINSEC_ACL)) == NULL)
    143157    return NULL;
    144158 
     
    153167  if((ret_val->size > buf_len) || (ret_val->num_aces > 4095))
    154168  {
    155     free(ret_val);
     169    talloc_free(ret_val);
    156170    return NULL;
    157171  }
     
    161175   * (allow no access).
    162176   */
    163   if((ret_val->aces = (WINSEC_ACE**)zcalloc(sizeof(WINSEC_ACE*),
     177  /*  if((ret_val->aces = (WINSEC_ACE**)zcalloc(sizeof(WINSEC_ACE*),
    164178                                           ret_val->num_aces+1)) == NULL)
    165   {
    166     free(ret_val);
     179  */
     180  if((ret_val->aces = talloc_array(ret_val, WINSEC_ACE*,
     181                                   ret_val->num_aces+1)) == NULL)
     182  {
     183    talloc_free(ret_val);
    167184    return NULL;
    168185  }
     
    171188  for(i=0; i < ret_val->num_aces; i++)
    172189  {
    173     ret_val->aces[i] = winsec_parse_ace(buf+offset, buf_len-offset);
     190    ret_val->aces[i] = winsec_parse_ace(ret_val->aces,
     191                                        buf+offset, buf_len-offset);
    174192    if(ret_val->aces[i] == NULL)
    175193    {
    176       free(ret_val->aces);
    177       free(ret_val);
     194      talloc_free(ret_val);
    178195      return NULL;
    179196    }
     
    182199    if(offset > buf_len)
    183200    {
    184       free(ret_val->aces);
    185       free(ret_val);
     201      talloc_free(ret_val);
    186202      return NULL;
    187203    }
     
    195211 * Parses a WINSEC_ACE structure and all substructures.
    196212 ******************************************************************************/
    197 WINSEC_ACE* winsec_parse_ace(const uint8_t* buf, uint32_t buf_len)
     213WINSEC_ACE* winsec_parse_ace(void* talloc_ctx,
     214                             const uint8_t* buf, uint32_t buf_len)
    198215{
    199216  uint32_t offset;
     
    203220    return NULL;
    204221
    205   if((ret_val = (WINSEC_ACE*)zalloc(sizeof(WINSEC_ACE))) == NULL)
     222  /*  if((ret_val = (WINSEC_ACE*)zalloc(sizeof(WINSEC_ACE))) == NULL)*/
     223
     224  if((ret_val = talloc(talloc_ctx, WINSEC_ACE)) == NULL)
    206225    return NULL;
    207226
     
    221240    if(ret_val->obj_flags & WINSEC_ACE_OBJECT_PRESENT)
    222241    {
    223       ret_val->obj_guid = winsec_parse_uuid(buf+offset, buf_len-offset);
     242      ret_val->obj_guid = winsec_parse_uuid(ret_val,
     243                                            buf+offset, buf_len-offset);
    224244      if(ret_val->obj_guid == NULL)
    225245      {
    226         free(ret_val);
     246        talloc_free(ret_val);
    227247        return NULL;
    228248      }
     
    232252    if(ret_val->obj_flags & WINSEC_ACE_OBJECT_INHERITED_PRESENT)
    233253    {
    234       ret_val->inh_guid = winsec_parse_uuid(buf+offset, buf_len-offset);
     254      ret_val->inh_guid = winsec_parse_uuid(ret_val,
     255                                            buf+offset, buf_len-offset);
    235256      if(ret_val->inh_guid == NULL)
    236257      {
    237         if(ret_val->obj_guid != NULL)
    238           free(ret_val->obj_guid);
    239         free(ret_val);
     258        talloc_free(ret_val);
    240259        return NULL;
    241260      }
     
    244263  }
    245264
    246   ret_val->trustee = winsec_parse_dom_sid(buf+offset, buf_len-offset);
     265  ret_val->trustee = winsec_parse_dom_sid(ret_val, buf+offset, buf_len-offset);
    247266  if(ret_val->trustee == NULL)
    248267  {
    249     if(ret_val->obj_guid != NULL)
    250       free(ret_val->obj_guid);
    251     if(ret_val->inh_guid != NULL)
    252       free(ret_val->inh_guid);
    253     free(ret_val);
    254         return NULL;
     268    talloc_free(ret_val);
     269    return NULL;
    255270  }
    256271 
     
    262277 * Parses a WINSEC_DOM_SID structure.
    263278 ******************************************************************************/
    264 WINSEC_DOM_SID* winsec_parse_dom_sid(const uint8_t* buf, uint32_t buf_len)
     279WINSEC_DOM_SID* winsec_parse_dom_sid(void* talloc_ctx,
     280                                     const uint8_t* buf, uint32_t buf_len)
    265281{
    266282  uint32_t i;
     
    270286    return NULL;
    271287
    272   if((ret_val = (WINSEC_DOM_SID*)zalloc(sizeof(WINSEC_DOM_SID))) == NULL)
     288  /*  if((ret_val = (WINSEC_DOM_SID*)zalloc(sizeof(WINSEC_DOM_SID))) == NULL)*/
     289  if((ret_val = talloc(talloc_ctx, WINSEC_DOM_SID)) == NULL)
    273290    return NULL;
    274291
     
    283300  if(buf_len < ret_val->num_auths*sizeof(uint32_t)+8)
    284301  {
    285     free(ret_val);
     302    talloc_free(ret_val);
    286303    return NULL;
    287304  }
     
    297314 * Parses a WINSEC_UUID struct.
    298315 ******************************************************************************/
    299 WINSEC_UUID* winsec_parse_uuid(const uint8_t* buf, uint32_t buf_len)
     316WINSEC_UUID* winsec_parse_uuid(void* talloc_ctx,
     317                               const uint8_t* buf, uint32_t buf_len)
    300318{
    301319  WINSEC_UUID* ret_val;
     
    304322    return false;
    305323
    306   if((ret_val = (WINSEC_UUID*)zalloc(sizeof(WINSEC_UUID))) == NULL)
     324  /* if((ret_val = (WINSEC_UUID*)zalloc(sizeof(WINSEC_UUID))) == NULL)*/
     325  if((ret_val = talloc(talloc_ctx, WINSEC_UUID)) == NULL)
    307326    return NULL;
    308327 
     
    321340 * Calculates the size of a SID.
    322341 ******************************************************************************/
    323 /*size_t sid_size(const WINSEC_DOM_SID *sid)*/
    324342size_t winsec_sid_size(const WINSEC_DOM_SID* sid)
    325343{
     
    334352 * Compare the auth portion of two SIDs.
    335353 ******************************************************************************/
    336 /*int sid_compare_auth(const WINSEC_DOM_SID *sid1, const WINSEC_DOM_SID *sid2)*/
    337354int winsec_sid_compare_auth(const WINSEC_DOM_SID* sid1, const WINSEC_DOM_SID* sid2)
    338355{
     
    360377 * Compare two SIDs.
    361378 ******************************************************************************/
    362 /*int sid_compare(const WINSEC_DOM_SID *sid1, const WINSEC_DOM_SID *sid2)*/
    363379int winsec_sid_compare(const WINSEC_DOM_SID* sid1, const WINSEC_DOM_SID* sid2)
    364380{
  • trunk/src/reglookup-recover.c

    r146 r147  
    2323#include <stdlib.h>
    2424
    25 #include "../include/regfi.h"
    26 #include "../include/range_list.h"
    27 #include "../include/lru_cache.h"
     25#include "regfi.h"
     26#include "range_list.h"
     27#include "lru_cache.h"
    2828
    2929
  • trunk/src/reglookup.c

    r143 r147  
    2727#include <strings.h>
    2828#include <time.h>
    29 #include "../include/regfi.h"
    30 #include "../include/void_stack.h"
     29#include "regfi.h"
     30#include "void_stack.h"
    3131
    3232/* Globals, influenced by command line parameters */
Note: See TracChangeset for help on using the changeset viewer.