|
|
5eda098 |
From 7942290a0a6230fcc56eae42bf436e6eeca88777 Mon Sep 17 00:00:00 2001
|
|
|
5eda098 |
From: Jan Kara <jack@suse.cz>
|
|
|
5eda098 |
Date: Fri, 24 May 2019 12:25:15 +0200
|
|
|
5eda098 |
Subject: [PATCH 3/4] quotaops: Do not leak dquot structures on failure
|
|
|
5eda098 |
MIME-Version: 1.0
|
|
|
5eda098 |
Content-Type: text/plain; charset=UTF-8
|
|
|
5eda098 |
Content-Transfer-Encoding: 8bit
|
|
|
5eda098 |
|
|
|
5eda098 |
Some error paths in getprivs() were not properly freeing already fetched
|
|
|
5eda098 |
structures. Free them properly in case of error.
|
|
|
5eda098 |
|
|
|
5eda098 |
Signed-off-by: Jan Kara <jack@suse.cz>
|
|
|
5eda098 |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
5eda098 |
---
|
|
|
5eda098 |
quotaops.c | 9 +++++----
|
|
|
5eda098 |
1 file changed, 5 insertions(+), 4 deletions(-)
|
|
|
5eda098 |
|
|
|
5eda098 |
diff --git a/quotaops.c b/quotaops.c
|
|
|
5eda098 |
index 3d65490..e067d29 100644
|
|
|
5eda098 |
--- a/quotaops.c
|
|
|
5eda098 |
+++ b/quotaops.c
|
|
|
5eda098 |
@@ -80,7 +80,7 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles, int ignore_noquo
|
|
|
5eda098 |
if (euid != id && euid != 0) {
|
|
|
5eda098 |
uid2user(id, name);
|
|
|
5eda098 |
errstr(_("%s (uid %d): Permission denied\n"), name, id);
|
|
|
5eda098 |
- return (struct dquot *)NULL;
|
|
|
5eda098 |
+ goto out_err;
|
|
|
5eda098 |
}
|
|
|
5eda098 |
break;
|
|
|
5eda098 |
case GRPQUOTA:
|
|
|
5eda098 |
@@ -92,7 +92,7 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles, int ignore_noquo
|
|
|
5eda098 |
if (!gidsetp) {
|
|
|
5eda098 |
gid2group(id, name);
|
|
|
5eda098 |
errstr(_("%s (gid %d): gid set allocation (%d): %s\n"), name, id, ngroups, strerror(errno));
|
|
|
5eda098 |
- return (struct dquot *)NULL;
|
|
|
5eda098 |
+ goto out_err;
|
|
|
5eda098 |
}
|
|
|
5eda098 |
}
|
|
|
5eda098 |
else
|
|
|
5eda098 |
@@ -103,7 +103,7 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles, int ignore_noquo
|
|
|
5eda098 |
free(gidsetp);
|
|
|
5eda098 |
gid2group(id, name);
|
|
|
5eda098 |
errstr(_("%s (gid %d): error while trying getgroups(): %s\n"), name, id, strerror(errno));
|
|
|
5eda098 |
- return (struct dquot *)NULL;
|
|
|
5eda098 |
+ goto out_err;
|
|
|
5eda098 |
}
|
|
|
5eda098 |
|
|
|
5eda098 |
for (j = 0; j < ngroups; j++)
|
|
|
5eda098 |
@@ -115,7 +115,7 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles, int ignore_noquo
|
|
|
5eda098 |
gid2group(id, name);
|
|
|
5eda098 |
errstr(_("%s (gid %d): Permission denied\n"),
|
|
|
5eda098 |
name, id);
|
|
|
5eda098 |
- return (struct dquot *)NULL;
|
|
|
5eda098 |
+ goto out_err;
|
|
|
5eda098 |
}
|
|
|
5eda098 |
break;
|
|
|
5eda098 |
default:
|
|
|
5eda098 |
@@ -134,6 +134,7 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles, int ignore_noquo
|
|
|
5eda098 |
id2name(id, handles[i]->qh_type, name);
|
|
|
5eda098 |
errstr(_("error while getting quota from %s for %s (id %u): %s\n"),
|
|
|
5eda098 |
handles[i]->qh_quotadev, name, id, strerror(olderrno));
|
|
|
5eda098 |
+out_err:
|
|
|
5eda098 |
freeprivs(qhead);
|
|
|
5eda098 |
return NULL;
|
|
|
5eda098 |
}
|
|
|
5eda098 |
--
|
|
|
5eda098 |
2.20.1
|
|
|
5eda098 |
|