Skip to content

Commit 13fd2d3

Browse files
Flavio Ceolinnashif
authored andcommitted
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 <[email protected]>
1 parent 6da1361 commit 13fd2d3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

subsys/shell/shell_utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ void shell_spaces_trim(char *str)
324324
/* +1 for EOS */
325325
memmove(&str[i + 1],
326326
&str[j],
327-
len - shift + 1);
327+
len - j + 1);
328328
len -= shift;
329329
shift = 0U;
330330
}

0 commit comments

Comments
 (0)