summaryrefslogtreecommitdiff
path: root/drivers/dfu/dfu_mtd.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <masami.hiramatsu@linaro.org>2022-01-31 11:52:29 +0900
committerTom Rini <trini@konsulko.com>2022-02-11 11:29:23 -0500
commit8db74c153b4e30edc5290da6c7330c63558678d0 (patch)
treee98f5ce256899d325e30abf32939a0d5ac8cc72c /drivers/dfu/dfu_mtd.c
parentd8ae90a8d47da2f22041bf9f6fd6d42a598f44ee (diff)
DFU: Accept redundant spaces and tabs in dfu_alt_info
If dfu_alt_info has repeated spaces or tab (for indentation or readability), the dfu fails to parse it. For example, if dfu_alt_info="mtd nor1=image raw 100000 200000" (double spaces after "raw"), the image entity start address is '0' and the size '0x100000'. This is because the repeated space is not skipped. Use space and tab as a separater and apply skip_spaces() to skip redundant spaces and tabs. Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
Diffstat (limited to 'drivers/dfu/dfu_mtd.c')
-rw-r--r--drivers/dfu/dfu_mtd.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c
index cce9ce0845e..27c011f5379 100644
--- a/drivers/dfu/dfu_mtd.c
+++ b/drivers/dfu/dfu_mtd.c
@@ -12,6 +12,7 @@
#include <mtd.h>
#include <jffs2/load_kernel.h>
#include <linux/err.h>
+#include <linux/ctype.h>
static bool mtd_is_aligned_with_block_size(struct mtd_info *mtd, u64 size)
{
@@ -285,11 +286,14 @@ int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char *s)
dfu->data.mtd.info = mtd;
dfu->max_buf_size = mtd->erasesize;
- st = strsep(&s, " ");
+ st = strsep(&s, " \t");
+ s = skip_spaces(s);
if (!strcmp(st, "raw")) {
dfu->layout = DFU_RAW_ADDR;
dfu->data.mtd.start = hextoul(s, &s);
- s++;
+ if (!isspace(*s))
+ return -1;
+ s = skip_spaces(s);
dfu->data.mtd.size = hextoul(s, &s);
} else if ((!strcmp(st, "part")) || (!strcmp(st, "partubi"))) {
char mtd_id[32];