diff mbox series

[1/2] tools/mkimage: fix handling long filenames

Message ID 20200427000839.26473-2-devel-sven@geroedel.de
State New
Headers show
Series mkimage: fix using long pathnames | expand

Commit Message

Sven Roederer April 27, 2020, 12:08 a.m. UTC
The cmdline for calling the dtc was cut-off when using long filenames (e.g.
245 bytes) for output-file and datafile of "-f" parameter.
For FIT-images cmd[MKIMAGE_MAX_DTC_CMDLINE_LEN] is declared (hardcoded 512 bytes),
and contains some static values, the path of a tmpfile and a datafile. tmpfile is
max MKIMAGE_MAX_TMPFILE_LEN (256) and datafile might be also this size. Having two
very long pathname results in a truncation os the executed shell command, as the
truncated datafile path will not be found.
Redefine MKIMAGE_MAX_DTC_CMDLINE_LEN to "2 * MKIMAGE_MAX_TMPFILE_LEN + 35 for the
parameters.
This likely applies to the "-d" parameter, too.

Signed-off-by: Sven Roederer <devel-sven at geroedel.de>
---
 tools/mkimage.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tom Rini May 1, 2020, 9:56 p.m. UTC | #1
On Mon, Apr 27, 2020 at 02:08:38AM +0200, Sven Roederer wrote:

> The cmdline for calling the dtc was cut-off when using long filenames (e.g.
> 245 bytes) for output-file and datafile of "-f" parameter.
> For FIT-images cmd[MKIMAGE_MAX_DTC_CMDLINE_LEN] is declared (hardcoded 512 bytes),
> and contains some static values, the path of a tmpfile and a datafile. tmpfile is
> max MKIMAGE_MAX_TMPFILE_LEN (256) and datafile might be also this size. Having two
> very long pathname results in a truncation os the executed shell command, as the
> truncated datafile path will not be found.
> Redefine MKIMAGE_MAX_DTC_CMDLINE_LEN to "2 * MKIMAGE_MAX_TMPFILE_LEN + 35 for the
> parameters.
> This likely applies to the "-d" parameter, too.
> 
> Signed-off-by: Sven Roederer <devel-sven at geroedel.de>

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

Patch

diff --git a/tools/mkimage.h b/tools/mkimage.h
index 0254af59fb..9de94dbe99 100644
--- a/tools/mkimage.h
+++ b/tools/mkimage.h
@@ -42,6 +42,7 @@  static inline ulong map_to_sysmem(void *ptr)
 #define MKIMAGE_TMPFILE_SUFFIX		".tmp"
 #define MKIMAGE_MAX_TMPFILE_LEN		256
 #define MKIMAGE_DEFAULT_DTC_OPTIONS	"-I dts -O dtb -p 500"
-#define MKIMAGE_MAX_DTC_CMDLINE_LEN	512
+#define MKIMAGE_MAX_DTC_CMDLINE_LEN	2 * MKIMAGE_MAX_TMPFILE_LEN + 35 
 /* 35 bytes for quotes, spaces, "-o", len(MKIMAGE_DEFAULT_DTC_OPTIONS), len(MKIMAGE_TMPFILE_SUFFIX) */
 
 #endif /* _MKIIMAGE_H_ */