aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-09-05 16:12:39 +0100
committerRon Yorston <rmy@pobox.com>2021-09-05 16:12:39 +0100
commitf67224cb2f60288c731b94975e20bd922eaacf6c (patch)
tree61c6dfdde7c13483bc0294938e84cb2907efa556 /shell
parenta819ff097b754ec9ab0a6c8b64a43e0228369c7a (diff)
downloadbusybox-w32-f67224cb2f60288c731b94975e20bd922eaacf6c.tar.gz
busybox-w32-f67224cb2f60288c731b94975e20bd922eaacf6c.tar.bz2
busybox-w32-f67224cb2f60288c731b94975e20bd922eaacf6c.zip
ash: restrict valid job ids
Although job control is disabled in busybox-w32 getjob() is still compiled in because it's used by waitcmd(). Job ids of the form '%string' or '%?string' don't work, though, because the command isn't stored in the job structure. Disable the code to handle them. Job ids '%%', '%+', '%-' and '%num' are still allowed and some of them are (successfully) used in the ash tests. Saves 144 bytes.
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 279cc8ed4..ff2a54fbe 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -4411,12 +4411,16 @@ static struct job *
4411getjob(const char *name, int getctl) 4411getjob(const char *name, int getctl)
4412{ 4412{
4413 struct job *jp; 4413 struct job *jp;
4414#if !ENABLE_PLATFORM_MINGW32
4414 struct job *found; 4415 struct job *found;
4416#endif
4415 const char *err_msg = "%s: no such job"; 4417 const char *err_msg = "%s: no such job";
4416 unsigned num; 4418 unsigned num;
4417 int c; 4419 int c;
4418 const char *p; 4420 const char *p;
4421#if !ENABLE_PLATFORM_MINGW32
4419 char *(*match)(const char *, const char *); 4422 char *(*match)(const char *, const char *);
4423#endif
4420 4424
4421 jp = curjob; 4425 jp = curjob;
4422 p = name; 4426 p = name;
@@ -4457,6 +4461,7 @@ getjob(const char *name, int getctl)
4457 } 4461 }
4458 } 4462 }
4459 4463
4464#if !ENABLE_PLATFORM_MINGW32
4460 match = prefix; 4465 match = prefix;
4461 if (*p == '?') { 4466 if (*p == '?') {
4462 match = strstr; 4467 match = strstr;
@@ -4476,6 +4481,9 @@ getjob(const char *name, int getctl)
4476 if (!found) 4481 if (!found)
4477 goto err; 4482 goto err;
4478 jp = found; 4483 jp = found;
4484#else
4485 goto err;
4486#endif
4479 4487
4480 gotit: 4488 gotit:
4481#if JOBS 4489#if JOBS