diff mbox series

[v2] tools: open FIT image read-only

Message ID rt336whqarwenm6q2pbla2x2yewfxwjpxuh2x6mmo5i7ynfopl@tarta.nabijaczleweli.xyz
State Accepted
Commit 32bc256ced33678d63147acb796aa1cbcc942baf
Delegated to: Tom Rini
Headers show
Series [v2] tools: open FIT image read-only | expand

Commit Message

Ahelenia Ziemiańska March 21, 2024, 6:31 p.m. UTC
Open for reading as O_RDONLY instead of O_RDWR:
the only usage of the fd is for the single read() below;
this prevented
	mkimage -f auto -A arm64 \
		-T kernel -C lz4 -d Image-6.6.15.lz4 \
		-b mt8173-elm-hana-6.6.15.dtb outf
when the inputs were unwritable.

Link: https://bugs.debian.org/1063097
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Reviewed-by: Dragan Simic <dsimic@manjaro.org>
---
 tools/fit_image.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dragan Simic April 4, 2024, 4:44 p.m. UTC | #1
Hello all,

Just a brief reminder about merging this patch.  It looks fine to me.


On 2024-03-21 19:31, Ahelenia Ziemiańska wrote:
> Open for reading as O_RDONLY instead of O_RDWR:
> the only usage of the fd is for the single read() below;
> this prevented
> 	mkimage -f auto -A arm64 \
> 		-T kernel -C lz4 -d Image-6.6.15.lz4 \
> 		-b mt8173-elm-hana-6.6.15.dtb outf
> when the inputs were unwritable.
> 
> Link: https://bugs.debian.org/1063097
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
> Reviewed-by: Dragan Simic <dsimic@manjaro.org>
> ---
>  tools/fit_image.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/fit_image.c b/tools/fit_image.c
> index beef1fa8..0fccfbb4 100644
> --- a/tools/fit_image.c
> +++ b/tools/fit_image.c
> @@ -137,7 +137,7 @@ static int fdt_property_file(struct
> image_tool_params *params,
>  	int ret;
>  	int fd;
> 
> -	fd = open(fname, O_RDWR | O_BINARY);
> +	fd = open(fname, O_RDONLY | O_BINARY);
>  	if (fd < 0) {
>  		fprintf(stderr, "%s: Can't open %s: %s\n",
>  			params->cmdname, fname, strerror(errno));
Tom Rini April 10, 2024, 5:43 p.m. UTC | #2
On Thu, 21 Mar 2024 19:31:54 +0100, Ahelenia Ziemiańska wrote:

> Open for reading as O_RDONLY instead of O_RDWR:
> the only usage of the fd is for the single read() below;
> this prevented
> 	mkimage -f auto -A arm64 \
> 		-T kernel -C lz4 -d Image-6.6.15.lz4 \
> 		-b mt8173-elm-hana-6.6.15.dtb outf
> when the inputs were unwritable.
> 
> [...]

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/tools/fit_image.c b/tools/fit_image.c
index beef1fa8..0fccfbb4 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -137,7 +137,7 @@  static int fdt_property_file(struct image_tool_params *params,
 	int ret;
 	int fd;
 
-	fd = open(fname, O_RDWR | O_BINARY);
+	fd = open(fname, O_RDONLY | O_BINARY);
 	if (fd < 0) {
 		fprintf(stderr, "%s: Can't open %s: %s\n",
 			params->cmdname, fname, strerror(errno));