[U-Boot] [PATCH 1/2] fastboot: getvar_partition_{type, size}: Sanitize arguments
Eugeniu Rosca
erosca at de.adit-jv.com
Tue Mar 19 22:57:05 UTC 2019
Correct usage of "fastboot getvar_partition_{type,size}" is:
host $> fastboot getvar partition-size:misc
partition-size:misc: 0x0000000000000400
Finished. Total time: 0.214s
When the partition name is omitted, current behavior is:
host $> fastboot getvar partition-size
getvar:partition-size FAILED (remote: partition not found)
finished. total time: 0.005s
host $> fastboot getvar partition-size:
getvar:partition-size: FAILED (remote: partition not found)
finished. total time: 0.006s
host $> fastboot getvar partition-type
getvar:partition-type FAILED (remote: partition not found)
finished. total time: 0.005s
host $> fastboot getvar partition-type:
getvar:partition-type: FAILED (remote: partition not found)
finished. total time: 0.006s
Tell the user the real cause of command failure:
host $> fastboot getvar partition-size
getvar:partition-size FAILED (remote: missing partition name)
Finished. Total time: 0.003s
host $> fastboot getvar partition-size:
getvar:partition-size: FAILED (remote: missing partition name)
Finished. Total time: 0.003s
host $> fastboot getvar partition-type
getvar:partition-type FAILED (remote: missing partition name)
Finished. Total time: 0.003s
host $> fastboot getvar partition-type:
getvar:partition-type: FAILED (remote: missing partition name)
Finished. Total time: 0.003s
Fixes: f73a7df984a9 ("net: fastboot: Merge AOSP UDP fastboot")
Signed-off-by: Eugeniu Rosca <erosca at de.adit-jv.com>
---
drivers/fastboot/fb_getvar.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/fastboot/fb_getvar.c b/drivers/fastboot/fb_getvar.c
index 4d264c985d7e..28e3e2fa1619 100644
--- a/drivers/fastboot/fb_getvar.c
+++ b/drivers/fastboot/fb_getvar.c
@@ -144,6 +144,11 @@ static void getvar_partition_type(char *part_name, char *response)
struct blk_desc *dev_desc;
disk_partition_t part_info;
+ if (!part_name || !strcmp(part_name, "")) {
+ fastboot_fail("missing partition name", response);
+ return;
+ }
+
r = fastboot_mmc_get_part_info(part_name, &dev_desc, &part_info,
response);
if (r >= 0) {
@@ -162,6 +167,11 @@ static void getvar_partition_size(char *part_name, char *response)
int r;
size_t size;
+ if (!part_name || !strcmp(part_name, "")) {
+ fastboot_fail("missing partition name", response);
+ return;
+ }
+
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
struct blk_desc *dev_desc;
disk_partition_t part_info;
--
2.21.0
More information about the U-Boot
mailing list