s = env;
while (s) {
ret = -EINVAL;
- i = strsep(&s, " ");
+ i = strsep(&s, " \t");
if (!i)
break;
+ s = skip_spaces(s);
d = strsep(&s, "=");
if (!d)
break;
char *st;
debug("%s: %s interface: %s dev: %s\n", __func__, s, interface, devstr);
- st = strsep(&s, " ");
+ st = strsep(&s, " \t");
strlcpy(dfu->name, st, DFU_NAME_SIZE);
+ s = skip_spaces(s);
dfu->alt = alt;
dfu->max_buf_size = 0;
dfu->data.mmc.dev_num = dectoul(devstr, NULL);
for (; parg < argv + sizeof(argv) / sizeof(*argv); ++parg) {
- *parg = strsep(&s, " ");
+ *parg = strsep(&s, " \t");
if (*parg == NULL) {
pr_err("Invalid number of arguments.\n");
return -ENODEV;
}
+ s = skip_spaces(s);
}
entity_type = argv[0];
* specifying the mmc HW defined partition number
*/
if (s)
- if (!strcmp(strsep(&s, " "), "mmcpart"))
+ if (!strcmp(strsep(&s, " \t"), "mmcpart")) {
+ s = skip_spaces(s);
dfu->data.mmc.hw_partition =
simple_strtoul(s, NULL, 0);
+ }
} else if (!strcmp(entity_type, "part")) {
struct disk_partition partinfo;
* specifying the mmc HW defined partition number
*/
if (s)
- if (!strcmp(strsep(&s, " "), "offset"))
+ if (!strcmp(strsep(&s, " \t"), "offset")) {
+ s = skip_spaces(s);
offset = simple_strtoul(s, NULL, 0);
+ }
dfu->layout = DFU_RAW_ADDR;
dfu->data.mmc.lba_start = partinfo.start + offset;
#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)
{
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];
dfu->data.nand.ubi = 0;
dfu->dev_type = DFU_DEV_NAND;
- st = strsep(&s, " ");
+ st = strsep(&s, " \t");
+ s = skip_spaces(s);
if (!strcmp(st, "raw")) {
dfu->layout = DFU_RAW_ADDR;
dfu->data.nand.start = hextoul(s, &s);
- s++;
+ if (!isspace(*s))
+ return -1;
+ s = skip_spaces(s);
dfu->data.nand.size = hextoul(s, &s);
} else if ((!strcmp(st, "part")) || (!strcmp(st, "partubi"))) {
char mtd_id[32];
dfu->layout = DFU_RAW_ADDR;
dev = dectoul(s, &s);
- s++;
+ if (!isspace(*s))
+ return -1;
+ s = skip_spaces(s);
part = dectoul(s, &s);
sprintf(mtd_id, "%s%d,%d", "nand", dev, part - 1);
const char **parg = argv;
for (; parg < argv + sizeof(argv) / sizeof(*argv); ++parg) {
- *parg = strsep(&s, " ");
+ *parg = strsep(&s, " \t");
if (*parg == NULL) {
pr_err("Invalid number of arguments.\n");
return -ENODEV;
}
+ s = skip_spaces(s);
}
dfu->dev_type = DFU_DEV_RAM;
#include <spi_flash.h>
#include <jffs2/load_kernel.h>
#include <linux/mtd/mtd.h>
+#include <linux/ctype.h>
static int dfu_get_medium_size_sf(struct dfu_entity *dfu, u64 *size)
{
dfu->dev_type = DFU_DEV_SF;
dfu->max_buf_size = dfu->data.sf.dev->sector_size;
- st = strsep(&s, " ");
+ st = strsep(&s, " \t");
+ s = skip_spaces(s);
if (!strcmp(st, "raw")) {
dfu->layout = DFU_RAW_ADDR;
dfu->data.sf.start = hextoul(s, &s);
- s++;
+ if (!isspace(*s))
+ return -1;
+ s = skip_spaces(s);
dfu->data.sf.size = hextoul(s, &s);
} else if (CONFIG_IS_ENABLED(DFU_SF_PART) &&
(!strcmp(st, "part") || !strcmp(st, "partubi"))) {
dfu->layout = DFU_RAW_ADDR;
dev = dectoul(s, &s);
- s++;
+ if (!isspace(*s))
+ return -1;
+ s = skip_spaces(s);
part = dectoul(s, &s);
sprintf(mtd_id, "%s%d,%d", "nor", dev, part - 1);