Skip to content

Commit

Permalink
Do not crash on tid == -1 in sys_thr_set_name (#667)
Browse files Browse the repository at this point in the history
Co-authored-by: SuchAFuriousDeath <[email protected]>
  • Loading branch information
mikusp and SuchAFuriousDeath authored Feb 23, 2024
1 parent c84b2fa commit d1c2463
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/kernel/src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ impl VProc {
}

fn sys_thr_set_name(self: &Arc<Self>, td: &VThread, i: &SysIn) -> Result<SysOut, SysErr> {
let tid: i32 = i.args[0].try_into().unwrap();
let tid: i64 = i.args[0].into();
let name: Option<&str> = unsafe { i.args[1].to_str(32) }?;

if tid == -1 {
Expand All @@ -432,7 +432,7 @@ impl VProc {

let thr = threads
.iter()
.find(|t| t.id().get() == tid)
.find(|t| t.id().get() == tid as i32)
.ok_or(SysErr::Raw(ESRCH))?;

info!(
Expand Down

0 comments on commit d1c2463

Please sign in to comment.