]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: (veritydev) use asprintf to build string
authorThomas Weißschuh <thomas@t-8ch.de>
Sun, 24 Dec 2023 11:50:02 +0000 (12:50 +0100)
committerThomas Weißschuh <thomas@t-8ch.de>
Sun, 31 Dec 2023 12:06:02 +0000 (13:06 +0100)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
libmount/src/hook_veritydev.c

index e4805a4e73b813f643622c2d8e9cd5ea252d36ae..6a9e64469a71443773dbd8dba45b0684ebaba325 100644 (file)
@@ -554,15 +554,10 @@ static int setup_veritydev(       struct libmnt_context *cxt,
        }
 
        if (!rc) {
-               hsd->devname = calloc(strlen(mapper_device)
-                                       + sizeof(_PATH_DEV_MAPPER) + 2, sizeof(char));
-               if (!hsd->devname)
+               if (asprintf(&hsd->devname, _PATH_DEV_MAPPER "/%s", mapper_device) == -1)
                        rc = -ENOMEM;
-               else {
-                       strcat(hsd->devname, _PATH_DEV_MAPPER "/");
-                       strcat(hsd->devname, mapper_device);
+               else
                        rc = mnt_fs_set_source(cxt->fs, hsd->devname);
-               }
        }
 
 done: