Skip to content

Commit

Permalink
proces: Fix parsing of empty argument
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentdephily committed Oct 28, 2024
1 parent a3c381d commit b6067ef
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/parse/proces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl Disp for FmtProc<'_> {
cmdstart = f1 + 1;
}
if let Some(z2) = cmdline[z1 + 1..].find('\0') {
if let Some(f2) = approx_filename(&cmdline[z1 + 1..z1 + z2]) {
if let Some(f2) = approx_filename(&cmdline[z1 + 1..z1 + 1 + z2]) {
cmdstart = z1 + f2 + 2;
}
}
Expand Down Expand Up @@ -295,7 +295,8 @@ pub mod tests {
("/usr/bin/bash\0/path/to/toto\0--arg", "1 toto --arg"),
("bash\0/usr/lib/portage/python3.12/ebuild.sh\0unpack\0", "1 ebuild.sh unpack"),
("[foo/bar-0.1.600] sandbox\0/path/to/ebuild.sh\0unpack\0", "1 ebuild.sh unpack"),
("[foo/bar-0.1.600] sandbox\0blah\0", "1 [foo/bar-0.1.600] sandbox blah"),];
("[foo/bar-0.1.600] sandbox\0blah\0", "1 [foo/bar-0.1.600] sandbox blah"),
("/bin/foo\0\0", "1 foo")];
for (cmd, out) in t.into_iter() {
let mut buf = vec![];
let p = Proc { kind: ProcKind::Other, pid: 1, ppid: 1, cmdline: cmd.into(), start: 0 };
Expand Down

0 comments on commit b6067ef

Please sign in to comment.