Changeset 7764378


Ignore:
Timestamp:
Sep 26, 2013 7:57:59 AM (5 years ago)
Author:
Mei <mei@…>
Branches:
abac0-leak, master
Children:
80f0770
Parents:
f2622ee
Message:

1) tweak according valgrind's leak report

Files:
15 edited

Legend:

Unmodified
Added
Removed
  • doc/ABAC.hh

    r4f79997 r7764378  
    2525            int load_id_file(char *filename) { return abac_context_load_id_file(m_ctx, filename); }
    2626            int load_id_chunk(abac_chunk_t cert) { return abac_context_load_id_chunk(m_ctx, cert); }
     27            int load_id_id(ID& id); /* defined later in the class */
    2728            int load_attribute_file(char *filename) { return abac_context_load_attribute_file(m_ctx, filename); }
    2829            int load_attribute_chunk(abac_chunk_t cert) { return abac_context_load_attribute_chunk(m_ctx, cert); }
     
    6667            abac_context_t *m_ctx;
    6768        friend class Role;
     69        friend class ID;
    6870        friend class Attribute;
    6971    };
     
    198200
    199201            friend class Attribute;
     202            friend class Context;
    200203
    201204        private:
     
    282285            abac_attribute_t *m_attr;
    283286    };
     287
     288    int Context::load_id_id(ID& id)
     289    { return abac_context_load_id_id(m_ctx, id.m_id); }
    284290}
    285291
  • doc/API

    r831da18 r7764378  
    3131     load id certificate from an chunk
    3232     (C:abac_context_load_id_chunk)
     33
     34   int load_id_id(ID&)
     35     load id certificate from an existing ID
     36     (C:abac_context_load_id_id)
    3337
    3438   int load_attribute_file(char *)
  • libabac/abac.c

    rf2622ee r7764378  
    115115 * Load an ID cert from a id.
    116116 */
    117 /*
    118 int abac_context_load_id_chunk(abac_context_t *ctx, abac_id_t *id) {
     117int abac_context_load_id_id(abac_context_t *ctx, abac_id_t *id) {
    119118    assert(ctx != NULL);
    120119    return abac_verifier_load_id_id(ctx->id_certs,id, ctx->keymap);
    121120}
    122 */
    123121
    124122
     
    143141                abac_credential_free(cred);
    144142            );
    145             abac_list_free(cred_list);
    146143        }
    147144    }
     145    abac_list_free(cred_list);
    148146    return ret;
    149147}
     
    237235        *success = 0;
    238236        abac_list_free(result);
    239         result_graph = abac_graph_new();
    240237
    241238        // TODO: This can probably be better, but it now returns an
  • libabac/abac.h

    rf2622ee r7764378  
    2121    int len;
    2222} abac_chunk_t;
     23void abac_chunk_free(abac_chunk_t);
     24
    2325#endif /* __ABAC_CHUNK_T__ */
    2426
     
    3638int abac_context_load_id_file(abac_context_t *ctx, char *filename);
    3739int abac_context_load_id_chunk(abac_context_t *ctx, abac_chunk_t cert);
     40int abac_context_load_id_id(abac_context_t *ctx, abac_id_t *cert);
    3841int abac_context_load_attribute_file(abac_context_t *ctx, char *filename);
    3942int abac_context_load_attribute_chunk(abac_context_t *ctx, abac_chunk_t cert);
  • libabac/abac.hh

    r831da18 r7764378  
    4545     load id certificate from an chunk
    4646     (C:abac_context_load_id_chunk)
     47f  int load_id_id(ID&)
     48     load id certificate from an existing ID
     49     (C:abac_context_load_id_id)
    4750f  int load_attribute_file(char *)
    4851     load attribute certificate from an id file.
     
    5861            int load_id_file(char *filename) { return abac_context_load_id_file(m_ctx, filename); }
    5962            int load_id_chunk(abac_chunk_t cert) { return abac_context_load_id_chunk(m_ctx, cert); }
     63            int load_id_id(ID& id); /* defined later in the class */
    6064            int load_attribute_file(char *filename) { return abac_context_load_attribute_file(m_ctx, filename); }
    6165            int load_attribute_chunk(abac_chunk_t cert) { return abac_context_load_attribute_chunk(m_ctx, cert); }
     
    130134            abac_context_t *m_ctx;
    131135        friend class Role;
     136        friend class ID;
    132137        friend class Attribute;
    133138    };
     
    455460
    456461            friend class Attribute;
     462            friend class Context;
    457463
    458464        private:
     
    636642            abac_attribute_t *m_attr;
    637643    };
     644
     645    int Context::load_id_id(ID& id)
     646    { return abac_context_load_id_id(m_ctx, id.m_id); }
    638647}
    639648
  • libabac/abac_attribute.c

    rf2622ee r7764378  
    481481    if ( attr->keymap ) abac_keyid_map_free(attr->keymap);
    482482
    483 /* MEI???, this can not be free as if it is a char string */
    484483    free(attr->cert.ptr);
    485484
  • libabac/abac_util.h

    rf2622ee r7764378  
    1313#endif /* __ABAC_CHUNK_T__ */
    1414
     15void abac_chunk_free(abac_chunk_t);
    1516void *abac_xmalloc(size_t);
    16 void abac_chunk_free(abac_chunk_t);
    1717char *abac_xstrdup(char *);
    1818void *abac_xrealloc(void *, size_t);
  • libabac/abac_verifier.c

    rf2622ee r7764378  
    187187
    188188/**
     189 * Load an ID cert with an id
     190 */
     191int abac_verifier_load_id_id(abac_list_t *id_certs,abac_id_t *id,
     192        abac_keyid_map_t *km) {
     193
     194    if (id == NULL)
     195        return ABAC_CERT_INVALID;
     196
     197    return _load_id(id_certs,&id, km);
     198}
     199
     200/**
    189201 * Load an ID cert from a char ptr of a X509 pem data
    190202 * this is called from parse_privilege/parse_abac
     
    311323        );
    312324    }
    313 /* ??? MEI, attr is being reused, just free the list ptr */
     325
     326/* just free the list ptr */
    314327    abac_list_free(attr_list);
    315328    return sz;
     
    324337    abac_list_t *attr_list = abac_attribute_certs_from_file(id_certs,filename);
    325338
    326     if (abac_list_size(attr_list) == 0)
    327         return ABAC_CERT_INVALID;
     339    if (abac_list_size(attr_list) == 0) {
     340        abac_list_free(attr_list);
     341        return ABAC_CERT_INVALID;
     342    }
    328343
    329344    int ret=_load_attribute_certs(id_certs,attr_list, cred_list, km);
  • libabac/options.c

    r461541a r7764378  
    1919    );
    2020    exit(1);
     21}
     22
     23void free_options(options_t *opts)
     24{           
     25    if(opts->keystore) free(opts->keystore);
     26    if(opts->role) free(opts->role);
     27    if(opts->principal) free(opts->principal);
     28    if(opts->rulefile) free(opts->rulefile);
    2129}
    2230
  • libabac/options.h

    r461541a r7764378  
    1414
    1515void get_options(int argc, char **argv, options_t *opts);
     16void free_options(options_t *opts);
    1617
    1718#ifdef __cplusplus
  • libabac/prover.c

    r4f79997 r7764378  
    7373    abac_context_credentials_free(credentials);
    7474    abac_context_free(ctx);
     75    free_options(&opts);
    7576
    7677    if(success) {
  • swig/perl/creddy_keyid.pl

    r9e51a80 r7764378  
    11#!/usr/bin/perl
    22
    3 use Creddy;
     3use ABAC;
    44
    55my $filename = shift || die "Usage: creddy_keyid.pl <cert.pem>\n";
  • tests/example_scripts/c/Makefile.am

    rf2622ee r7764378  
    2828
    2929tleak: abac_attr.c
    30         gcc -g -O1 $(MY_INCLUDES_VAL) -c abac_attr.c -o leak_attr.o
    31         gcc -g -O1 -o tleak leak_attr.o $(MY_LDFLAGS_VAL) 
    32         valgrind -v --leak-check=full ./tleak IceCream_ID.pem  IceCream_private.pem IceCream_attr.xml Chocolate_ID.pem
    33 
     30        make clean
     31        @$(MY_ENV) ./setup.sh 1>/dev/null 2>&1
     32        gcc -g -O1 $(MY_INCLUDES_VAL) -c abac_attr.c -o abac_attr.o
     33        gcc -g -O1 -o leak_attr abac_attr.o $(MY_LDFLAGS_VAL) 
     34        gcc -g -O1 $(MY_INCLUDES_VAL) -c abac_prover.c -o abac_prover.o
     35        gcc -g -O1 -o leak_prover abac_prover.o $(MY_LDFLAGS_VAL)
     36        $(MY_ENV) ./run_leak_prover
    3437
    3538tt: tbasic.c
  • tests/example_scripts/c/abac_attr.c

    rf2622ee r7764378  
    4949
    5050    abac_id_t *chocolate_id = abac_id_from_file(argv[4]);
    51     abac_chunk_t b_chunk=abac_id_cert_chunk(chocolate_id);
    52     rc=abac_context_load_id_chunk(ctx, b_chunk);
    53     abac_chunk_free(b_chunk);
     51    rc=abac_context_load_id_id(ctx, chocolate_id);
    5452
    5553    abac_attribute_t *attr;
     
    9997    free(tmp);
    10098    abac_id_free(id);
    101     abac_id_free(chocolate_id);
    10299    abac_attribute_free(attr);
    103100    abac_context_free(ctx);
  • tests/example_scripts/c/abac_prover.c

    rec550f7 r7764378  
    1717#include <assert.h>
    1818#include <string.h>
     19#include <stdlib.h>
    1920
    2021#include <abac.h>
     
    3435    printf("with %s\n", with);
    3536
    36 int k=1; /* use to do repetitions */
     37int k=10; /* use to do repetitions */
    3738while(k) {
    3839    credentials = abac_context_query(ctx,
     
    5657    k=k-1;
    5758}
    58 
     59    free(query);
     60    free(with);
    5961
    6062{ /* dump credentials from context */
Note: See TracChangeset for help on using the changeset viewer.