zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit beb9d33d6da42be75faed2975cf16e4acbf62be4 (tree)
parent 8c9919ec7b409d11ca73ca5764f44282dec0fe25
Author: Alexandros Naskos <alex_naskos@hotmail.com>
Date:   Tue, 17 Nov 2020 14:05:01 +0200

Disallow absolute paths passed as system libraries

Added OBJECT_NAME_INVALID handling in faccessatW

Diffstat:
Mlib/std/os.zig | 1+
Msrc/main.zig | 3+++
2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/lib/std/os.zig b/lib/std/os.zig @@ -3809,6 +3809,7 @@ pub fn faccessatW(dirfd: fd_t, sub_path_w: [*:0]const u16, mode: u32, flags: u32 .SUCCESS => return, .OBJECT_NAME_NOT_FOUND => return error.FileNotFound, .OBJECT_PATH_NOT_FOUND => return error.FileNotFound, + .OBJECT_NAME_INVALID => return error.BadPathName, .INVALID_PARAMETER => unreachable, .ACCESS_DENIED => return error.PermissionDenied, .OBJECT_PATH_SYNTAX_BAD => unreachable, diff --git a/src/main.zig b/src/main.zig @@ -1401,6 +1401,9 @@ fn buildOutputType( _ = system_libs.orderedRemove(i); continue; } + if (std.fs.path.isAbsolute(lib_name)) { + fatal("cannot use absolute path as a system library: {}", .{lib_name}); + } i += 1; } }