From 9e4b0cfc2aec33234b93de48ba52cee304ba1991 Mon Sep 17 00:00:00 2001 From: wguanghao Date: Tue, 30 Jul 2024 16:40:38 +0800 Subject: [PATCH] common.c: fix strncat usage --- 0006-common.c-fix-strncat-usage.patch | 43 +++++++++++++++++++++++++++ quota.spec | 6 +++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 0006-common.c-fix-strncat-usage.patch diff --git a/0006-common.c-fix-strncat-usage.patch b/0006-common.c-fix-strncat-usage.patch new file mode 100644 index 0000000..1120b34 --- /dev/null +++ b/0006-common.c-fix-strncat-usage.patch @@ -0,0 +1,43 @@ +From b0f95e3954f85d97a99f8a08645418945484dbca Mon Sep 17 00:00:00 2001 +From: "Dmitry V. Levin" +Date: Wed, 1 Sep 2021 08:00:00 +0000 +Subject: [PATCH] common.c: fix strncat usage + +When quota is configured using --enable-werror, gcc -flto fails with +the following diagnostics: + +In function 'strncat', + inlined from 'sstrncat' at common.c:113:2, + inlined from 'get_proc_num' at quotastats.c:46:2: +/usr/include/bits/string_fortified.h:122:10: error: '__builtin___strncat_chk' specified bound 4096 equals destination size [-Werror=str +ingop-overflow=] + 122 | return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest)); + | ^ + +This diagnostics is correct: when "src" contains "len" or more bytes, +strncat() writes "len"+1 bytes to "dest" ("len" from "src" plus +the terminating null byte). + +Signed-off-by: Dmitry V. Levin +Signed-off-by: Jan Kara +--- + common.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/common.c b/common.c +index 8be0428..b3e5ad2 100644 +--- a/common.c ++++ b/common.c +@@ -110,8 +110,7 @@ void sstrncpy(char *d, const char *s, size_t len) + + void sstrncat(char *d, const char *s, size_t len) + { +- strncat(d, s, len); +- d[len - 1] = 0; ++ strncat(d, s, len - 1); + } + + char *sstrdup(const char *s) +-- +2.39.2 + diff --git a/quota.spec b/quota.spec index 166b2e5..831c2e5 100644 --- a/quota.spec +++ b/quota.spec @@ -1,7 +1,7 @@ Name: quota Version: 4.06 Epoch: 1 -Release: 7 +Release: 8 Summary: Linux Diskquota system as part of the Linux kernel License: BSD and GPLv2 and GPLv2+ and LGPLv2+ URL: http://sourceforge.net/projects/linuxquota/ @@ -18,6 +18,7 @@ Patch2: 0002-quotaio_xfs-Warn-when-large-kernel-timestamps-cannot.patch 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 BuildRequires: autoconf, automake, coreutils, rpcgen, systemd, gcc BuildRequires: e2fsprogs-devel, gettext-devel, openldap-devel @@ -126,6 +127,9 @@ make check %{_mandir}/man*/* %changelog +* Tue Jul 30 2024 wuguanghao - 1:4.06-8 +- common.c: fix strncat usage + * Tue Dec 6 2022 lihaoxiang - 1:4.06-7 - Type:bugfix - ID:NA