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

Advapi32Util.registryGetValues() returns no results if the key contains an empty REG_BINARY value #116

Closed
ghost opened this issue Sep 4, 2012 · 4 comments

Comments

@ghost
Copy link

ghost commented Sep 4, 2012

Not much else to say but this a bit serious for what I'm working on at the moment.

How to reproduce:

  1. Open up regedit
  2. Create a registry key and add an empty REG_BINARY value
  3. Add a couple of other values
  4. Then try this:
    System.out.println(Advapi32Util.registryGetValues(WinReg.HKEY_CURRENT_USER, "your_key_here").size());

You will see that it returns 0 entries, even though there are several actually there. If you remove that binary value, registryGetValues() will magically work again.

@twall
Copy link
Contributor

twall commented Sep 4, 2012

If you could augment the existing unit tests to reproduce this fault it would speed up getting a fix.

On Sep 3, 2012, at 11:51 PM, phailwhale22 wrote:

Not much else to say but this a bit serious for what I'm working on at the moment.

How to reproduce:

  1. Open up regedit
  2. Create a registry key and add an empty REG_BINARY value
  3. Add a couple of other values

• Then try this: System.out.println(Advapi32Util.registryGetValues(WinReg.HKEY_CURRENT_USER, "your_key_here").size());
You will see that it returns 0 entries, even though there are several actually there. If you remove that binary value, registryGetValues() will magically work again.


Reply to this email directly or view it on GitHub.

@ghost
Copy link
Author

ghost commented Sep 4, 2012

I'm feeling a bit dumb now, I had a try..catch block around my call to registryGetValues(). Here is the exception that it was throwing:

Exception in thread "main" java.lang.IllegalArgumentException: Allocation size must be greater than zero
at com.sun.jna.Memory.(Memory.java:88)
at com.sun.jna.platform.win32.Advapi32Util.registryGetValues(Advapi32Util.java:1265)
at com.sun.jna.platform.win32.Advapi32Util.registryGetValues(Advapi32Util.java:1327)

@ghost ghost closed this as completed Sep 4, 2012
@ghost
Copy link
Author

ghost commented Sep 4, 2012

Oops, accidentally closed the issue...

@ghost ghost reopened this Sep 4, 2012
@dblock
Copy link
Member

dblock commented Sep 4, 2012

Looks like a bug, https://github.com/twall/jna/blob/master/contrib/platform/src/com/sun/jna/platform/win32/Advapi32Util.java#L1265 is allocating memory when in fact there's none (empty binary value). Should be an easy fix, @phailwhale22 want to try a unit test that reproduces it (in https://github.com/twall/jna/blob/master/contrib/platform/test/com/sun/jna/platform/win32/Advapi32UtilTest.java) and maybe a fix?

@ghost ghost closed this as completed Sep 4, 2012
twall added a commit that referenced this issue Sep 7, 2012
mstyura pushed a commit to mstyura/jna that referenced this issue Sep 9, 2024
Motivation:

How we constructed the path was incorrect.

Modifications:

Fix path.

Result:

Be able to re-use precompiled quiche
This issue was closed.
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

No branches or pull requests

2 participants