ash: all blocks in function node copying must be SHELL_ALIGNed

Previous commit probably introduced a bug:
non-matching size calculation in size counting and
actual copying caused by SHELL_ALIGN being applied differently!
This won't bite if string sizes are also SHELL_ALIGNed.
Thus fixing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2016-10-07 04:28:33 +02:00
parent d43be87591
commit 561639a68c

View File

@ -8248,7 +8248,7 @@ calcsize(int funcblocksize, union node *n)
funcblocksize = calcsize(funcblocksize, n->nif.test); funcblocksize = calcsize(funcblocksize, n->nif.test);
break; break;
case NFOR: case NFOR:
funcblocksize += strlen(n->nfor.var) + 1; /* was funcstringsize += ... */ funcblocksize += SHELL_ALIGN(strlen(n->nfor.var) + 1); /* was funcstringsize += ... */
funcblocksize = calcsize(funcblocksize, n->nfor.body); funcblocksize = calcsize(funcblocksize, n->nfor.body);
funcblocksize = calcsize(funcblocksize, n->nfor.args); funcblocksize = calcsize(funcblocksize, n->nfor.args);
break; break;
@ -8264,7 +8264,7 @@ calcsize(int funcblocksize, union node *n)
case NDEFUN: case NDEFUN:
case NARG: case NARG:
funcblocksize = sizenodelist(funcblocksize, n->narg.backquote); funcblocksize = sizenodelist(funcblocksize, n->narg.backquote);
funcblocksize += strlen(n->narg.text) + 1; /* was funcstringsize += ... */ funcblocksize += SHELL_ALIGN(strlen(n->narg.text) + 1); /* was funcstringsize += ... */
funcblocksize = calcsize(funcblocksize, n->narg.next); funcblocksize = calcsize(funcblocksize, n->narg.next);
break; break;
case NTO: case NTO:
@ -8298,7 +8298,7 @@ calcsize(int funcblocksize, union node *n)
static char * static char *
nodeckstrdup(char *s) nodeckstrdup(char *s)
{ {
funcstring_end -= strlen(s) + 1; funcstring_end -= SHELL_ALIGN(strlen(s) + 1);
return strcpy(funcstring_end, s); return strcpy(funcstring_end, s);
} }