diff options
author | Ron Yorston <rmy@pobox.com> | 2018-02-19 15:22:31 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-02-19 15:33:12 +0000 |
commit | a1401e340043ac2829757be5c5f546d0ce7eadc7 (patch) | |
tree | 4f73e6c871e9bbd02c897dcc67a4ce242ea7d01a | |
parent | d1da09ea7a88cabdce417041ffa2018b7516de0c (diff) | |
download | busybox-w32-a1401e340043ac2829757be5c5f546d0ce7eadc7.tar.gz busybox-w32-a1401e340043ac2829757be5c5f546d0ce7eadc7.tar.bz2 busybox-w32-a1401e340043ac2829757be5c5f546d0ce7eadc7.zip |
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.
-rw-r--r-- | shell/ash.c | 4 |
1 files 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 | |||
15044 | tblentry_size(struct tblentry *tep) | 15044 | tblentry_size(struct tblentry *tep) |
15045 | { | 15045 | { |
15046 | while (tep) { | 15046 | while (tep) { |
15047 | funcblocksize += sizeof(struct tblentry) + strlen(tep->cmdname) + 1; | 15047 | funcblocksize += sizeof(struct tblentry) + strlen(tep->cmdname); |
15048 | /* CMDBUILTIN, e->param.cmd needs no pointer relocation */ | 15048 | /* CMDBUILTIN, e->param.cmd needs no pointer relocation */ |
15049 | if (tep->cmdtype == CMDFUNCTION) { | 15049 | if (tep->cmdtype == CMDFUNCTION) { |
15050 | funcblocksize += offsetof(struct funcnode, n); | 15050 | funcblocksize += offsetof(struct funcnode, n); |
@@ -15066,7 +15066,7 @@ tblentry_copy(struct tblentry *tep) | |||
15066 | newp = &start; | 15066 | newp = &start; |
15067 | while (tep) { | 15067 | while (tep) { |
15068 | *newp = funcblock; | 15068 | *newp = funcblock; |
15069 | size = sizeof(struct tblentry) + strlen(tep->cmdname) + 1; | 15069 | size = sizeof(struct tblentry) + strlen(tep->cmdname); |
15070 | 15070 | ||
15071 | funcblock = (char *) funcblock + size; | 15071 | funcblock = (char *) funcblock + size; |
15072 | memcpy(*newp, tep, size); | 15072 | memcpy(*newp, tep, size); |