aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2020-01-14 15:42:58 +0000
committerRon Yorston <rmy@pobox.com>2020-01-14 15:42:58 +0000
commit2ffcb860ea478d4b8d553fe59af5982c5939f7fa (patch)
tree1486f35991e3c01848f589115876f158049abe9a
parentcf0fa4d1392b7dc7eb8d37206c111f76af67e0e9 (diff)
downloadbusybox-w32-2ffcb860ea478d4b8d553fe59af5982c5939f7fa.tar.gz
busybox-w32-2ffcb860ea478d4b8d553fe59af5982c5939f7fa.tar.bz2
busybox-w32-2ffcb860ea478d4b8d553fe59af5982c5939f7fa.zip
ash: minor fixes to forkshell handling
Ensure that tblentry structures are properly aligned. The cmdname array has a size of one but the code doesn't allow for this in case upstream ever switches to using an empty array. Remove a couple of unnecessary increments.
-rw-r--r--shell/ash.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 95d0aebf0..a2b798cad 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -15590,7 +15590,7 @@ static int
15590tblentry_size(int funcblocksize, struct tblentry *tep) 15590tblentry_size(int funcblocksize, struct tblentry *tep)
15591{ 15591{
15592 while (tep) { 15592 while (tep) {
15593 funcblocksize += sizeof(struct tblentry) + strlen(tep->cmdname); 15593 funcblocksize += sizeof(struct tblentry) + align_len(tep->cmdname);
15594 /* CMDBUILTIN, e->param.cmd needs no pointer relocation */ 15594 /* CMDBUILTIN, e->param.cmd needs no pointer relocation */
15595 if (tep->cmdtype == CMDFUNCTION) { 15595 if (tep->cmdtype == CMDFUNCTION) {
15596 funcblocksize += offsetof(struct funcnode, n); 15596 funcblocksize += offsetof(struct funcnode, n);
@@ -15613,7 +15613,7 @@ tblentry_copy(struct tblentry *tep)
15613 newp = &start; 15613 newp = &start;
15614 while (tep) { 15614 while (tep) {
15615 *newp = funcblock; 15615 *newp = funcblock;
15616 size = sizeof(struct tblentry) + strlen(tep->cmdname); 15616 size = sizeof(struct tblentry) + align_len(tep->cmdname);
15617 15617
15618 funcblock = (char *) funcblock + size; 15618 funcblock = (char *) funcblock + size;
15619 memcpy(*newp, tep, size); 15619 memcpy(*newp, tep, size);
@@ -15745,7 +15745,6 @@ argv_copy(char **p)
15745 SAVE_PTR(*new); 15745 SAVE_PTR(*new);
15746 ANNOT_NO_DUP(xasprintf("argv[%d] '%s'", i++, *p)); 15746 ANNOT_NO_DUP(xasprintf("argv[%d] '%s'", i++, *p));
15747 p++; 15747 p++;
15748 new++;
15749 } 15748 }
15750 new = funcblock; 15749 new = funcblock;
15751 funcblock = (char *) funcblock + sizeof(char *); 15750 funcblock = (char *) funcblock + sizeof(char *);
@@ -15779,7 +15778,6 @@ history_copy(line_input_t *st)
15779 *new = nodeckstrdup(st->history[i]); 15778 *new = nodeckstrdup(st->history[i]);
15780 SAVE_PTR(*new); 15779 SAVE_PTR(*new);
15781 ANNOT_NO_DUP(xasprintf("history[%d] '%s'", i, st->history[i])); 15780 ANNOT_NO_DUP(xasprintf("history[%d] '%s'", i, st->history[i]));
15782 new++;
15783 } 15781 }
15784 return start; 15782 return start;
15785} 15783}