9d87610 sss_client: Fix memory leak in nss_mc_{group,passwd}

2 files Authored by lslebodn 9 years ago, Committed by jhrozek 9 years ago,
    sss_client: Fix memory leak in nss_mc_{group,passwd}
    
    Memory leak can happen with long living clients where there are records with
    colliding hashes; usually LDAP servers with many  users or groups.
    
    Function sss_nss_mc_get_record allocates memory that is stored into "rec",
    with next iteration variable rec is overriden with new record and old
    one is lost and cannot be freed.
    
    Example code flow:
    src/sss_client/nss_mc_group.c:133: alloc_arg: "sss_nss_mc_get_record" allocates memory that is stored into "rec".
    src/sss_client/nss_mc_common.c:216:13: alloc_fn: Storage is returned from allocation function "malloc".
    src/sss_client/nss_mc_common.c:216:13: var_assign: Assigning: "copy_rec" = "malloc(rec_len)".
    src/sss_client/nss_mc_common.c:225:9: noescape: Resource "copy_rec" is not freed or pointed-to in function "memcpy". [Note: The source code implementation of the function has been overridden by a builtin model.]
    src/sss_client/nss_mc_common.c:239:5: var_assign: Assigning: "*_rec" = "copy_rec".
    src/sss_client/nss_mc_group.c:163: noescape: Resource "rec" is not freed or pointed-to in "sss_nss_mc_next_slot_with_hash".
    src/sss_client/nss_mc_common.c:294:60: noescape: "sss_nss_mc_next_slot_with_hash(struct sss_mc_rec *, uint32_t)" does not free or save its pointer parameter "rec".
    src/sss_client/nss_mc_group.c:133: overwrite_var: Overwriting "rec" in call to "sss_nss_mc_get_record" leaks the storage that "rec" points to.
    src/sss_client/nss_mc_common.c:239:5: write_notnull_to_parm: Assigning: "*_rec" = "copy_rec".
    
    Reviewed-by: Michal Židek <mzidek@redhat.com>
    Reviewed-by: Sumit Bose <sbose@redhat.com>