mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-30 00:21:06 +00:00
53b406369e
When parsing the dfu_alt_info, check the number of arguments and argument string strictly. If there is any garbage data (which is not able to be parsed correctly) in dfu_alt_info, that means something wrong and user may make a typo or mis- understanding about the syntax. Since the dfu_alt_info is used for updating the firmware, this mistake may lead to brick the hardware. Thus it should be checked strictly for making sure there is no mistake. Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
53 lines
1.1 KiB
C
53 lines
1.1 KiB
C
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
|
/*
|
|
* Copyright (C) 2019, STMicroelectronics - All Rights Reserved
|
|
*/
|
|
#include <common.h>
|
|
#include <dfu.h>
|
|
#include <errno.h>
|
|
#include <log.h>
|
|
#include <malloc.h>
|
|
|
|
int __weak dfu_write_medium_virt(struct dfu_entity *dfu, u64 offset,
|
|
void *buf, long *len)
|
|
{
|
|
debug("%s: off=0x%llx, len=0x%x\n", __func__, offset, (u32)*len);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int __weak dfu_get_medium_size_virt(struct dfu_entity *dfu, u64 *size)
|
|
{
|
|
*size = 0;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int __weak dfu_read_medium_virt(struct dfu_entity *dfu, u64 offset,
|
|
void *buf, long *len)
|
|
{
|
|
debug("%s: off=0x%llx, len=0x%x\n", __func__, offset, (u32)*len);
|
|
*len = 0;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int dfu_fill_entity_virt(struct dfu_entity *dfu, char *devstr, char **argv, int argc)
|
|
{
|
|
debug("%s: devstr = %s\n", __func__, devstr);
|
|
|
|
if (argc != 0)
|
|
return -EINVAL;
|
|
|
|
dfu->dev_type = DFU_DEV_VIRT;
|
|
dfu->layout = DFU_RAW_ADDR;
|
|
dfu->data.virt.dev_num = dectoul(devstr, NULL);
|
|
|
|
dfu->write_medium = dfu_write_medium_virt;
|
|
dfu->get_medium_size = dfu_get_medium_size_virt;
|
|
dfu->read_medium = dfu_read_medium_virt;
|
|
|
|
dfu->inited = 0;
|
|
|
|
return 0;
|
|
}
|