Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL: Unexpected dbus-launch response leads to panic when parsing for address #151

Closed
johnnymo87 opened this issue Apr 10, 2019 · 0 comments · Fixed by #152
Closed

WSL: Unexpected dbus-launch response leads to panic when parsing for address #151

johnnymo87 opened this issue Apr 10, 2019 · 0 comments · Fixed by #152

Comments

@johnnymo87
Copy link
Contributor

In using this library via clisso, I encountered an exception parsing the output of dbus-launch. My machine was responding to that with the following:

process 7616: D-Bus library appears to be incorrectly set up; failed to read machine uuid: UUID file '/etc/machine-id' should contain a hex string of length 32, not len
gth 0, with no other text
See the manual page for dbus-uuidgen to correct this issue.
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-0SO9YZUBGA,guid=ac22f2f3b9d228496b4d4b935cae3417
DBUS_SESSION_BUS_PID=7620
DBUS_SESSION_BUS_WINDOWID=16777217

I think this is due to the fact that I'm running WSL, and I had to do the following to get dbus properly setup on my machine.

sudo apt-get install dbus-x11
sudo service dbus start

The code assumes the = will always preceed the \n, and thus does b[i+1:j]:

	i := bytes.IndexByte(b, '=')
	j := bytes.IndexByte(b, '\n')
	env, addr := string(b[0:i]), string(b[i+1:j])

In my case, the newline came before the equals sign, and thus the slice arguments made no sense and threw panic: runtime error: slice bounds out of range.

jsouthworth pushed a commit that referenced this issue Apr 13, 2019
Users may not have dbus properly configured, and their machine may respond
to dbus-launch with a multiline string that prints a warning before returning
the expected output. The code handling this response assumed that it would
always find '=' before it finds '\n', but this not true in the case of a
multiline string. Rather, it is the other way around, and thus the code sliced
the response with a lower bound greater than its upper bound, leading to a
"panic: runtime error: slice bounds out of range" crash.

Fixes #151
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant