aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-11-21 10:36:36 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-11-21 10:36:36 +0000
commit340299a8bc923f548e6889093b6665241f4f0aa8 (patch)
treee27e5fba77d7366161220d34bcfc5f8d9f532fdf
parentb8baf407aacc09167c4e9fa0db55fe323b15854e (diff)
downloadbusybox-w32-340299a8bc923f548e6889093b6665241f4f0aa8.tar.gz
busybox-w32-340299a8bc923f548e6889093b6665241f4f0aa8.tar.bz2
busybox-w32-340299a8bc923f548e6889093b6665241f4f0aa8.zip
ash: fix miscalculation of memory needed for eval tree
found by Timo Teras (timo.teras AT iki.fi)
-rw-r--r--shell/ash.c68
1 files changed, 35 insertions, 33 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 92aa5ecc0..f99c50933 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -536,6 +536,7 @@ static const char dolatstr[] ALIGN1 = {
536#define NHERE 24 536#define NHERE 24
537#define NXHERE 25 537#define NXHERE 25
538#define NNOT 26 538#define NNOT 26
539#define N_NUMBER 27
539 540
540union node; 541union node;
541 542
@@ -7546,43 +7547,44 @@ commandcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
7546 7547
7547/* ============ eval.c */ 7548/* ============ eval.c */
7548 7549
7549static int funcblocksize; /* size of structures in function */ 7550static int funcblocksize; /* size of structures in function */
7550static int funcstringsize; /* size of strings in node */ 7551static int funcstringsize; /* size of strings in node */
7551static void *funcblock; /* block to allocate function from */ 7552static void *funcblock; /* block to allocate function from */
7552static char *funcstring; /* block to allocate strings from */ 7553static char *funcstring; /* block to allocate strings from */
7553 7554
7554/* flags in argument to evaltree */ 7555/* flags in argument to evaltree */
7555#define EV_EXIT 01 /* exit after evaluating tree */ 7556#define EV_EXIT 01 /* exit after evaluating tree */
7556#define EV_TESTED 02 /* exit status is checked; ignore -e flag */ 7557#define EV_TESTED 02 /* exit status is checked; ignore -e flag */
7557#define EV_BACKCMD 04 /* command executing within back quotes */ 7558#define EV_BACKCMD 04 /* command executing within back quotes */
7558 7559
7559static const short nodesize[26] = { 7560static const short nodesize[N_NUMBER] = {
7560 SHELL_ALIGN(sizeof(struct ncmd)), 7561 [NCMD ] = SHELL_ALIGN(sizeof(struct ncmd)),
7561 SHELL_ALIGN(sizeof(struct npipe)), 7562 [NPIPE ] = SHELL_ALIGN(sizeof(struct npipe)),
7562 SHELL_ALIGN(sizeof(struct nredir)), 7563 [NREDIR ] = SHELL_ALIGN(sizeof(struct nredir)),
7563 SHELL_ALIGN(sizeof(struct nredir)), 7564 [NBACKGND ] = SHELL_ALIGN(sizeof(struct nredir)),
7564 SHELL_ALIGN(sizeof(struct nredir)), 7565 [NSUBSHELL] = SHELL_ALIGN(sizeof(struct nredir)),
7565 SHELL_ALIGN(sizeof(struct nbinary)), 7566 [NAND ] = SHELL_ALIGN(sizeof(struct nbinary)),
7566 SHELL_ALIGN(sizeof(struct nbinary)), 7567 [NOR ] = SHELL_ALIGN(sizeof(struct nbinary)),
7567 SHELL_ALIGN(sizeof(struct nbinary)), 7568 [NSEMI ] = SHELL_ALIGN(sizeof(struct nbinary)),
7568 SHELL_ALIGN(sizeof(struct nif)), 7569 [NIF ] = SHELL_ALIGN(sizeof(struct nif)),
7569 SHELL_ALIGN(sizeof(struct nbinary)), 7570 [NWHILE ] = SHELL_ALIGN(sizeof(struct nbinary)),
7570 SHELL_ALIGN(sizeof(struct nbinary)), 7571 [NUNTIL ] = SHELL_ALIGN(sizeof(struct nbinary)),
7571 SHELL_ALIGN(sizeof(struct nfor)), 7572 [NFOR ] = SHELL_ALIGN(sizeof(struct nfor)),
7572 SHELL_ALIGN(sizeof(struct ncase)), 7573 [NCASE ] = SHELL_ALIGN(sizeof(struct ncase)),
7573 SHELL_ALIGN(sizeof(struct nclist)), 7574 [NCLIST ] = SHELL_ALIGN(sizeof(struct nclist)),
7574 SHELL_ALIGN(sizeof(struct narg)), 7575 [NDEFUN ] = SHELL_ALIGN(sizeof(struct narg)),
7575 SHELL_ALIGN(sizeof(struct narg)), 7576 [NARG ] = SHELL_ALIGN(sizeof(struct narg)),
7576 SHELL_ALIGN(sizeof(struct nfile)), 7577 [NTO ] = SHELL_ALIGN(sizeof(struct nfile)),
7577 SHELL_ALIGN(sizeof(struct nfile)), 7578 [NTO2 ] = SHELL_ALIGN(sizeof(struct nfile)),
7578 SHELL_ALIGN(sizeof(struct nfile)), 7579 [NCLOBBER ] = SHELL_ALIGN(sizeof(struct nfile)),
7579 SHELL_ALIGN(sizeof(struct nfile)), 7580 [NFROM ] = SHELL_ALIGN(sizeof(struct nfile)),
7580 SHELL_ALIGN(sizeof(struct nfile)), 7581 [NFROMTO ] = SHELL_ALIGN(sizeof(struct nfile)),
7581 SHELL_ALIGN(sizeof(struct ndup)), 7582 [NAPPEND ] = SHELL_ALIGN(sizeof(struct nfile)),
7582 SHELL_ALIGN(sizeof(struct ndup)), 7583 [NTOFD ] = SHELL_ALIGN(sizeof(struct ndup)),
7583 SHELL_ALIGN(sizeof(struct nhere)), 7584 [NFROMFD ] = SHELL_ALIGN(sizeof(struct ndup)),
7584 SHELL_ALIGN(sizeof(struct nhere)), 7585 [NHERE ] = SHELL_ALIGN(sizeof(struct nhere)),
7585 SHELL_ALIGN(sizeof(struct nnot)), 7586 [NXHERE ] = SHELL_ALIGN(sizeof(struct nhere)),
7587 [NNOT ] = SHELL_ALIGN(sizeof(struct nnot)),
7586}; 7588};
7587 7589
7588static void calcsize(union node *n); 7590static void calcsize(union node *n);