]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: (dev) use strdup to duplicate string
authorThomas Weißschuh <thomas@t-8ch.de>
Sun, 24 Dec 2023 11:35:18 +0000 (12:35 +0100)
committerThomas Weißschuh <thomas@t-8ch.de>
Sun, 31 Dec 2023 12:04:23 +0000 (13:04 +0100)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
libblkid/src/dev.c

index c38ec3d3213445770a34fded2738a93090d75aa7..ca13f3970df6787f805830f1902d7b91e0b5ac28 100644 (file)
@@ -155,15 +155,13 @@ int blkid_dev_set_search(blkid_dev_iterate iter,
        if (!iter || iter->magic != DEV_ITERATE_MAGIC || !search_type ||
            !search_value)
                return -1;
-       new_type = malloc(strlen(search_type)+1);
-       new_value = malloc(strlen(search_value)+1);
+       new_type = strdup(search_type);
+       new_value = strdup(search_value);
        if (!new_type || !new_value) {
                free(new_type);
                free(new_value);
                return -1;
        }
-       strcpy(new_type, search_type);
-       strcpy(new_value, search_value);
        free(iter->search_type);
        free(iter->search_value);
        iter->search_type = new_type;