Skip to content

Commit

Permalink
Merge pull request #22 from vyfor/dev
Browse files Browse the repository at this point in the history
fix: Validate the IPC path before connecting
  • Loading branch information
vyfor authored Nov 6, 2024
2 parents d31c74e + fe4dee3 commit 3dab928
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,13 @@ actual class Connection {
dirs.forEach { dir ->
for (i in 0..9) {
try {
pipe = SocketChannel.open(UnixDomainSocketAddress.of("$dir/discord-ipc-$i"))
val path = Path("$dir/discord-ipc-$i")
if (!path.exists()) continue
pipe = SocketChannel.open(UnixDomainSocketAddress.of(path))
return
} catch (_: InvalidPathException) {
} catch (_: IllegalArgumentException) {
} catch (e: SocketException) {
if (e.message == "No such file or directory") continue
throw ConnectionException(e)
} catch (e: Exception) {
throw ConnectionException(e)
Expand Down

0 comments on commit 3dab928

Please sign in to comment.