summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2015-01-05 15:59:45 +0100
committerJan Kara <jack@suse.cz>2015-01-05 15:59:45 +0100
commit33160239630e668413bcb915490f604f2870309a (patch)
tree7ade0ed421de876727e8cd68656a5a727dbcc87c
parentade969d2640e1752444060da34e47b2fce5bfda2 (diff)
edquota: Fix error handling
Error handling didn't properly free quota structures allocated for a user when editing of limits failed for some reason. We also didn't bail out when editing of grace times failed. Fix the problems by jumping to a proper label. Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--edquota.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/edquota.c b/edquota.c
index 019eb19..81ec5e4 100644
--- a/edquota.c
+++ b/edquota.c
@@ -280,10 +280,12 @@ int main(int argc, char **argv)
if (writetimes(handles, tmpfd) < 0) {
errstr(_("Cannot write grace times to file.\n"));
ret = -1;
+ goto out;
}
if (editprivs(tmpfil) < 0) {
errstr(_("Error while editing grace times.\n"));
ret = -1;
+ goto out;
}
close(tmpfd);
/*
@@ -296,6 +298,7 @@ int main(int argc, char **argv)
if (readtimes(handles, tmpfd) < 0) {
errstr(_("Failed to parse grace times file.\n"));
ret = -1;
+ goto out;
}
}
else {
@@ -308,19 +311,19 @@ int main(int argc, char **argv)
if (writeindividualtimes(curprivs, tmpfd, *argv, quotatype) < 0) {
errstr(_("Cannot write individual grace times to file.\n"));
ret = -1;
- continue;
+ goto next_user;
}
} else {
if (writeprivs(curprivs, tmpfd, *argv, quotatype) < 0) {
errstr(_("Cannot write quotas to file.\n"));
ret = -1;
- continue;
+ goto next_user;
}
}
if (editprivs(tmpfil) < 0) {
errstr(_("Error while editing quotas.\n"));
ret = -1;
- continue;
+ goto next_user;
}
close(tmpfd);
/*
@@ -334,17 +337,18 @@ int main(int argc, char **argv)
if (readindividualtimes(curprivs, tmpfd) < 0) {
errstr(_("Cannot read individual grace times from file.\n"));
ret = -1;
- continue;
+ goto next_user;
}
} else {
if (readprivs(curprivs, tmpfd) < 0) {
errstr(_("Cannot read quotas from file.\n"));
ret = -1;
- continue;
+ goto next_user;
}
}
if (putprivs(curprivs, COMMIT_LIMITS) == -1)
ret = -1;
+next_user:
freeprivs(curprivs);
}
}