dummyflasher.c: Replace atoi() with strtoul()
flashrom-stable: Squashed fixup
Change-Id: Ib9e66016a2f4ce2d13b833c261f900cab80916b7
Spotted-by: Angel Pons <th3fanbus@gmail.com>
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/54854
Original-Reviewed-by: Sam McNally <sammc@google.com>
Original-Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/71359
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/dummyflasher.c b/dummyflasher.c
index add7579..86f6968 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -165,6 +165,7 @@
#if EMULATE_CHIP
struct stat image_stat;
#endif
+ char *endptr;
struct emu_data *data = calloc(1, sizeof(struct emu_data));
if (!data) {
@@ -207,12 +208,13 @@
tmp = extract_programmer_param("spi_write_256_chunksize");
if (tmp) {
- spi_write_256_chunksize = atoi(tmp);
- free(tmp);
- if (spi_write_256_chunksize < 1) {
+ spi_write_256_chunksize = strtoul(tmp, &endptr, 0);
+ if (*endptr != '\0' || spi_write_256_chunksize < 1) {
msg_perr("invalid spi_write_256_chunksize\n");
+ free(tmp);
return 1;
}
+ free(tmp);
}
tmp = extract_programmer_param("spi_blacklist");
@@ -375,7 +377,6 @@
#ifdef EMULATE_SPI_CHIP
status = extract_programmer_param("spi_status");
if (status) {
- char *endptr;
errno = 0;
data->emu_status = strtoul(status, &endptr, 0);
free(status);