← Commit list

749575d3c

Denys Vlasenko
Denys Vlasenko
2018-01-30
SUCCESS Duration: 142s

Subject

hush: protect against self-modifying trap code

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/hush.c+3 -1
@@ -2004,10 +2004,12 @@ static int check_and_run_traps(void)
smalluint save_rcode;
char *argv[3];
/* argv[0] is unused */
- argv[1] = G_traps[sig];
+ argv[1] = xstrdup(G_traps[sig]);
+ /* why strdup? trap can modify itself: trap 'trap "echo oops" INT' INT */
argv[2] = NULL;
save_rcode = G.last_exitcode;
builtin_eval(argv);
+ free(argv[1]);
//FIXME: shouldn't it be set to 128 + sig instead?
G.last_exitcode = save_rcode;
last_sig = sig;