Blame SOURCES/nfs-utils-2.5.4-rpcpipefs-warn.patch

ee8f10
commit 7f8463fe702174bd613df9d308cc899af25ae02e
ee8f10
Author: Steve Dickson <steved@redhat.com>
ee8f10
Date:   Wed Feb 23 15:19:51 2022 -0500
ee8f10
ee8f10
    systemd: Fix format-overflow warning
ee8f10
    
ee8f10
    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=]
ee8f10
       35 |         sprintf(path, "%s/%s", dirname, pipefs_unit);
ee8f10
          |                       ^
ee8f10
    
ee8f10
    Signed-off-by: Steve Dickson <steved@redhat.com>
ee8f10
ee8f10
diff --git a/systemd/rpc-pipefs-generator.c b/systemd/rpc-pipefs-generator.c
ee8f10
index c24db567..7b2bb4f7 100644
ee8f10
--- a/systemd/rpc-pipefs-generator.c
ee8f10
+++ b/systemd/rpc-pipefs-generator.c
ee8f10
@@ -28,11 +28,12 @@ static int generate_mount_unit(const char *pipefs_path, const char *pipefs_unit,
ee8f10
 {
ee8f10
 	char	*path;
ee8f10
 	FILE	*f;
ee8f10
+	size_t size = (strlen(dirname) + 1 + strlen(pipefs_unit) + 1);
ee8f10
 
ee8f10
-	path = malloc(strlen(dirname) + 1 + strlen(pipefs_unit));
ee8f10
+	path = malloc(size);
ee8f10
 	if (!path)
ee8f10
 		return 1;
ee8f10
-	sprintf(path, "%s/%s", dirname, pipefs_unit);
ee8f10
+	snprintf(path, size, "%s/%s", dirname, pipefs_unit);
ee8f10
 	f = fopen(path, "w");
ee8f10
 	if (!f)
ee8f10
 	{