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

'int java.lang.String.hashCode()' on a null object reference in SmbShareInfo class #108

Closed
oleg30 opened this issue Oct 2, 2018 · 2 comments

Comments

@oleg30
Copy link

oleg30 commented Oct 2, 2018

When trying to connect from Android device to Windows (server 2008 standard SP2 build 6002) and trying to call list() method of SmbFile - it gives NPE on line 137 of SmbShareInfo class (leading from line 164 of SmbEnumerationUtil class) on Android.
Using version 2.1 of jcifs-ng.
Properties of jcifs-ng set: "jcifs.smb.client.useExtendedSecurity" - "false", "jcifs.smb.client.useSMB2Negotiation" - "true", "jcifs.resolveOrder" - "DNS".
I will be very grateful if someone can tell why this can be and what string does it need in line 137 of SmbShareInfo? And maybe how to avoid this NPE?
Thank you.

NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference, stack:
jcifs.internal.smb1.net.SmbShareInfo.hashCode(SmbShareInfo.java:137), java.util.Collections.secondaryHash(Collections.java:3405),
java.util.HashMap.containsKey(HashMap.java:325),
java.util.HashSet.contains(HashSet.java:138),
jcifs.smb.SmbEnumerationUtil.doShareEnum(SmbEnumerationUtil.java:164), jcifs.smb.SmbEnumerationUtil.doEnum(SmbEnumerationUtil.java:222),
jcifs.smb.SmbEnumerationUtil.list(SmbEnumerationUtil.java:247),
jcifs.smb.SmbFile.list(SmbFile.java:1133)

And if I'm trying to connect to "smb://host_name/folder_name" and get SmbFile list() it returns error: jcifs.smb.SmbException: 0xC000026E, stack:
jcifs.smb.SmbTransportImpl.checkStatus2(SmbTransportImpl.java:1436), jcifs.smb.SmbTransportImpl.checkStatus(SmbTransportImpl.java:1547), jcifs.smb.SmbTransportImpl.sendrecv(SmbTransportImpl.java:1005),
jcifs.smb.SmbTransportImpl.send(SmbTransportImpl.java:1518),
jcifs.smb.SmbSessionImpl.send(SmbSessionImpl.java:407),
jcifs.smb.SmbTreeImpl.send(SmbTreeImpl.java:472),
jcifs.smb.SmbTreeConnection.send0(SmbTreeConnection.java:399),
jcifs.smb.SmbTreeConnection.send(SmbTreeConnection.java:314),
jcifs.smb.SmbTreeConnection.send(SmbTreeConnection.java:294),
jcifs.smb.SmbTreeHandleImpl.send(SmbTreeHandleImpl.java:130),
jcifs.smb.SmbTreeHandleImpl.send(SmbTreeHandleImpl.java:117), jcifs.smb.DirFileEntryEnumIterator2.open(DirFileEntryEnumIterator2.java:94), jcifs.smb.DirFileEntryEnumIteratorBase.(DirFileEntryEnumIteratorBase.java:67), jcifs.smb.DirFileEntryEnumIterator2.(DirFileEntryEnumIterator2.java:56), jcifs.smb.SmbEnumerationUtil.doEnum(SmbEnumerationUtil.java:227),
jcifs.smb.SmbEnumerationUtil.list(SmbEnumerationUtil.java:247),
jcifs.smb.SmbFile.list(SmbFile.java:1133)

Some debugging had shown that NPE on line 137 of SmbShareInfo class is rising when jcifs-ng trying to get name of root folder (e.g. ADMIN$), when local user with access to only one public folder is trying to connect. When domain user connecting - there's no NPE...

@mbechler
Copy link
Contributor

mbechler commented Oct 7, 2018

That commit should fix the null pointer exception when the share name is null, however the question is how we end up with an null name in the first place, any chance you can provide a traffic capture (pcap)?

@mbechler
Copy link
Contributor

I think this is fixed by the patches related to #130

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