| To: | xfsprogs <xfs@xxxxxxxxxxx> |
|---|---|
| Subject: | [PATCH] xfsprogs: fix potential memory free issues in quota_group_type() |
| From: | Li Zhong <zhong@xxxxxxxxxxxxxxxxxx> |
| Date: | Sun, 22 Sep 2013 14:45:53 +0800 |
| Cc: | Chandra Seetharaman <sekharan@xxxxxxxxxx> |
| Delivered-to: | xfs@xxxxxxxxxxx |
This patch tries to fix CID 997009 reported by Coverity scan, as
suggested by sekharan
If getgroups() fails, gids might be malloced, and overwritten with &gid.
So the free() at the end of the function is trying to free a variable on
the stack, while the pointer to the allocated memory is lost.
Signed-off-by: Li Zhong <zhong@xxxxxxxxxxxxxxxxxx>
---
quota/quota.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/quota/quota.c b/quota/quota.c
index 7e52ad2..ae9b156 100644
--- a/quota/quota.c
+++ b/quota/quota.c
@@ -292,7 +292,8 @@ quota_group_type(
} else if ( ((ngroups = sysconf(_SC_NGROUPS_MAX)) < 0) ||
((gids = malloc(ngroups * sizeof(gid_t))) == NULL) ||
((ngroups = getgroups(ngroups, gids)) < 0)) {
- dofree = (gids != NULL);
+ if (gids)
+ free(gids);
gid = getgid();
gids = &gid;
ngroups = 1;
--
1.8.1.4
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | [PATCH] xfsprogs: fix potential memory leak in verify_set_primary_sb(), Li Zhong |
|---|---|
| Next by Date: | [PATCH] xfs: fix the wrong new_size/rnew_size at xfs_iext_realloc_direct(), Jeff Liu |
| Previous by Thread: | [PATCH] xfsprogs: fix potential memory leak in verify_set_primary_sb(), Li Zhong |
| Next by Thread: | Re: [PATCH] xfsprogs: fix potential memory free issues in quota_group_type(), Mark Tinguely |
| Indexes: | [Date] [Thread] [Top] [All Lists] |