From f1c2fe4abfa9666de3f1bb9f4479dbfbbb12d7e8 Mon Sep 17 00:00:00 2001 From: lvyy Date: Mon, 14 Oct 2024 02:27:44 +0000 Subject: [PATCH] Use realloc(3) instead of reallocarray(3) (cherry picked from commit aef8e9b5b0b847698635485db426b3fccd11eb25) --- ...-realloc-3-instead-of-reallocarray-3.patch | 32 +++++++++++++++++++ quota.spec | 6 +++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 0007-quota-Use-realloc-3-instead-of-reallocarray-3.patch diff --git a/0007-quota-Use-realloc-3-instead-of-reallocarray-3.patch b/0007-quota-Use-realloc-3-instead-of-reallocarray-3.patch new file mode 100644 index 0000000..48f4746 --- /dev/null +++ b/0007-quota-Use-realloc-3-instead-of-reallocarray-3.patch @@ -0,0 +1,32 @@ +From 02b222a335527f1031cc9495d8c5ebc1bc5b1d4e Mon Sep 17 00:00:00 2001 +From: Fabrice Fontaine +Date: Wed, 11 Nov 2020 15:00:47 +0100 +Subject: [PATCH] quota: Use realloc(3) instead of reallocarray(3) + +reallocarray(3) has been added to glibc relatively recently (version +2.26, from 2017) and apparently not all users run new enough glibc. Just +use realloc(3) for now since in this case there's no real risk of +overflow. + +Signed-off-by: Fabrice Fontaine +Signed-off-by: Jan Kara +--- + quota.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/quota.c b/quota.c +index a6ed61f..a60de12 100644 +--- a/quota.c ++++ b/quota.c +@@ -385,7 +385,7 @@ int main(int argc, char **argv) + break; + case 259: + fscount++; +- fsnames = reallocarray(fsnames, fscount, sizeof(char *)); ++ fsnames = realloc(fsnames, fscount * sizeof(char *)); + if (!fsnames) + die(1, _("Not enough memory for filesystem names")); + fsnames[fscount - 1] = optarg; +-- +2.33.0 + diff --git a/quota.spec b/quota.spec index 831c2e5..90e07d9 100644 --- a/quota.spec +++ b/quota.spec @@ -1,7 +1,7 @@ Name: quota Version: 4.06 Epoch: 1 -Release: 8 +Release: 9 Summary: Linux Diskquota system as part of the Linux kernel License: BSD and GPLv2 and GPLv2+ and LGPLv2+ URL: http://sourceforge.net/projects/linuxquota/ @@ -19,6 +19,7 @@ Patch3: 0003-quota-Add-sw64-architecture.patch Patch4: 0004-quota_nld-Initialize-sa_mask-when-registering-PID-fi.patch Patch5: 0005-quota-nld-fix-open-PID-file-failed-when-systemd-read.patch Patch6: 0006-common.c-fix-strncat-usage.patch +Patch7: 0007-quota-Use-realloc-3-instead-of-reallocarray-3.patch BuildRequires: autoconf, automake, coreutils, rpcgen, systemd, gcc BuildRequires: e2fsprogs-devel, gettext-devel, openldap-devel @@ -127,6 +128,9 @@ make check %{_mandir}/man*/* %changelog +* Mon Oct 14 2024 lvyy - 1:4.06-9 +- DESC:Use realloc(3) instead of reallocarray(3) + * Tue Jul 30 2024 wuguanghao - 1:4.06-8 - common.c: fix strncat usage