authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-08-23 19:24:41-07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-08-23 19:24:41-07:00
log95b36afadfe436856757013206db6c7048ff69c2
treec85733e484e5a377aee74fabbbb2bfd7269764bf
parent0e6c256cd96af224511210d877acef60ac07484f
signature Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

use nio.randomBytes instead of sys.getrandom directly


1 files changed, 2 insertions(+), 5 deletions(-)

nfs.zig+2-5
......@@ -57,8 +57,7 @@ pub fn munmap(region: []const u8) void {
5757pub fn mkdtemp() !Dir {
5858 var template = "/tmp/tmp.XXXXXXXXXX\x00".*;
5959 const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
60 var buf: [10]u8 = @splat(0);
61 const rand = try sys.getrandom(&buf, 0);
60 const rand = nio.randomBytes(10);
6261 if (rand.len != 10) return error.EAGAIN;
6362 for (template[9..][0..10], rand) |*a, b| a.* = letters[b % 62];
6463 const path = template[0 .. template.len - 1 :0];
......@@ -68,9 +67,7 @@ pub fn mkdtemp() !Dir {
6867pub fn mktemp(flags: Dir.CreateFlags) !File {
6968 var template = "/tmp/tmp.XXXXXXXXXX\x00".*;
7069 const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
71 var buf: [10]u8 = @splat(0);
72 const rand = try sys.getrandom(&buf, 0);
73 if (rand.len != 10) return error.EAGAIN;
70 const rand = nio.randomBytes(10);
7471 for (template[9..][0..10], rand) |*a, b| a.* = letters[b % 62];
7572 const path = template[0 .. template.len - 1 :0];
7673 return cwd().createFile(path, flags);