Merge branch 'fix-seekdir' into 'master'

fix: handle negative offset in `seekdir`

Closes #260

See merge request redox-os/relibc!980
This commit is contained in:
Jeremy Soller
2026-02-24 08:11:11 -07:00
+6 -4
View File
@@ -354,10 +354,12 @@ pub unsafe extern "C" fn scandir(
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/seekdir.html>.
#[unsafe(no_mangle)]
pub extern "C" fn seekdir(dir: &mut DIR, off: c_long) {
dir.seek(
off.try_into()
.expect("off must come from telldir, thus never negative"),
);
let Ok(off) = off.try_into() else {
platform::ERRNO.set(EINVAL);
return;
};
dir.seek(off);
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/telldir.html>.