Skip to content

Commit

Permalink
Creating a pipe does not use the RNG, on Windows
Browse files Browse the repository at this point in the history
Closes #390.
  • Loading branch information
gaborcsardi committed Jan 28, 2025
1 parent 118704a commit e190b4a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/win/stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ static int processx__create_output_handle(HANDLE *handle_ptr, const char *file,
}

static void processx__unique_pipe_name(char* ptr, char* name, size_t size) {
int r;
GetRNGstate();
r = (int)(unif_rand() * 65000);
snprintf(name, size, "\\\\?\\pipe\\px\\%p-%lu", ptr + r, GetCurrentProcessId());
PutRNGstate();
// we'll retry with a larger number if it already exists
static int cntr = 0;
snprintf(
name, size, "\\\\?\\pipe\\px\\%p-%lu", ptr + cntr++,
GetCurrentProcessId()
);
}

int processx__create_pipe(void *id, HANDLE* parent_pipe_ptr,
Expand Down

0 comments on commit e190b4a

Please sign in to comment.