authorgravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2020-10-02 19:33:14+02:00
committergravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2020-10-02 19:33:14+02:00
logf841ea77e2cb7ad2ee4ecf993206f0c29d087131
treec18cbb48354f9d3c06b294ff9b9948eb21a8761c
parenta2074c1ec31ab553aea4232dfdc760a0442aeddf

make symlink buffer null-terminated

Signed-off-by: Loris Cro <kappaloris@gmail.com>

2 files changed, 3 insertions(+), 3 deletions(-)

lib/std/c/darwin.zig+1-1
...@@ -12,7 +12,7 @@ usingnamespace @import("../os/bits.zig");...@@ -12,7 +12,7 @@ usingnamespace @import("../os/bits.zig");
1212
13extern "c" fn __error() *c_int;13extern "c" fn __error() *c_int;
14pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32;14pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32;
15pub extern "c" fn _NSGetExecutablePath(buf: [*]u8, bufsize: *u32) c_int;15pub extern "c" fn _NSGetExecutablePath(buf: [*:0]u8, bufsize: *u32) c_int;
16pub extern "c" fn _dyld_image_count() u32;16pub extern "c" fn _dyld_image_count() u32;
17pub extern "c" fn _dyld_get_image_header(image_index: u32) ?*mach_header;17pub extern "c" fn _dyld_get_image_header(image_index: u32) ?*mach_header;
18pub extern "c" fn _dyld_get_image_vmaddr_slide(image_index: u32) usize;18pub extern "c" fn _dyld_get_image_vmaddr_slide(image_index: u32) usize;
lib/std/fs.zig+2-2
...@@ -2192,13 +2192,13 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {...@@ -2192,13 +2192,13 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 {
2192 if (is_darwin) {2192 if (is_darwin) {
2193 // Note that _NSGetExecutablePath() will return "a path" to2193 // Note that _NSGetExecutablePath() will return "a path" to
2194 // the executable not a "real path" to the executable.2194 // the executable not a "real path" to the executable.
2195 var symlink_path_buf: [MAX_PATH_BYTES]u8 = undefined;2195 var symlink_path_buf: [MAX_PATH_BYTES:0]u8 = undefined;
2196 var u32_len: u32 = MAX_PATH_BYTES;2196 var u32_len: u32 = MAX_PATH_BYTES;
2197 const rc = std.c._NSGetExecutablePath(&symlink_path_buf, &u32_len);2197 const rc = std.c._NSGetExecutablePath(&symlink_path_buf, &u32_len);
2198 if (rc != 0) return error.NameTooLong;2198 if (rc != 0) return error.NameTooLong;
21992199
2200 var real_path_buf: [MAX_PATH_BYTES]u8 = undefined;2200 var real_path_buf: [MAX_PATH_BYTES]u8 = undefined;
2201 const real_path = try std.os.realpathZ(@ptrCast([*:0]u8, &symlink_path_buf), &real_path_buf);2201 const real_path = try std.os.realpathZ(&symlink_path_buf, &real_path_buf);
2202 if (real_path.len > out_buffer.len) return error.NameTooLong;2202 if (real_path.len > out_buffer.len) return error.NameTooLong;
2203 std.mem.copy(u8, out_buffer, real_path);2203 std.mem.copy(u8, out_buffer, real_path);
2204 return out_buffer[0..real_path.len];2204 return out_buffer[0..real_path.len];