On Tue, May 06, 2014 at 01:07:53PM -0700, John Johansen wrote:
> +++ 2.9-test/parser/parser_interface.c
> @@ -634,52 +634,73 @@
>       return NULL;
>  int sd_load_buffer(int option, char *buffer, int size)
>  {
>       int fd = -1;
> +     int error = -ENOMEM, bsize;
>       char *filename = NULL;
> +
> +     /* TODO: push backup into caller */
> +     if (!kernel_load)
> +             return 0;
>  
>       switch (option) {
>       case OPTION_ADD:
>               if (asprintf(&filename, "%s/.load", subdomainbase) == -1)
> +                     goto out;
>               break;
>       case OPTION_REPLACE:
>               if (asprintf(&filename, "%s/.replace", subdomainbase) == -1)
> +                     goto out;
>               break;
>       default:
> +             return -EINVAL;
>       }
> [...]
>       }
> +     close(fd);
> +
> +out:
>       free(filename);
> +
>       return error;
>  }

Most of this patch looked alright but in the event of an error return
from asprintf() the contents of &filename are undefined. We shouldn't
pass it to free() in the event of failure.

Thanks

Attachment: signature.asc
Description: Digital signature

-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor

Reply via email to