forked from auracaster/openocd
flash/nor: improved API of flash_driver.info & fixed buffer overruns
1) The API of "info" callback in "struct flash_driver" has been improved. Fixed buffers for strings 2) Removed the calls to snprintf() from the flash_driver.info implementations. Many of them were used in an unsafe manner (buffer overruns were possible). Change-Id: I42ab8a8018d01f9af43c5ba49f650c3cb5d31dcb Signed-off-by: Jan Matyas <matyas@codasip.com> Reviewed-on: http://openocd.zylin.com/6182 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
committed by
Antonio Borneo
parent
f2958fc04b
commit
64c2e03b23
@@ -753,14 +753,14 @@ static int psoc5lp_nvl_write(struct flash_bank *bank,
|
||||
}
|
||||
|
||||
static int psoc5lp_nvl_get_info_command(struct flash_bank *bank,
|
||||
char *buf, int buf_size)
|
||||
struct command_invocation *cmd)
|
||||
{
|
||||
struct psoc5lp_nvl_flash_bank *psoc_nvl_bank = bank->driver_priv;
|
||||
char part_number[PART_NUMBER_LEN];
|
||||
|
||||
psoc5lp_get_part_number(psoc_nvl_bank->device, part_number);
|
||||
|
||||
snprintf(buf, buf_size, "%s", part_number);
|
||||
command_print_sameline(cmd, "%s", part_number);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -934,14 +934,14 @@ static int psoc5lp_eeprom_write(struct flash_bank *bank,
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int psoc5lp_eeprom_get_info_command(struct flash_bank *bank, char *buf, int buf_size)
|
||||
static int psoc5lp_eeprom_get_info_command(struct flash_bank *bank, struct command_invocation *cmd)
|
||||
{
|
||||
struct psoc5lp_eeprom_flash_bank *psoc_eeprom_bank = bank->driver_priv;
|
||||
char part_number[PART_NUMBER_LEN];
|
||||
|
||||
psoc5lp_get_part_number(psoc_eeprom_bank->device, part_number);
|
||||
|
||||
snprintf(buf, buf_size, "%s", part_number);
|
||||
command_print_sameline(cmd, "%s", part_number);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
@@ -1397,7 +1397,7 @@ static int psoc5lp_protect_check(struct flash_bank *bank)
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int psoc5lp_get_info_command(struct flash_bank *bank, char *buf, int buf_size)
|
||||
static int psoc5lp_get_info_command(struct flash_bank *bank, struct command_invocation *cmd)
|
||||
{
|
||||
struct psoc5lp_flash_bank *psoc_bank = bank->driver_priv;
|
||||
char part_number[PART_NUMBER_LEN];
|
||||
@@ -1406,7 +1406,7 @@ static int psoc5lp_get_info_command(struct flash_bank *bank, char *buf, int buf_
|
||||
psoc5lp_get_part_number(psoc_bank->device, part_number);
|
||||
ecc = psoc_bank->ecc_enabled ? "ECC enabled" : "ECC disabled";
|
||||
|
||||
snprintf(buf, buf_size, "%s %s", part_number, ecc);
|
||||
command_print_sameline(cmd, "%s %s", part_number, ecc);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user