Skip to content

libgamestream: fix uniqueid.dat read check - #933

Merged
cgutman merged 1 commit into
moonlight-stream:masterfrom
jfernandez:fix/uniqueid-fread
Jun 6, 2026
Merged

libgamestream: fix uniqueid.dat read check#933
cgutman merged 1 commit into
moonlight-stream:masterfrom
jfernandez:fix/uniqueid-fread

Conversation

@jfernandez

Copy link
Copy Markdown
Contributor

fread(unique_id, UNIQUEID_CHARS, 1, fd) returns the number of items read (1 on success), not bytes, so the != UNIQUEID_CHARS comparison is always true. The result is that an existing uniqueid.dat is silently ignored and rewritten with the default 0123456789ABCDEF on every run, so a custom per-device uniqueid is impossible.

This bit me when pairing a second moonlight-embedded client against a host that keys pairing state by uniqueid (moonshine). Once the first device pairs with the shared default id, the second client is told it's already paired and gs_pair bails before ever sending getservercert.

Fix is to compare against the item count. Tested on 2.7.0 (same code as master): with this change a custom uniqueid.dat survives restarts and the second client pairs fine.

fread(unique_id, UNIQUEID_CHARS, 1, fd) returns the number of items
read (1 on success), not bytes, so the != UNIQUEID_CHARS comparison is
always true. Any existing uniqueid.dat is silently ignored and
rewritten with the default 0123456789ABCDEF on every run, making a
custom per-device uniqueid impossible.
@cgutman
cgutman merged commit f32e415 into moonlight-stream:master Jun 6, 2026
0 of 6 checks passed
@cgutman

cgutman commented Jun 6, 2026

Copy link
Copy Markdown
Member

Merged, thanks!

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 this pull request may close these issues.

2 participants