Skip to content

Commit a3547fd

Browse files
author
Oliver Kiddle
committed
54013: add a range check on signal numbers passed to trap
1 parent ebd51de commit a3547fd

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
2025-10-31 Oliver Kiddle <[email protected]>
22

3+
* 54013: Src/builtin.c, Src/jobs.c: add a range check on signal
4+
numbers passed to trap
5+
36
* 54012: Src/subst.c: fix use of out of scope array variable
47

58
* 54007: Src/exec.c, Src/hist.c, Src/init.c, Src/jobs.c, Src/module.c,

Src/builtin.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7428,6 +7428,14 @@ bin_trap(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
74287428
return 1;
74297429
}
74307430

7431+
if (!*argv) {
7432+
if (idigit(*arg) || !strncmp(arg, "SIG", 3))
7433+
zwarnnam(name, "undefined signal: %s", arg);
7434+
else
7435+
zwarnnam(name, "signal expected");
7436+
return 1;
7437+
}
7438+
74317439
/* set traps */
74327440
for (; *argv; argv++) {
74337441
Eprog t;

Src/jobs.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3054,7 +3054,11 @@ getsigidx(const char *s)
30543054

30553055
/* check for a signal specified by number */
30563056
x = atoi(s);
3057-
if (idigit(*s) && x >= 0)
3057+
if (idigit(*s) && x >= 0 && (x < VSIGCOUNT
3058+
#if defined(SIGRTMIN) && defined(SIGRTMAX)
3059+
|| (x >= SIGRTMIN && x <= SIGRTMAX)
3060+
#endif
3061+
))
30583062
return SIGIDX(x);
30593063

30603064
/* search for signal by name */

0 commit comments

Comments
 (0)