From a1401e340043ac2829757be5c5f546d0ce7eadc7 Mon Sep 17 00:00:00 2001 From: Ron Yorston <rmy@pobox.com> Date: Mon, 19 Feb 2018 15:22:31 +0000 Subject: ash: use correct size for tblentry As noted in cmdlookup the size of a tblentry instance, *t, is sizeof(struct tblentry) + strlen(t->cmdname) because the structure includes one byte for the cmdname array. Apply the same logic in tblentry_size and tblentry_copy. --- shell/ash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index 8f137404f..59c1d2272 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -15044,7 +15044,7 @@ static void tblentry_size(struct tblentry *tep) { while (tep) { - funcblocksize += sizeof(struct tblentry) + strlen(tep->cmdname) + 1; + funcblocksize += sizeof(struct tblentry) + strlen(tep->cmdname); /* CMDBUILTIN, e->param.cmd needs no pointer relocation */ if (tep->cmdtype == CMDFUNCTION) { funcblocksize += offsetof(struct funcnode, n); @@ -15066,7 +15066,7 @@ tblentry_copy(struct tblentry *tep) newp = &start; while (tep) { *newp = funcblock; - size = sizeof(struct tblentry) + strlen(tep->cmdname) + 1; + size = sizeof(struct tblentry) + strlen(tep->cmdname); funcblock = (char *) funcblock + size; memcpy(*newp, tep, size); -- cgit v1.2.3-55-g6feb