Skip to contentSkip to conversation

tools/mkimage: Fix DTC run command to handle file names with space

PATCH In review Mirza 2 participants 2 messages Oct 4, 2017 – Oct 17, 2017

lore
Share & tools
lore

Mirza

#0 lore raw

PATCH 1/1 tools/mkimage: Fix DTC run command to handle file names with space

From: "Mirza, Taimoor" <[email protected]>

fit_handle_file function does not quote input and output files while preparing command to run DTC to convert .its to .itb. This results in a failure if input or output files contain spaces in their names. Quote input and output files in DTC command to avoid this failure.

---

 tools/fit_image.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/fit_image.c +2 -2
index 4dc8bd8..0f88c21 100644
@@ -648,11 +648,11 @@ static int fit_handle_file(struct image_tool_params *params)
 		*cmd = '\0';
 	} else if (params->datafile) {
 		/* dtc -I dts -O dtb -p 500 datafile > tmpfile */
-		snprintf(cmd, sizeof(cmd), "%s %s %s > %s",
+		snprintf(cmd, sizeof(cmd), "%s %s \"%s\" > \"%s\"",
 			 MKIMAGE_DTC, params->dtc, params->datafile, tmpfile);
 		debug("Trying to execute \"%s\"\n", cmd);
 	} else {
-		snprintf(cmd, sizeof(cmd), "cp %s %s",
+		snprintf(cmd, sizeof(cmd), "cp \"%s\" \"%s\"",
 			 params->imagefile, tmpfile);
 	}
 	if (*cmd && system(cmd) == -1) {
Signature · 1 line
1.9.1
#1 lore raw
Quoted 8 lines · Taimoor

From: "Mirza, Taimoor" <[email protected]>

fit_handle_file function does not quote input and output files while preparing command to run DTC to convert .its to .itb. This results in a failure if input or output files contain spaces in their names. Quote input and output files in DTC command to avoid this failure.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171016/d5bbc5a7/attachment.sig>