Skip to content

Commit 5392abe

Browse files
authored
Merge pull request #62 from notkadez/fix/macos-tmpdir-uds-path-too-long
fix(v8-runtime): shorten macOS bootstrap UDS socket path
2 parents d4fa0ab + bd4fe10 commit 5392abe

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

native/v8-runtime/src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ fn drain_pipe(fd: RawFd) {
8989
}
9090
}
9191

92-
/// Generate a 128-bit random hex string from /dev/urandom
93-
fn random_hex_128() -> io::Result<String> {
94-
let mut buf = [0u8; 16];
92+
/// Generate a 64-bit random hex string from /dev/urandom.
93+
fn random_hex_64() -> io::Result<String> {
94+
let mut buf = [0u8; 8];
9595
let mut f = fs::File::open("/dev/urandom")?;
9696
f.read_exact(&mut buf)?;
97-
Ok(buf.iter().fold(String::with_capacity(32), |mut s, b| {
97+
Ok(buf.iter().fold(String::with_capacity(16), |mut s, b| {
9898
use std::fmt::Write;
9999
let _ = write!(s, "{:02x}", b);
100100
s
@@ -105,7 +105,7 @@ fn random_hex_128() -> io::Result<String> {
105105
/// Uses DirBuilder::mode() to set permissions atomically via mkdir(2), avoiding
106106
/// a TOCTOU race between create_dir and set_permissions.
107107
fn create_socket_dir() -> io::Result<(PathBuf, PathBuf)> {
108-
let suffix = random_hex_128()?;
108+
let suffix = random_hex_64()?;
109109
let tmpdir = std::env::temp_dir().join(format!("secure-exec-{}", suffix));
110110
fs::DirBuilder::new().mode(0o700).create(&tmpdir)?;
111111
let socket_path = tmpdir.join("secure-exec.sock");
@@ -314,7 +314,7 @@ fn main() {
314314
.unwrap_or(4)
315315
});
316316

317-
// Create socket directory with 128-bit random suffix and 0700 permissions
317+
// Create socket directory with 64-bit random suffix and 0700 permissions
318318
let (tmpdir, socket_path) = create_socket_dir().expect("failed to create socket directory");
319319

320320
// Bind UDS listener

0 commit comments

Comments
 (0)