Skip to content

Commit

Permalink
return correct error code on overlong paths
Browse files Browse the repository at this point in the history
  • Loading branch information
gvilums committed Apr 12, 2024
1 parent 22d6227 commit d785d30
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions src/bun.js/node/types.zig
Original file line number Diff line number Diff line change
Expand Up @@ -926,12 +926,9 @@ pub const Valid = struct {
0...bun.MAX_PATH_BYTES => return true,
else => {
// TODO: should this be an EINVAL?
JSC.throwInvalidArguments(
comptime std.fmt.comptimePrint("Invalid path string: path is too long (max: {d})", .{bun.MAX_PATH_BYTES}),
.{},
ctx,
exception,
);
var system_error = bun.sys.Error.fromCode(.NAMETOOLONG, .open).withPath(zig_str.slice()).toSystemError();
system_error.syscall = bun.String.dead;
exception.* = system_error.toErrorInstance(ctx).asObjectRef();
return false;
},
}
Expand All @@ -944,12 +941,9 @@ pub const Valid = struct {
0...bun.MAX_PATH_BYTES => return true,
else => {
// TODO: should this be an EINVAL?
JSC.throwInvalidArguments(
comptime std.fmt.comptimePrint("Invalid path string: path is too long (max: {d})", .{bun.MAX_PATH_BYTES}),
.{},
ctx,
exception,
);
var system_error = bun.sys.Error.fromCode(.NAMETOOLONG, .open).toSystemError();
system_error.syscall = bun.String.dead;
exception.* = system_error.toErrorInstance(ctx).asObjectRef();
return false;
},
}
Expand All @@ -970,14 +964,9 @@ pub const Valid = struct {
},

else => {

// TODO: should this be an EINVAL?
JSC.throwInvalidArguments(
comptime std.fmt.comptimePrint("Invalid path buffer: path is too long (max: {d})", .{bun.MAX_PATH_BYTES}),
.{},
ctx,
exception,
);
var system_error = bun.sys.Error.fromCode(.NAMETOOLONG, .open).toSystemError();
system_error.syscall = bun.String.dead;
exception.* = system_error.toErrorInstance(ctx).asObjectRef();
return false;
},
1...bun.MAX_PATH_BYTES => return true,
Expand Down

0 comments on commit d785d30

Please sign in to comment.