diff options
author | Thomas Bertschinger <tahbertschinger@gmail.com> | 2024-01-11 23:57:29 -0700 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-01-12 15:04:13 -0500 |
commit | aefc2644017d85ec9b502fb4d10b917c2a0629ed (patch) | |
tree | c97fc2b6cb0dcf452fafa85ba2220fe212578d9e /rust-src | |
parent | 076216c16b2cbf5ab774fa34a83e6ef5b9429a4b (diff) |
fix invalid write in pop_cmd()
The memmove() in pop_cmd() reads and writes beyond the end of argv.
This is basically harmless in the current C program; the environment
variable list immediately follows argv so all this does is unnecessarily
copy the beginning of that list.
However, this will become problematic once we start calling C functions
like fs_cmds() from Rust code. Then argv will be a Vec<String> (as
*mut *mut i8) and the memory layout will be different--in particular,
I don't think we can assume that a Vec<String> will be NULL-terminated
like argv always is--, meaning the invalid write could lead to heap
corruption.
Also, it doesn't look like full_cmd ever gets used after calling
pop_cmd() so I'm removing it here since it looks unneeded to me.
Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'rust-src')
0 files changed, 0 insertions, 0 deletions