[SSSD] [PATCH] fix early free of sdap_handle

Simo Sorce ssorce at redhat.com
Wed Apr 14 12:51:46 UTC 2010


On Wed, 14 Apr 2010 10:48:28 +0400
Eugene Indenbom <eindenbom at gmail.com> wrote:

> +    /* private data is allocated as top-level talloc context as
> +     * it may need to survive for a while after main handle
> destruction,
> +     * see sdap_handle_data_lock/sdap_handle_data_release */
> +    sh->private = talloc_zero(NULL, struct sdap_handle_data);
> +    if (!sh->private) {
> +        goto fail;
> +    }
> +
> +    sh->private->sh = sh;
>      return sh;
> +

Sorry Eugene, but I *really* do not like things like this.
- Allocating on NULL: very high risk of memory leaks
- Assigning sh to private->sh: very high risk of accessing free memory
  if sh is freed before private is.

If preserving the handle is important I'd rather have a list of
handles, with old ones pushed down the list as soon as a connection is
marked bad so that they are not reused, but also not lost (memory wise).

-- 
Simo Sorce * Red Hat, Inc * New York



More information about the sssd-devel mailing list