Re: [PATCH 2/3] libselinux: Fix RESOURCE_LEAK defects reported by coverity scan

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 31, 2019 at 2:22 PM Petr Lautrbach <plautrba@xxxxxxxxxx> wrote:
>
> Signed-off-by: Petr Lautrbach <plautrba@xxxxxxxxxx>
> ---
>  libselinux/src/checkAccess.c        |  4 +++-
>  libselinux/src/label_db.c           |  3 +++
>  libselinux/src/label_file.c         |  4 +++-
>  libselinux/src/load_policy.c        |  4 +++-
>  libselinux/src/selinux_config.c     | 17 +++++++++--------
>  libselinux/src/selinux_restorecon.c | 12 ++++++++++--
>  6 files changed, 31 insertions(+), 13 deletions(-)
>
> diff --git a/libselinux/src/checkAccess.c b/libselinux/src/checkAccess.c
> index 8de57477..16bfcfb6 100644
> --- a/libselinux/src/checkAccess.c
> +++ b/libselinux/src/checkAccess.c
> @@ -89,8 +89,10 @@ int selinux_check_passwd_access(access_vector_t requested)
>                 int retval;
>
>                 passwd_class = string_to_security_class("passwd");
> -               if (passwd_class == 0)
> +               if (passwd_class == 0) {
> +                       freecon(user_context);
>                         return 0;
> +               }
>
>                 retval = security_compute_av_raw(user_context,
>                                                      user_context,
> diff --git a/libselinux/src/label_db.c b/libselinux/src/label_db.c
> index c46d0a1d..fa481e04 100644
> --- a/libselinux/src/label_db.c
> +++ b/libselinux/src/label_db.c
> @@ -283,10 +283,12 @@ db_init(const struct selinux_opt *opts, unsigned nopts,
>         }
>         if (fstat(fileno(filp), &sb) < 0) {
>                 free(catalog);
> +    fclose(filp);
>                 return NULL;
>         }
>         if (!S_ISREG(sb.st_mode)) {
>                 free(catalog);
> +    fclose(filp);
>                 errno = EINVAL;
>                 return NULL;
>         }

Please indent with tabs instead of spaces, like the other lines.
All the other changes in this patch look good to me.

Nicolas




[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux