RFR 9: 8081567 : java/lang/ProcessHandle/InfoTest.java failed Cannot run program "whoami"
Ivan Gerasimov
ivan.gerasimov at oracle.com
Tue Jun 2 21:37:01 UTC 2015
Hi Roger!
On 02.06.2015 0:38, Roger Riggs wrote:
> Please review a change to report the user/owner in ProcessHandle.info to
> have the same form for the owner identification as provided by
> java.nio.Files.
> On Windows it includes the domain with the user name.
>
> The test is updated to remove a dependency on the OS command whoami
> and instead compare the users process with the owner of a file created
> by the process improving portability.
>
> Webrev:
> http://cr.openjdk.java.net/~rriggs/webrev-whoami-8081567/
>
1)
+ if (domainLen > 0) {
+ wcscat(domain, L"\\");
+ } else {
+ domain[0] = L'\0';
+ }
+ wcscat(domain, name);
Here, domainLen is either equal to whatever LookupAccountSid has set it to.
In MSDN [1] it's written:
On input, specifies the size, in TCHARs, of the lpReferencedDomainName
buffer. If the function fails because the buffer is too small or if
cchReferencedDomainName is zero, cchReferencedDomainName receives the
required buffer size, including the terminating null character.
I see in the comments that in fact on success this parameter receives
the length of the resulting string.
But should we rely on that undocumented behavior?
Does it really happen that LookupAccountSidW() returns 0, setting
domainLen to 0 and leaving the domain buffer uninitialized?
From the published example [2] it seems that this shouldn't happen.
2)
I think domainLen should be set to
DWORD domainLen = sizeof(domain) - sizeof(name) - 1;
Otherwise LookupAccountSid is allowed to fill up the whole buffer, so
that 'name' could not be appended.
3)
Indentation isn't consistent: it should be multiple of 4.
Sincerely yours,
Ivan
[1]
https://msdn.microsoft.com/en-us/library/windows/desktop/aa379166%28v=vs.85%29.aspx
[2]
https://msdn.microsoft.com/en-us/library/windows/desktop/aa379554(v=vs.85).aspx
> Issue:
> https://bugs.openjdk.java.net/browse/JDK-8081567
>
> Thanks, Roger
>
>
More information about the core-libs-dev
mailing list