From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2 4/5] fastboot: Fix possible buffer overrun
Date: Thu, 11 Mar 2021 00:15:44 -0500 [thread overview]
Message-ID: <20210311051545.1886333-5-seanga2@gmail.com> (raw)
In-Reply-To: <20210311051545.1886333-1-seanga2@gmail.com>
This fixes several uses of strn(cpy|cat) which did not terminate their
destinations properly.
Fixes de1728ce4c ("fastboot: Allow u-boot-style partitions")
Reported-by: Coverity Scan
Signed-off-by: Sean Anderson <seanga2@gmail.com>
---
Changes in v2:
- New
drivers/fastboot/fb_mmc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index 8e74e50e91..2f3837e559 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -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_");
- strncat(env_desc_name, name, PART_NAME_LEN);
+ strlcat(env_desc_name, name, PART_NAME_LEN);
raw_part_desc = strdup(env_get(env_desc_name));
if (raw_part_desc == NULL)
return -ENODEV;
@@ -61,7 +61,7 @@ static int raw_part_get_info_by_name(struct blk_desc *dev_desc,
info->start = simple_strtoul(argv[0], NULL, 0);
info->size = simple_strtoul(argv[1], NULL, 0);
info->blksz = dev_desc->blksz;
- strncpy((char *)info->name, name, PART_NAME_LEN);
+ strlcpy((char *)info->name, name, PART_NAME_LEN);
if (raw_part_desc) {
if (strcmp(strsep(&raw_part_desc, " "), "mmcpart") == 0) {
@@ -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_");
- strncat(env_alias_name, name, PART_NAME_LEN);
+ strlcat(env_alias_name, name, PART_NAME_LEN);
aliased_part_name = env_get(env_alias_name);
if (aliased_part_name != NULL)
ret = do_get_part_info(dev_desc, aliased_part_name,
--
2.30.1
next prev parent reply other threads:[~2021-03-11 5:15 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-11 5:15 [PATCH v2 0/5] string: strl(cat|cpy) Sean Anderson
2021-03-11 5:15 ` [PATCH v2 1/5] lib: string: Fix strlcpy return value Sean Anderson
2021-03-25 0:38 ` Simon Glass
2021-03-25 0:54 ` Sean Anderson
2021-03-25 2:40 ` Simon Glass
2021-03-25 0:53 ` Sean Anderson
2021-04-13 14:28 ` Tom Rini
2021-03-11 5:15 ` [PATCH v2 2/5] lib: string: Implement strlcat Sean Anderson
2021-03-25 0:38 ` Simon Glass
2021-04-13 14:28 ` Tom Rini
2021-03-11 5:15 ` [PATCH v2 3/5] test: Add test for strlcat Sean Anderson
2021-03-25 0:38 ` Simon Glass
2021-04-13 14:29 ` Tom Rini
2021-03-11 5:15 ` Sean Anderson [this message]
2021-04-13 14:29 ` [PATCH v2 4/5] fastboot: Fix possible buffer overrun Tom Rini
2021-03-11 5:15 ` [PATCH v2 5/5] checkpatch: Add warnings for using strn(cat|cpy) Sean Anderson
2021-03-25 0:38 ` Simon Glass
2021-04-13 14:29 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210311051545.1886333-5-seanga2@gmail.com \
--to=seanga2@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox