Angel Pons has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/39973 )
Change subject: libflashrom.c: Use correct type for sizeof
......................................................................
libflashrom.c: Use correct type for sizeof
As we want to allocate an array of `flashrom_board_info` structs, use
that type in sizeof. This did not cause problems as `board_info` was at
least as big as `flashrom_board_info`, but nothing guarantees it.
Change-Id: I66e875d54c9a7cc59898b072b052282b0b5cbb2f
Signed-off-by: Angel Pons <th3fanbus(a)gmail.com>
---
M libflashrom.c
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/73/39973/1
diff --git a/libflashrom.c b/libflashrom.c
index 0dec22e..ab7e364 100644
--- a/libflashrom.c
+++ b/libflashrom.c
@@ -182,7 +182,7 @@
++boards_known_size;
struct flashrom_board_info *supported_boards =
- malloc(boards_known_size * sizeof(*binfo));
+ malloc(boards_known_size * sizeof(struct flashrom_board_info));
if (supported_boards != NULL) {
for (; i < boards_known_size; ++i) {
--
To view, visit https://review.coreboot.org/c/flashrom/+/39973
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I66e875d54c9a7cc59898b072b052282b0b5cbb2f
Gerrit-Change-Number: 39973
Gerrit-PatchSet: 1
Gerrit-Owner: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-MessageType: newchange
Angel Pons has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/39975 )
Change subject: ft2232_spi.c: Improve handling of static buffer
......................................................................
ft2232_spi.c: Improve handling of static buffer
If `buf` became NULL because of an error, subsequent calls to the
`ft2232_spi_send_command` function with a smaller buffer size will
result in a null pointer dereference. Add an additional null check
before using `buf` to prevent that. Moreover, use `size_t` for the
`bufsize` and `oldbufsize` variables, as it's what `realloc` uses.
Change-Id: Idc4237ddca94c42ce2a930e6d00fd2d14e4f125c
Signed-off-by: Angel Pons <th3fanbus(a)gmail.com>
---
M ft2232_spi.c
1 file changed, 3 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/75/39975/1
diff --git a/ft2232_spi.c b/ft2232_spi.c
index 1a5b2fe..84aebb3 100644
--- a/ft2232_spi.c
+++ b/ft2232_spi.c
@@ -468,8 +468,8 @@
static unsigned char *buf = NULL;
/* failed is special. We use bitwise ops, but it is essentially bool. */
int i = 0, ret = 0, failed = 0;
- int bufsize;
- static int oldbufsize = 0;
+ size_t bufsize;
+ static size_t oldbufsize = 0;
if (writecnt > 65536 || readcnt > 65536)
return SPI_INVALID_LENGTH;
@@ -477,7 +477,7 @@
/* buf is not used for the response from the chip. */
bufsize = max(writecnt + 9, 260 + 9);
/* Never shrink. realloc() calls are expensive. */
- if (bufsize > oldbufsize) {
+ if (!buf || bufsize > oldbufsize) {
buf = realloc(buf, bufsize);
if (!buf) {
msg_perr("Out of memory!\n");
--
To view, visit https://review.coreboot.org/c/flashrom/+/39975
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Idc4237ddca94c42ce2a930e6d00fd2d14e4f125c
Gerrit-Change-Number: 39975
Gerrit-PatchSet: 1
Gerrit-Owner: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-MessageType: newchange
Angel Pons has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/39972 )
Change subject: cli_classic.c: Prevent memory leak
......................................................................
cli_classic.c: Prevent memory leak
If the `--flash-contents` switch is specified more than once, it will
result in a memory leak. Therefore, allow this option only once.
Change-Id: I530933c9a6431580fe4645396bb363939472a80a
Signed-off-by: Angel Pons <th3fanbus(a)gmail.com>
---
M cli_classic.c
1 file changed, 3 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/72/39972/1
diff --git a/cli_classic.c b/cli_classic.c
index 73cc417..967ff50 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -273,6 +273,9 @@
}
break;
case OPTION_FLASH_CONTENTS:
+ if (referencefile)
+ cli_classic_abort_usage("Error: --flash-contents specified more than once."
+ "Aborting.\n");
referencefile = strdup(optarg);
break;
case OPTION_FLASH_NAME:
--
To view, visit https://review.coreboot.org/c/flashrom/+/39972
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I530933c9a6431580fe4645396bb363939472a80a
Gerrit-Change-Number: 39972
Gerrit-PatchSet: 1
Gerrit-Owner: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-MessageType: newchange