]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fastboot: fix partition name truncation in environment lookup
authorMatthias Schiffer <matthias.schiffer@ew.tq-group.com>
Fri, 30 Jul 2021 12:23:54 +0000 (14:23 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 12 Oct 2021 20:48:38 +0000 (16:48 -0400)
strlcat() need to be passed the full buffer length. The incorrect call
caused truncation of partition names for fastboot_raw_partition_... and
fastboot_partition_alias_... env lookup to much less than PART_NAME_LEN.

Fixes: 69a752983171 ("fastboot: Fix possible buffer overrun")
Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
drivers/fastboot/fb_mmc.c

index cbb3f7b1dea28c96992b3d5742362aff9bf113b4..2738dc836e1e94bfc98cf2c3e3b2a6cdb53f2c79 100644 (file)
@@ -40,7 +40,7 @@ static int raw_part_get_info_by_name(struct blk_desc *dev_desc,
 
        /* check for raw partition descriptor */
        strcpy(env_desc_name, "fastboot_raw_partition_");
-       strlcat(env_desc_name, name, PART_NAME_LEN);
+       strlcat(env_desc_name, name, sizeof(env_desc_name));
        raw_part_desc = strdup(env_get(env_desc_name));
        if (raw_part_desc == NULL)
                return -ENODEV;
@@ -114,7 +114,7 @@ static int part_get_info_by_name_or_alias(struct blk_desc **dev_desc,
 
                /* check for alias */
                strcpy(env_alias_name, "fastboot_partition_alias_");
-               strlcat(env_alias_name, name, PART_NAME_LEN);
+               strlcat(env_alias_name, name, sizeof(env_alias_name));
                aliased_part_name = env_get(env_alias_name);
                if (aliased_part_name != NULL)
                        ret = do_get_part_info(dev_desc, aliased_part_name,