mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 12:29:07 +00:00
Revert "node:fs.readdir: should not fail even if folder contains self-referential symlinks" (#10750)
This commit is contained in:
@@ -504,12 +504,6 @@ pub const AsyncReaddirRecursiveTask = struct {
|
||||
is_root,
|
||||
)) {
|
||||
.err => |err| {
|
||||
// readdir() should never fail with 'ELOOP: Too many levels of symbolic links'
|
||||
if (err.getErrno() == .LOOP) {
|
||||
this.writeResults(ResultType, &entries);
|
||||
return;
|
||||
}
|
||||
|
||||
for (entries.items) |*item| {
|
||||
switch (ResultType) {
|
||||
bun.String => item.deref(),
|
||||
@@ -4973,8 +4967,6 @@ pub const NodeFS = struct {
|
||||
// This is different than what Node does, at the time of writing.
|
||||
// Node doesn't gracefully handle errors like these. It fails the entire operation.
|
||||
.NOENT, .NOTDIR, .PERM => continue,
|
||||
// readdir() should never fail with 'ELOOP: Too many levels of symbolic links'
|
||||
.LOOP => continue,
|
||||
else => {
|
||||
const path_parts = [_]string{ args.path.slice(), basename };
|
||||
return .{
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../../../..
|
||||
@@ -8,7 +8,6 @@ import fs, {
|
||||
existsSync,
|
||||
mkdirSync,
|
||||
openSync,
|
||||
readdir,
|
||||
readdirSync,
|
||||
readFile,
|
||||
readFileSync,
|
||||
@@ -3031,20 +3030,3 @@ it("promises.fdatasync with a bad fd should include that in the error thrown", a
|
||||
}
|
||||
expect.unreachable();
|
||||
});
|
||||
|
||||
it("readdirSync should not crash on symlink loops", () => {
|
||||
// prettier-ignore
|
||||
expect(readdirSync(join(import.meta.dirname, "./fixtures/readdir-loop"), { recursive: true }).length).toBe(symlink_fixture_depth());
|
||||
});
|
||||
|
||||
it("readdir should not crash on symlink loops", async () => {
|
||||
// prettier-ignore
|
||||
expect((await promisify(readdir)(join(import.meta.dirname, "./fixtures/readdir-loop"), { recursive: true })).length).toBe(symlink_fixture_depth());
|
||||
});
|
||||
|
||||
function symlink_fixture_depth() {
|
||||
if (process.platform === "darwin") return 166;
|
||||
if (process.platform === "linux") return 206;
|
||||
if (process.platform === "win32") return 6;
|
||||
throw new Error(`test unimplemented for '${process.platform}'`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user