aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2020-06-20 12:13:43 +0100
committerRon Yorston <rmy@pobox.com>2020-06-20 12:13:43 +0100
commit1a322c80f98f932a729d2ef1615b942420e8d62e (patch)
tree876af28132a51e2790730b5d17cea026c256cab5
parent327445bbbd6afa8ff164717206ad7635873b4bcc (diff)
downloadbusybox-w32-1a322c80f98f932a729d2ef1615b942420e8d62e.tar.gz
busybox-w32-1a322c80f98f932a729d2ef1615b942420e8d62e.tar.bz2
busybox-w32-1a322c80f98f932a729d2ef1615b942420e8d62e.zip
ash: reduce forkshell block size for FS_SHELLEXEC
It isn't necessary to pass the alias table or line editing history to a forkshell shell that's handling FS_SHELLEXEC.
-rw-r--r--shell/ash.c71
1 files changed, 46 insertions, 25 deletions
diff --git a/shell/ash.c b/shell/ash.c
index d84eaec88..a3b881ed8 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -16054,18 +16054,19 @@ forkshell_size(struct forkshell *fs)
16054 ds = globals_var_size(ds, ash_ptr_to_globals_var); 16054 ds = globals_var_size(ds, ash_ptr_to_globals_var);
16055 ds = globals_misc_size(ds, ash_ptr_to_globals_misc); 16055 ds = globals_misc_size(ds, ash_ptr_to_globals_misc);
16056 ds = cmdtable_size(ds, cmdtable); 16056 ds = cmdtable_size(ds, cmdtable);
16057#if ENABLE_ASH_ALIAS
16058 ds = atab_size(ds, atab);
16059#endif
16060 16057
16061 ds.funcblocksize = calcsize(ds.funcblocksize, fs->n); 16058 ds.funcblocksize = calcsize(ds.funcblocksize, fs->n);
16062 ds = argv_size(ds, fs->argv); 16059 ds = argv_size(ds, fs->argv);
16063 16060
16061 if ((ENABLE_ASH_ALIAS || MAX_HISTORY) && fs->fpid != FS_SHELLEXEC) {
16062#if ENABLE_ASH_ALIAS
16063 ds = atab_size(ds, atab);
16064#endif
16064#if MAX_HISTORY 16065#if MAX_HISTORY
16065 if (line_input_state) { 16066 if (line_input_state)
16066 ds = history_size(ds, line_input_state); 16067 ds = history_size(ds, line_input_state);
16067 }
16068#endif 16068#endif
16069 }
16069 return ds; 16070 return ds;
16070} 16071}
16071 16072
@@ -16086,23 +16087,24 @@ forkshell_copy(struct forkshell *fs, struct forkshell *new)
16086 new->gmp, "gmp", NO_FREE, 16087 new->gmp, "gmp", NO_FREE,
16087 new->cmdtable, "cmdtable", NO_FREE); 16088 new->cmdtable, "cmdtable", NO_FREE);
16088 16089
16089#if ENABLE_ASH_ALIAS
16090 new->atab = atab_copy(atab);
16091 SAVE_PTR(new->atab, "atab", NO_FREE);
16092#endif
16093
16094 new->n = copynode(fs->n); 16090 new->n = copynode(fs->n);
16095 new->argv = argv_copy(fs->argv); 16091 new->argv = argv_copy(fs->argv);
16096 SAVE_PTR2( new->n, "n", NO_FREE, 16092 SAVE_PTR2( new->n, "n", NO_FREE,
16097 new->argv, "argv", NO_FREE); 16093 new->argv, "argv", NO_FREE);
16098 16094
16095 if ((ENABLE_ASH_ALIAS || MAX_HISTORY) && fs->fpid != FS_SHELLEXEC) {
16096#if ENABLE_ASH_ALIAS
16097 new->atab = atab_copy(atab);
16098 SAVE_PTR(new->atab, "atab", NO_FREE);
16099#endif
16099#if MAX_HISTORY 16100#if MAX_HISTORY
16100 if (line_input_state) { 16101 if (line_input_state) {
16101 new->history = history_copy(line_input_state); 16102 new->history = history_copy(line_input_state);
16102 SAVE_PTR(new->history, "history", NO_FREE); 16103 SAVE_PTR(new->history, "history", NO_FREE);
16103 new->cnt_history = line_input_state->cnt_history; 16104 new->cnt_history = line_input_state->cnt_history;
16104 } 16105 }
16105#endif 16106#endif
16107 }
16106} 16108}
16107 16109
16108#if FORKSHELL_DEBUG 16110#if FORKSHELL_DEBUG
@@ -16153,19 +16155,38 @@ forkshell_print(FILE *fp0, struct forkshell *fs, const char **notes)
16153 size_gvp = (int)((char *)fs->gmp-(char *)fs->gvp); 16155 size_gvp = (int)((char *)fs->gmp-(char *)fs->gvp);
16154 size_gmp = (int)((char *)fs->cmdtable-(char *)fs->gmp); 16156 size_gmp = (int)((char *)fs->cmdtable-(char *)fs->gmp);
16155#if ENABLE_ASH_ALIAS && MAX_HISTORY 16157#if ENABLE_ASH_ALIAS && MAX_HISTORY
16156 size_cmdtable = (int)((char *)fs->atab-(char *)fs->cmdtable); 16158 if (fs->atab) {
16157 if (fs->history) { 16159 size_cmdtable = (int)((char *)fs->atab-(char *)fs->cmdtable);
16158 size_atab = (int)((char *)fs->history-(char *)fs->atab); 16160 if (fs->history) {
16159 size_history = (int)(lfuncstring-(char *)fs->history); 16161 size_atab = (int)((char *)fs->history-(char *)fs->atab);
16162 size_history = (int)(lfuncstring-(char *)fs->history);
16163 }
16164 else {
16165 size_atab = (int)(lfuncstring-(char *)fs->atab);
16166 size_history = 0;
16167 }
16160 } 16168 }
16161 else { 16169 else {
16162 size_atab = (int)(lfuncstring-(char *)fs->atab); 16170 size_atab = 0;
16163 size_history = 0; 16171 if (fs->history) {
16172 size_cmdtable = (int)((char *)fs->history-(char *)fs->cmdtable);
16173 size_history = (int)(lfuncstring-(char *)fs->history);
16174 }
16175 else {
16176 size_cmdtable = (int)(lfuncstring-(char *)fs->cmdtable);
16177 size_history = 0;
16178 }
16164 } 16179 }
16165#elif ENABLE_ASH_ALIAS 16180#elif ENABLE_ASH_ALIAS
16166 size_cmdtable = (int)((char *)fs->atab-(char *)fs->cmdtable);
16167 size_atab = (int)(lfuncstring-(char *)fs->atab);
16168 size_history = 0; 16181 size_history = 0;
16182 if (fs->atab) {
16183 size_cmdtable = (int)((char *)fs->atab-(char *)fs->cmdtable);
16184 size_atab = (int)(lfuncstring-(char *)fs->atab);
16185 }
16186 else {
16187 size_cmdtable = (int)(lfuncstring-(char *)fs->cmdtable);
16188 size_atab = 0;
16189 }
16169#elif MAX_HISTORY 16190#elif MAX_HISTORY
16170 size_atab = 0; 16191 size_atab = 0;
16171 if (fs->history) { 16192 if (fs->history) {
@@ -16369,7 +16390,7 @@ forkshell_init(const char *idstr)
16369 *gmpp = fs->gmp; 16390 *gmpp = fs->gmp;
16370 cmdtable = fs->cmdtable; 16391 cmdtable = fs->cmdtable;
16371#if ENABLE_ASH_ALIAS 16392#if ENABLE_ASH_ALIAS
16372 atab = fs->atab; 16393 atab = fs->atab; /* will be NULL for FS_SHELLEXEC */
16373#endif 16394#endif
16374#if MAX_HISTORY 16395#if MAX_HISTORY
16375 if (fs->cnt_history) { 16396 if (fs->cnt_history) {