File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -1486,7 +1486,10 @@ pub mod module {
14861486 let mut flags = 0i32 ;
14871487
14881488 if let Some ( pgid) = self . setpgroup {
1489- assert ! ( unsafe { libc:: posix_spawnattr_setpgroup( & mut attrp, pgid) } == 0 ) ;
1489+ let ret = unsafe { libc:: posix_spawnattr_setpgroup ( & mut attrp, pgid) } ;
1490+ if ret != 0 {
1491+ return Err ( vm. new_os_error ( format ! ( "posix_spawnattr_setpgroup failed: {ret}" ) ) ) ;
1492+ }
14901493 flags |= libc:: POSIX_SPAWN_SETPGROUP ;
14911494 }
14921495
@@ -1518,7 +1521,12 @@ pub mod module {
15181521 } ) ?;
15191522 set. add ( sig) ;
15201523 }
1521- assert ! ( unsafe { libc:: posix_spawnattr_setsigmask( & mut attrp, set. as_ref( ) ) } == 0 ) ;
1524+ let ret = unsafe { libc:: posix_spawnattr_setsigmask ( & mut attrp, set. as_ref ( ) ) } ;
1525+ if ret != 0 {
1526+ return Err (
1527+ vm. new_os_error ( format ! ( "posix_spawnattr_setsigmask failed: {ret}" ) )
1528+ ) ;
1529+ }
15221530 flags |= libc:: POSIX_SPAWN_SETSIGMASK ;
15231531 }
15241532
@@ -1531,7 +1539,15 @@ pub mod module {
15311539 }
15321540
15331541 if flags != 0 {
1534- assert ! ( unsafe { libc:: posix_spawnattr_setflags( & mut attrp, flags as i16 ) } == 0 ) ;
1542+ // Check for potential overflow when casting to c_short
1543+ if flags > libc:: c_short:: MAX as i32 {
1544+ return Err ( vm. new_value_error ( "Too many flags set for posix_spawn" . to_owned ( ) ) ) ;
1545+ }
1546+ let ret =
1547+ unsafe { libc:: posix_spawnattr_setflags ( & mut attrp, flags as libc:: c_short ) } ;
1548+ if ret != 0 {
1549+ return Err ( vm. new_os_error ( format ! ( "posix_spawnattr_setflags failed: {ret}" ) ) ) ;
1550+ }
15351551 }
15361552
15371553 let mut args: Vec < CString > = self
You can’t perform that action at this time.
0 commit comments