]> www.infradead.org Git - users/dwmw2/openconnect.git/commit
dumb_socketpair(): generate named socket path more carefully
authorDaniel Lenski <dlenski@gmail.com>
Sat, 1 Jan 2022 03:22:54 +0000 (22:22 -0500)
committerDaniel Lenski <dlenski@gmail.com>
Thu, 13 Jan 2022 05:38:08 +0000 (21:38 -0800)
commitf7a24edc344ab9f05f964fe7367dd35868b83d63
tree0b0ca30cd7923ba23a49fc066df54b62dbc6debf
parent7920ffb0953423b144126fc56b6bcff77821ca07
dumb_socketpair(): generate named socket path more carefully

Windows forces us to use named-path Unix sockets.  Generating a path in the
temporary directory, combining current high-res time and PID, seems like a
less-bad option.

On GitHub, a commenter
[suggested](https://github.com/microsoft/WSL/issues/4240#issuecomment-1010545442)
that it would be better to use
[GetTempFileName](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettempfilenamea)
here. However, that function:

- Only adds 16 bits of time-based random bits,
- Will currently fail if there aren't 14 characters available for the filename,
- Might conceivably generate paths longer than UNIX_PATH_MAX, and
- Offers no other apparent offsetting advantages

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
compat.c