From 2ffcb860ea478d4b8d553fe59af5982c5939f7fa Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 14 Jan 2020 15:42:58 +0000 Subject: 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. --- shell/ash.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'shell') 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 tblentry_size(int funcblocksize, struct tblentry *tep) { while (tep) { - funcblocksize += sizeof(struct tblentry) + strlen(tep->cmdname); + funcblocksize += sizeof(struct tblentry) + align_len(tep->cmdname); /* CMDBUILTIN, e->param.cmd needs no pointer relocation */ if (tep->cmdtype == CMDFUNCTION) { funcblocksize += offsetof(struct funcnode, n); @@ -15613,7 +15613,7 @@ tblentry_copy(struct tblentry *tep) newp = &start; while (tep) { *newp = funcblock; - size = sizeof(struct tblentry) + strlen(tep->cmdname); + size = sizeof(struct tblentry) + align_len(tep->cmdname); funcblock = (char *) funcblock + size; memcpy(*newp, tep, size); @@ -15745,7 +15745,6 @@ argv_copy(char **p) SAVE_PTR(*new); ANNOT_NO_DUP(xasprintf("argv[%d] '%s'", i++, *p)); p++; - new++; } new = funcblock; funcblock = (char *) funcblock + sizeof(char *); @@ -15779,7 +15778,6 @@ history_copy(line_input_t *st) *new = nodeckstrdup(st->history[i]); SAVE_PTR(*new); ANNOT_NO_DUP(xasprintf("history[%d] '%s'", i, st->history[i])); - new++; } return start; } -- cgit v1.2.3-55-g6feb