* [PATCH master 2/3] scripts: kwbimage: check return value of asprintf
2023-05-31 6:27 [PATCH master 1/3] ARM: rockchip: pine64-quartz64: add sdram-init.bin to .gitignore Ahmad Fatoum
@ 2023-05-31 6:27 ` Ahmad Fatoum
2023-05-31 6:27 ` [PATCH master 3/3] scripts: omap3-usb-loader: fix heap overflow Ahmad Fatoum
2023-05-31 7:28 ` [PATCH master 1/3] ARM: rockchip: pine64-quartz64: add sdram-init.bin to .gitignore Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2023-05-31 6:27 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
Some newer toolchains defines asprintf with a must_check attribute,
leading to warnings when compiling kwbimage. Let's handle OOM gracefully
to get rid of the warnings.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
scripts/kwbimage.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/scripts/kwbimage.c b/scripts/kwbimage.c
index f9d052752d79..370c54c983b5 100644
--- a/scripts/kwbimage.c
+++ b/scripts/kwbimage.c
@@ -1006,6 +1006,7 @@ static int image_create_config_parse_oneline(char *line,
char *configpath)
{
char *keyword, *saveptr;
+ int ret;
keyword = strtok_r(line, " ", &saveptr);
if (!strcmp(keyword, "VERSION")) {
@@ -1056,10 +1057,16 @@ static int image_create_config_parse_oneline(char *line,
int argi = 0;
el->type = IMAGE_CFG_BINARY;
- if (*value == '/')
+ if (*value == '/') {
el->binary.file = strdup(value);
- else
- asprintf(&el->binary.file, "%s/%s", configpath, value);
+ } else {
+ ret = asprintf(&el->binary.file, "%s/%s", configpath, value);
+ if (ret < 0) {
+ fprintf(stderr, "Cannot allocate memory\n");
+ return -1;
+ }
+ }
+
while (1) {
value = strtok_r(NULL, " ", &saveptr);
if (!value)
--
2.38.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH master 3/3] scripts: omap3-usb-loader: fix heap overflow
2023-05-31 6:27 [PATCH master 1/3] ARM: rockchip: pine64-quartz64: add sdram-init.bin to .gitignore Ahmad Fatoum
2023-05-31 6:27 ` [PATCH master 2/3] scripts: kwbimage: check return value of asprintf Ahmad Fatoum
@ 2023-05-31 6:27 ` Ahmad Fatoum
2023-05-31 7:28 ` [PATCH master 1/3] ARM: rockchip: pine64-quartz64: add sdram-init.bin to .gitignore Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2023-05-31 6:27 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
Newer GCC versions correctly warn that the buffer allocated by realloc
is too small. Correct the size.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
scripts/omap3-usb-loader.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/omap3-usb-loader.c b/scripts/omap3-usb-loader.c
index a8d626c32f23..31a03be8e7f4 100644
--- a/scripts/omap3-usb-loader.c
+++ b/scripts/omap3-usb-loader.c
@@ -784,7 +784,7 @@ int main(int argc, char *argv[])
file.addr = OMAP_BASE_ADDRESS;
/* commit the file object with the processor specified base address */
- args->files = realloc(args->files, filecount);
+ args->files = realloc(args->files, filecount * sizeof(*args->files));
args->numfiles = filecount;
args->files[filecount - 1] = malloc(sizeof (file));
memcpy(args->files[filecount - 1], &file, sizeof (file));
--
2.38.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH master 1/3] ARM: rockchip: pine64-quartz64: add sdram-init.bin to .gitignore
2023-05-31 6:27 [PATCH master 1/3] ARM: rockchip: pine64-quartz64: add sdram-init.bin to .gitignore Ahmad Fatoum
2023-05-31 6:27 ` [PATCH master 2/3] scripts: kwbimage: check return value of asprintf Ahmad Fatoum
2023-05-31 6:27 ` [PATCH master 3/3] scripts: omap3-usb-loader: fix heap overflow Ahmad Fatoum
@ 2023-05-31 7:28 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2023-05-31 7:28 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Wed, May 31, 2023 at 08:27:01AM +0200, Ahmad Fatoum wrote:
> Other boards already have sdram-init.bin in their .gitignore, so have
> quartz64 follow suit.
>
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---
> arch/arm/boards/pine64-quartz64/.gitignore | 1 +
> 1 file changed, 1 insertion(+)
> create mode 100644 arch/arm/boards/pine64-quartz64/.gitignore
Applied, thanks
Sascha
>
> diff --git a/arch/arm/boards/pine64-quartz64/.gitignore b/arch/arm/boards/pine64-quartz64/.gitignore
> new file mode 100644
> index 000000000000..f458f794b54c
> --- /dev/null
> +++ b/arch/arm/boards/pine64-quartz64/.gitignore
> @@ -0,0 +1 @@
> +sdram-init.bin
> --
> 2.38.5
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 4+ messages in thread