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

os_get_passwd: Explicitly compare uid/gid against -1 instead of >= 0 #590

Merged
merged 1 commit into from Mar 12, 2022

Conversation

squeek502
Copy link
Member

@squeek502 squeek502 commented Mar 12, 2022

In Libuv 1.44.0, uv_passwd_t.uid/gid was changed to be unsigned, so the >= 0 check would always return true. Changing to compare against -1 explicitly fixes #589 while still maintaining correct functionality when built against previous Libuv versions. Note that with Libuv 1.44.0 and above, this relies on implicitly casting -1 to unsigned long (the type of uv_passwd_t.uid/uv_passwd_t.gid).

Before (incorrectly including uid/gid):

  { homedir = "C:\\Users\\Ryan", username = "Ryan", uid = 4294967295, gid = 4294967295 }
ok 13 uv.os_get_passwd

After (correctly omitting uid/gid):

  { homedir = "C:\\Users\\Ryan", username = "Ryan" }
ok 13 uv.os_get_passwd

In Libuv 1.44.0, uv_passwd_t.uid/gid was changed to be unsigned, so the >= 0 check would always return true. Changing to compare against -1 explicitly fixes luvit#589 while still maintaining correct functionality when built against previous Libuv versions. Note that with Libuv 1.44.0 and above, this relies on implicitly casting -1 to unsigned long (the type of `uv_passwd_t.uid`/`uv_passwd_t.gid`).
@squeek502 squeek502 merged commit 4e7e56c into luvit:master Mar 12, 2022
squeek502 added a commit to squeek502/luv that referenced this pull request Mar 12, 2022
…s environments

-1 only has special meaning on Windows, and gid and uid are always set to -1 on Windows, so we can just omit the gid and uid fields on Windows instead of checking for -1. This is a better fix for luvit#589, and a follow up to luvit#590.
zhaozg pushed a commit that referenced this pull request Mar 12, 2022
…s environments

-1 only has special meaning on Windows, and gid and uid are always set to -1 on Windows, so we can just omit the gid and uid fields on Windows instead of checking for -1. This is a better fix for #589, and a follow up to #590.
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.

Libuv 1.44.0 uv_os_get_passwd signed -> unsigned change breaks our binding
2 participants