fastboot: mmc: Fix dest size in strlcat()
PATCH 1/1 fastboot: mmc: Fix dest size in strlcat()
strlcat() is truncating the destination string to the size of the source string. Fix size argument in strlcat() to match the size of destination buffer.
Bug was introduced in the following commit:
commit 69a752983171c2983fc1f29c7cfa1844f41e5d8b
Author: Sean Anderson <[email protected]>
fastboot: Fix possible buffer overrun
--- drivers/fastboot/fb_mmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/fastboot/fb_mmc.c +2 -2
@@ -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,ARRAY_SIZE (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,ARRAY_SIZE (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,
Signature · 1 line
2.30.2
Quoted 31 lines · Ariel D'Alessandro
strlcat()is truncating the destination string to the size of the source string. Fix size argument instrlcat()to match the size of destination buffer.Bug was introduced in the following commit:
commit
69a752983171c2983fc1f29c7cfa1844f41e5d8b
Author: Sean Anderson <[email protected]>fastboot: Fix possible buffer overrun
Signed-off-by Ariel D'Alessandro <[email protected]>--- drivers/fastboot/fb_mmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/fastboot/fb_mmc.c +1
-1@@ -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,ARRAY_SIZE (env_desc_name)); raw_part_desc =strdup (env_get (env_desc_name));if (raw_part_desc ==NULL )return -ENODEV ;
drivers/fastboot/fb_mmc.c static int part_get_info_by_name_or_alias(struct blk_desc **dev_desc, · line 120
Quoted 8 lines
drivers/fastboot/fb_mmc.c +1
-1@@ -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,ARRAY_SIZE (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,
This looks like a duplicate of [1]. I think the only difference is ARRAY_SIZE vs sizeof, but they are equivalent since sizeof(char) == 1.
--Sean
[1] http://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
Hi Sean,
Quoted 37 lines · Sean Anderson
Quoted 33 lines · Ariel D'Alessandro
strlcat()is truncating the destination string to the size of the source string. Fix size argument instrlcat()to match the size of destination buffer.Bug was introduced in the following commit:
commit
69a752983171c2983fc1f29c7cfa1844f41e5d8b
Author: Sean Anderson <[email protected]>fastboot: Fix possible buffer overrun
Signed-off-by Ariel D'Alessandro <[email protected]>---
drivers/fastboot/fb_mmc.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/fastboot/fb_mmc.c +1
-1@@ -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, ARRAY_SIZE(env_desc_name)); raw_part_desc = strdup(env_get(env_desc_name)); if (raw_part_desc == NULL)return
-ENODEV;drivers/fastboot/fb_mmc.c +0
-0@@ -114,7 +114,7 @@ static int part_get_info_by_name_or_alias(struct blk_desc **dev_desc,
Quoted 11 lines
Quoted 8 lines
drivers/fastboot/fb_mmc.c +1
-1/* check for alias */ strcpy(env_alias_name, "fastboot_partition_alias_"); - strlcat(env_alias_name, name, PART_NAME_LEN); + strlcat(env_alias_name, name, ARRAY_SIZE(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,This looks like a duplicate of [1]. I think the only difference is
ARRAY_SIZEvs sizeof, but they are equivalent since sizeof(char) == 1.
Ah, you're right. Sorry I missed that patch.
Quoted 6 lines
--Sean
[1]
http://patchwork.ozlabs.org/project/uboot/patch/[email protected]/