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>
37 lines
1.2 KiB
Diff
37 lines
1.2 KiB
Diff
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
|
|
|