From: Tudor Cretu <[email protected]> A reference can be either an array of numbers or an array of arrays. The bc code makes the following check for a reference: ref = (v->size == sizeof(BcVec) && t != BC_TYPE_ARRAY);
Which, semantically, only checks for an array of arrays. On many platforms, one has sizeof(BcVec) == sizeof(BcNum); and the above check implicitly covers an array of numbers too. Unfortunately, there are cases where sizeof(BcVec) != sizeof(BcNum) (the Morello platform being one), which can lead to an array of numbers being mis-identified. (Any future changes to the two structs could also lead to their sizes changing). This patch fixes the conditional check to cover both array of arrays and array of numbers explicitly. Signed-off-by: Tudor Cretu <[email protected]> Reviewed-by: Steve Capper <[email protected]> [SteveC: tweaked commit log] Signed-off-by: Steve Capper <[email protected]> --- miscutils/bc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miscutils/bc.c b/miscutils/bc.c index ab785bbc8..55f23cfb6 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c @@ -5921,7 +5921,7 @@ static BC_STATUS zxc_program_popResultAndCopyToVar(char *name, BcType t) BcVec *v = (BcVec*) n; bool ref, ref_size; - ref = (v->size == sizeof(BcVec) && t != BC_TYPE_ARRAY); + ref = ((v->size == sizeof(BcVec) || v->size == sizeof(BcNum)) && t != BC_TYPE_ARRAY); ref_size = (v->size == sizeof(uint8_t)); if (ref || (ref_size && t == BC_TYPE_REF)) { -- 2.35.1 _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
