setexpr: Split the core logic into its own function
authorSimon Glass <sjg@chromium.org>
Sun, 1 Nov 2020 21:15:39 +0000 (14:15 -0700)
committerTom Rini <trini@konsulko.com>
Tue, 1 Dec 2020 15:33:38 +0000 (10:33 -0500)
commit56331b2680d9fef7e60a88fa50d3e167f236c4a0
treeda95bc331ed888120f361fc199d512a9b0e86156
parente713124e352efe3141af6a4ffc83f6dba449a177
setexpr: Split the core logic into its own function

At present this function always allocates a large amount of stack, and
selects its own size for buffers. This makes it hard to test the code
for buffer overflow.

Separate out the inner logic of the substitution so that tests can call
this directly. This will allow checking that the algorithm does not
overflow the buffer.

Fix up one of the error lines at the same time, since it should be
printing nbuf_size, not data_size.

Signed-off-by: Simon Glass <sjg@chromium.org>
cmd/setexpr.c