git » libfiu » commit 935ecf0

fiu-run: Avoid uninitialized memory on error in fiu_run_init()

author Peter van Dijk
2021-04-18 19:29:12 UTC
committer Alberto Bertogli
2021-04-19 20:38:25 UTC
parent ed9c81e06eecdf4d7105432ef45c847c824140f9

fiu-run: Avoid uninitialized memory on error in fiu_run_init()

In fiu_rc_string(), when a command is valid but returns an error (for
example, disabling a name that has not been enabled), no error message
is returned.

In turn, that causes an access to non-initialized memory in
fiu_run_init() when printing the error message.

This patches fixes the issue by always initializing the error message.

Amended-by: Alberto Bertogli <albertito@blitiri.com.ar>
  Edited commit message.

preload/run/run.c +1 -1

diff --git a/preload/run/run.c b/preload/run/run.c
index bce0739..51685fb 100644
--- a/preload/run/run.c
+++ b/preload/run/run.c
@@ -29,7 +29,7 @@ static void __attribute__((constructor)) fiu_run_init(void)
 		 * accordingly. */
 		char *tok, *state;
 		char *env_copy;
-		char *rc_error;
+		char *rc_error = "no error returned";
 
 		env_copy = strdup(fiu_enable_env);
 		if (env_copy == NULL) {