diff --git a/quota-4.01-Close-FILE-handles-on-error.patch b/quota-4.01-Close-FILE-handles-on-error.patch new file mode 100644 index 0000000..46e82af --- /dev/null +++ b/quota-4.01-Close-FILE-handles-on-error.patch @@ -0,0 +1,101 @@ +From d26e316c3ffd4658b25f14ea1c42384f251c96de Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Thu, 13 Jun 2013 16:11:30 +0200 +Subject: [PATCH] Close FILE handles on error + +Functions for reading quota specification in quotaops.c create new +temporary FILE stream handle, they close it on successful return, +but they forget to close it on unsuccessful return. That leads to +memory leaks. This patch ensures that the handle gets closed in all +cases. +--- + quotaops.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/quotaops.c b/quotaops.c +index 175a945..47ef9a7 100644 +--- a/quotaops.c ++++ b/quotaops.c +@@ -334,42 +334,49 @@ int readprivs(struct dquot *qlist, int infd) + + if (cnt != 7) { + errstr(_("Bad format:\n%s\n"), line); ++ fclose(fd); + return -1; + } + error = str2space(blocksstring, &blocks); + if (error) { + errstr(_("Bad block usage: %s: %s\n"), + blocksstring, error); ++ fclose(fd); + return -1; + } + error = str2space(bsoftstring, &bsoft); + if (error) { + errstr(_("Bad block soft limit: %s: %s\n"), + bsoftstring, error); ++ fclose(fd); + return -1; + } + error = str2space(bhardstring, &bhard); + if (error) { + errstr(_("Bad block hard limit: %s: %s\n"), + bhardstring, error); ++ fclose(fd); + return -1; + } + error = str2number(inodesstring, &inodes); + if (error) { + errstr(_("Bad inode usage: %s: %s\n"), + inodesstring, error); ++ fclose(fd); + return -1; + } + error = str2number(isoftstring, &isoft); + if (error) { + errstr(_("Bad inode soft limit: %s: %s\n"), + isoftstring, error); ++ fclose(fd); + return -1; + } + error = str2number(ihardstring, &ihard); + if (error) { + errstr(_("Bad inode hard limit: %s: %s\n"), + ihardstring, error); ++ fclose(fd); + return -1; + } + +@@ -478,6 +485,7 @@ int readindividualtimes(struct dquot *qlist, int infd) + if (cnt != 3) { + format_err: + errstr(_("bad format:\n%s\n"), line); ++ fclose(fd); + return -1; + } + if (!strcmp(btimestr, _("unset"))) +@@ -488,6 +496,7 @@ format_err: + if (str2timeunits(btime, bunits, &bseconds) < 0) { + units_err: + errstr(_("Bad time units. Units are 'second', 'minute', 'hour', and 'day'.\n")); ++ fclose(fd); + return -1; + } + bseconds += now; +@@ -576,11 +585,13 @@ int readtimes(struct quota_handle **handles, int infd) + cnt = sscanf(line, "%s %d %s %d %s", fsp, &btime, bunits, &itime, iunits); + if (cnt != 5) { + errstr(_("bad format:\n%s\n"), line); ++ fclose(fd); + return -1; + } + if (str2timeunits(btime, bunits, &bseconds) < 0 || + str2timeunits(itime, iunits, &iseconds) < 0) { + errstr(_("Bad time units. Units are 'second', 'minute', 'hour', and 'day'.\n")); ++ fclose(fd); + return -1; + } + for (i = 0; handles[i]; i++) { +-- +1.8.1.4 + diff --git a/quota.spec b/quota.spec index f65bea3..bc95628 100644 --- a/quota.spec +++ b/quota.spec @@ -5,7 +5,7 @@ Name: quota Summary: System administration tools for monitoring users' disk usage Epoch: 1 Version: 4.01 -Release: 8%{?dist} +Release: 9%{?dist} # quota_nld.c, quotaio_xfs.h: GPLv2 # bylabel.c copied from util-linux: GPLv2+ # svc_socket.c copied from glibc: LGPLv2+ @@ -55,6 +55,8 @@ Patch14: quota-4.01-Recognize-units-at-block-limits-by-edquota.patch Patch15: quota-4.01-Recognize-units-at-inode-limits-by-setquota.patch # In upstream after 4.01, SF#3600120 Patch16: quota-4.01-Recognize-units-at-inode-limits-by-edquota.patch +# Submited to upstream +Patch17: quota-4.01-Close-FILE-handles-on-error.patch %description @@ -144,6 +146,7 @@ Linux/UNIX environment. %patch14 -p1 -b .edquota_block_units %patch15 -p1 -b .setquota_inode_units %patch16 -p1 -b .edquota_inode_units +%patch17 -p1 -b .close_file_handles #fix typos/mistakes in localized documentation for pofile in $(find ./po/*.p*) @@ -242,6 +245,9 @@ install -p -m644 -D %{SOURCE2} \ %changelog +* Thu Jun 13 2013 Petr Pisar - 1:4.01-9 +- Close FILE handles on error too + * Wed Jun 12 2013 Petr Pisar - 1:4.01-8 - Allow to set limits using multiplicative units