Ack, (On behalf of Ramesh)
Mathi.

> -----Original Message-----
> From: Zoran Milinkovic [mailto:[email protected]]
> Sent: Wednesday, August 26, 2015 8:52 PM
> To: [email protected]
> Cc: [email protected]
> Subject: [devel] [PATCH 1 of 1] osaf: fix memory leak in daemonize [#1461]
> 
>  osaf/libs/core/common/osaf_secutil.c |  14 ++++++++------
>  1 files changed, 8 insertions(+), 6 deletions(-)
> 
> 
> The patch fixes a memory leak adding endgrent() in missed places in
> osaf_get_group_list().
> 
> diff --git a/osaf/libs/core/common/osaf_secutil.c
> b/osaf/libs/core/common/osaf_secutil.c
> --- a/osaf/libs/core/common/osaf_secutil.c
> +++ b/osaf/libs/core/common/osaf_secutil.c
> @@ -327,7 +327,7 @@ done:
> 
>  int osaf_get_group_list(const uid_t uid, const gid_t gid, gid_t *groups, int
> *ngroups)  {
> -     int rc = 0;
> +     int rc = -1;    // Initially set to error
>       int size = 0;
>       int max_groups = sysconf(_SC_NGROUPS_MAX);
>       if (max_groups == -1){
> @@ -370,7 +370,7 @@ int osaf_get_group_list(const uid_t uid,
>       struct group *gr = getgrent();
>       if (errno != 0) {
>               LOG_NO("setgrent failed: %s", strerror(errno));
> -             return -1;
> +             goto done;
>       }
> 
>       while (gr){
> @@ -379,7 +379,7 @@ int osaf_get_group_list(const uid_t uid,
>                       gr = getgrent();
>                       if (errno != 0) {
>                               LOG_NO("setgrent failed: %s",
> strerror(errno));
> -                             return -1;
> +                             goto done;
>                       }
>                       continue;
>               }
> @@ -399,12 +399,11 @@ int osaf_get_group_list(const uid_t uid,
>               gr = getgrent();
>               if (errno != 0) {
>                       LOG_NO("setgrent failed: %s", strerror(errno));
> -                     return -1;
> +                     goto done;
>               }
>       }
> 
> -     endgrent();
> -
> +     // rc will be set to non-error value
>       if (groups){
>               *ngroups = (size < *ngroups)? size : *ngroups;
>               rc = size;
> @@ -413,5 +412,8 @@ int osaf_get_group_list(const uid_t uid,
>               rc = 0;
>       }
> 
> +done:
> +     endgrent();
> +
>       return rc;
>  }
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Opensaf-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensaf-devel

------------------------------------------------------------------------------
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to