diff mbox series

[V2] Fix usage of TMPDIR

Message ID 1505215260-21152-1-git-send-email-sbabic@denx.de
State Changes Requested
Headers show
Series [V2] Fix usage of TMPDIR | expand

Commit Message

Stefano Babic Sept. 12, 2017, 11:21 a.m. UTC
Commit 7ce284c5401c64bcd54e469ce8a3f7639e28ed3a makes TMPDIR
configurable. Fix the remaining sources that use the TMPDIR variable.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---

Changes since V1:
	- flash handler was not fixed

 corelib/lua_interface.c      | 1 +
 handlers/flash_handler.c     | 1 +
 handlers/lua_scripthandler.c | 7 +++++--
 3 files changed, 7 insertions(+), 2 deletions(-)

Comments

Storm, Christian Sept. 12, 2017, 11:50 a.m. UTC | #1
Hi Stefano,

> Commit 7ce284c5401c64bcd54e469ce8a3f7639e28ed3a makes TMPDIR
> configurable. Fix the remaining sources that use the TMPDIR variable.
> 
> Signed-off-by: Stefano Babic <sbabic@denx.de>
> ---
> 
> Changes since V1:
> 	- flash handler was not fixed
> 
>  corelib/lua_interface.c      | 1 +
>  handlers/flash_handler.c     | 1 +
>  handlers/lua_scripthandler.c | 7 +++++--
>  3 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
> index 90c2230..5717807 100644
> --- a/corelib/lua_interface.c
> +++ b/corelib/lua_interface.c
> @@ -401,6 +401,7 @@ static int l_handler_wrapper(struct img_type *img, void *data) {
>  	lua_Number result;
>  	int l_func_ref;
>  	int fdout;
> +	const char* TMPDIR = get_tmpdir();
>  
>  	if (!gL || !img || !data) {
>  		return -1;
> diff --git a/handlers/flash_handler.c b/handlers/flash_handler.c
> index 081c2a4..ff27aa7 100644
> --- a/handlers/flash_handler.c
> +++ b/handlers/flash_handler.c
> @@ -312,6 +312,7 @@ static int install_flash_image(struct img_type *img,
>  	char filename[64];
>  	int mtdnum;
>  	int n;
> +	const char* TMPDIR = get_tmpdir();
>  
>  	n = snprintf(filename, sizeof(filename), "%s%s", TMPDIR, img->fname);
>  	if (n < 0 || n >= sizeof(filename)) {
> diff --git a/handlers/lua_scripthandler.c b/handlers/lua_scripthandler.c
> index a3df317..1793878 100644
> --- a/handlers/lua_scripthandler.c
> +++ b/handlers/lua_scripthandler.c
> @@ -44,9 +44,11 @@ static int start_lua_script(struct img_type *img, void *data)
>  	int ret;
>  	const char *fnname;
>  	const char *output;
> -	char filename[64];
>  	script_fn scriptfn;
>  	lua_State *L = luaL_newstate(); /* opens Lua */
> +	const char* TMPDIR = get_tmpdir();
> +	char filename[MAX_IMAGE_FNAME + strlen(TMPDIR) +
> +		strlen(SCRIPTS_DIR_SUFFIX) + 2];
>  
>  	if (!data)
>  		return -1;
> @@ -65,7 +67,8 @@ static int start_lua_script(struct img_type *img, void *data)
>  		return 0;
>  	}
>  
> -	snprintf(filename, sizeof(filename), "%s%s", TMPDIR, img->fname);
> +	snprintf(filename, sizeof(filename),
> +		"%s%s%s", TMPDIR, SCRIPTS_DIR_SUFFIX, img->fname);
>  	TRACE("Calling Lua %s", filename);
>  
>  	luaL_openlibs(L); /* opens the standard libraries */
> -- 
> 2.7.4
> 

Thanks! It is obviously surprisingly hard to find all
those occurrences :)

Acked-by: Christian Storm <christian.storm@siemens.com>


Kind regards,
   Christian
diff mbox series

Patch

diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
index 90c2230..5717807 100644
--- a/corelib/lua_interface.c
+++ b/corelib/lua_interface.c
@@ -401,6 +401,7 @@  static int l_handler_wrapper(struct img_type *img, void *data) {
 	lua_Number result;
 	int l_func_ref;
 	int fdout;
+	const char* TMPDIR = get_tmpdir();
 
 	if (!gL || !img || !data) {
 		return -1;
diff --git a/handlers/flash_handler.c b/handlers/flash_handler.c
index 081c2a4..ff27aa7 100644
--- a/handlers/flash_handler.c
+++ b/handlers/flash_handler.c
@@ -312,6 +312,7 @@  static int install_flash_image(struct img_type *img,
 	char filename[64];
 	int mtdnum;
 	int n;
+	const char* TMPDIR = get_tmpdir();
 
 	n = snprintf(filename, sizeof(filename), "%s%s", TMPDIR, img->fname);
 	if (n < 0 || n >= sizeof(filename)) {
diff --git a/handlers/lua_scripthandler.c b/handlers/lua_scripthandler.c
index a3df317..1793878 100644
--- a/handlers/lua_scripthandler.c
+++ b/handlers/lua_scripthandler.c
@@ -44,9 +44,11 @@  static int start_lua_script(struct img_type *img, void *data)
 	int ret;
 	const char *fnname;
 	const char *output;
-	char filename[64];
 	script_fn scriptfn;
 	lua_State *L = luaL_newstate(); /* opens Lua */
+	const char* TMPDIR = get_tmpdir();
+	char filename[MAX_IMAGE_FNAME + strlen(TMPDIR) +
+		strlen(SCRIPTS_DIR_SUFFIX) + 2];
 
 	if (!data)
 		return -1;
@@ -65,7 +67,8 @@  static int start_lua_script(struct img_type *img, void *data)
 		return 0;
 	}
 
-	snprintf(filename, sizeof(filename), "%s%s", TMPDIR, img->fname);
+	snprintf(filename, sizeof(filename),
+		"%s%s%s", TMPDIR, SCRIPTS_DIR_SUFFIX, img->fname);
 	TRACE("Calling Lua %s", filename);
 
 	luaL_openlibs(L); /* opens the standard libraries */