fix: handle negative offset in seekdir

This commit is contained in:
Marsman
2026-02-09 16:10:42 +00:00
parent ab6a2e7322
commit d29016c98c
+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>.