Commit d5f0495
committed
Fix parsing arguments
When executing the 'ih' or 'it' command with multiple leading spaces,
the parsed arguments contained unexpected characters.
The problem stemmed from 'parse_args' allocating memory for 'buf' using
'malloc_or_fail', which does not initialize memory. Since 'strlen'
determines string length based on the first null terminator
it encounters, uninitialized memory beyond the expected input could be
incorrectly read, leading to unintended characters in 'argv'.
To fix this, an explicit null terminator was added at the end of
the parsing loop, ensuring proper null termination and
preventing 'strlen' from reading beyond valid input.
This change guarantees correct argument parsing
even when the input contains multiple leading spaces.
Close #233
Change-Id: I178fa357962b28fd22646ab9c21542e1c780bd551 parent 29d90ea commit d5f0495
1 file changed
+2
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
147 | 149 | | |
148 | 150 | | |
149 | 151 | | |
| |||
0 commit comments