Fix format-overflow warning

rpc-pipefs-generator.c:35  sprintf: '%s' directive output between 0 and 2147483653 bytes
may exceed minimum required size of 4095 [-Werror=format-overflow=]

Signed-off-by: xueyamao <xueyamao@kylinos.cn>
This commit is contained in:
xueyamao 2022-08-12 10:41:17 +08:00
parent 86ecc22b84
commit 17517501c0
2 changed files with 41 additions and 2 deletions

View File

@ -0,0 +1,36 @@
From 7f8463fe702174bd613df9d308cc899af25ae02e Mon Sep 17 00:00:00 2001
From: Steve Dickson <steved@redhat.com>
Date: Thu, 11 Aug 2022 11:15:15 +0800
Subject: [PATCH] Fix format-overflow warning
rpc-pipefs-generator.c:35:23: error: '%s' directive output between 0 and 2147483653 bytes may exceed minimum required size of 4095 [-Werror=format-overflow=]
35 | sprintf(path, "%s/%s", dirname, pipefs_unit);
| ^
Signed-off-by: Steve Dickson <steved@redhat.com>
---
systemd/rpc-pipefs-generator.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/systemd/rpc-pipefs-generator.c b/systemd/rpc-pipefs-generator.c
index 8e218aa..801975c 100644
--- a/systemd/rpc-pipefs-generator.c
+++ b/systemd/rpc-pipefs-generator.c
@@ -28,11 +28,11 @@ static int generate_mount_unit(const char *pipefs_path, const char *pipefs_unit,
{
char *path;
FILE *f;
-
- path = malloc(strlen(dirname) + 1 + strlen(pipefs_unit));
+ size_t size = (strlen(dirname) + 1 + strlen(pipefs_unit));
+ path = malloc(size);
if (!path)
return 1;
- sprintf(path, "%s/%s", dirname, pipefs_unit);
+ snprintf(path, size, "%s/%s", dirname, pipefs_unit);
f = fopen(path, "w");
if (!f)
{
--
2.33.0

View File

@ -4,7 +4,7 @@
Name: nfs-utils
Version: 2.5.4
Release: 6
Release: 7
Epoch: 2
Summary: The Linux NFS userland utility package
License: MIT and GPLv2 and GPLv2+ and BSD
@ -17,7 +17,7 @@ Patch1: 0001-correct-the-statd-path-in-man.patch
Patch2: 0002-nfs-utils-set-use-gss-proxy-1-to-enable-gss-proxy-by.patch
Patch3: 0003-idmapd-Fix-error-status-when-nfs-idmapd-exits.patch
Patch4: 0004-fix-coredump-in-bl_add_disk.patch
Patch5: 0005-Fix-format-overflow-warning.patch
BuildRequires: libevent-devel,libcap-devel, libtirpc-devel libblkid-devel
BuildRequires: krb5-libs >= 1.4 autoconf >= 2.57 openldap-devel >= 2.2
BuildRequires: automake, libtool, gcc, device-mapper-devel
@ -228,6 +228,9 @@ fi
%{_mandir}/*/*
%changelog
* Thu Aug 11 2022 xueyamao <xueyamao@ktlinos.cn> - 2:2.5.4-7
- systemd: Fix format-overflow warning.
* Sat Apr 16 2022 Wu Bo <wubo40@huawei.com> - 2.5.4-6
- Update epoch version to 2. In order to fix the upgrade issues.