common.c: fix strncat usage
This commit is contained in:
parent
35f9c43662
commit
9e4b0cfc2a
43
0006-common.c-fix-strncat-usage.patch
Normal file
43
0006-common.c-fix-strncat-usage.patch
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
From b0f95e3954f85d97a99f8a08645418945484dbca Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Dmitry V. Levin" <ldv@altlinux.org>
|
||||||
|
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 <ldv@altlinux.org>
|
||||||
|
Signed-off-by: Jan Kara <jack@suse.cz>
|
||||||
|
---
|
||||||
|
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
|
||||||
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
Name: quota
|
Name: quota
|
||||||
Version: 4.06
|
Version: 4.06
|
||||||
Epoch: 1
|
Epoch: 1
|
||||||
Release: 7
|
Release: 8
|
||||||
Summary: Linux Diskquota system as part of the Linux kernel
|
Summary: Linux Diskquota system as part of the Linux kernel
|
||||||
License: BSD and GPLv2 and GPLv2+ and LGPLv2+
|
License: BSD and GPLv2 and GPLv2+ and LGPLv2+
|
||||||
URL: http://sourceforge.net/projects/linuxquota/
|
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
|
Patch3: 0003-quota-Add-sw64-architecture.patch
|
||||||
Patch4: 0004-quota_nld-Initialize-sa_mask-when-registering-PID-fi.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
|
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: autoconf, automake, coreutils, rpcgen, systemd, gcc
|
||||||
BuildRequires: e2fsprogs-devel, gettext-devel, openldap-devel
|
BuildRequires: e2fsprogs-devel, gettext-devel, openldap-devel
|
||||||
@ -126,6 +127,9 @@ make check
|
|||||||
%{_mandir}/man*/*
|
%{_mandir}/man*/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Jul 30 2024 wuguanghao <wuguanghao3@huawei.com> - 1:4.06-8
|
||||||
|
- common.c: fix strncat usage
|
||||||
|
|
||||||
* Tue Dec 6 2022 lihaoxiang <lihaoxiang9@huawei.com> - 1:4.06-7
|
* Tue Dec 6 2022 lihaoxiang <lihaoxiang9@huawei.com> - 1:4.06-7
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user