shell: utils: Fix buffer overrun in shell_spaces_trim

The third argument in memmove can possible be greater than remaining
buffer size. Just ensuring that memmove will changes bytes only inside
the string buffer and nothing else.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2020-03-05 11:32:51 -08:00 committed by Johan Hedberg
commit a2872c3a00

View file

@ -413,7 +413,7 @@ void shell_spaces_trim(char *str)
/* +1 for EOS */ /* +1 for EOS */
memmove(&str[i + 1], memmove(&str[i + 1],
&str[j], &str[j],
len - shift + 1); len - j + 1);
len -= shift; len -= shift;
shift = 0U; shift = 0U;
} }