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

Fixes for #114. #122

Closed
wants to merge 2 commits into from
Closed

Fixes for #114. #122

wants to merge 2 commits into from

Conversation

kentcb
Copy link
Contributor

@kentcb kentcb commented Jul 29, 2014

Where relevant, tokens are obtained in a loop with an increasing buffer size as long as SEC_E_BUFFER_TOO_SMALL or SEC_E_INSUFFICIENT_MEMORY is returned.

As discussed in the forum, there is still a case that is not dealt with here. Namely, if the buffer size is too small then TestNegotiate() will fail with:

System.ComponentModel.Win32Exception : Not enough memory is available to complete this request
        WindowsSecurityContext.cs(143,0): at Waffle.Windows.AuthProvider.WindowsSecurityContext..ctor(String username, WindowsCredentialsHandle credentials, String securityPackage, Int32 fContextReq, Int32 targetDataRep)

It only fails on the second call to InitializeSecurityContext().

Where relevant, tokens are obtained in a loop with an increasing buffer size as long as SEC_E_BUFFER_TOO_SMALL or SEC_E_INSUFFICIENT_MEMORY is returned.

throw new Win32Exception(rc);
}
if (continueSecHandle == Secur32.SecHandle.Zero)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two branches are identical minus a single parameter. Condition with a 1-liner in it: continueSecHandle == Secur32SecHandle.Zero ? IntPtr.Zero : ref continueSecHandle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 problems: 1. I was trying not to change existing code - just do the minimal to fix the issue. 2. That won't compile, which I suspect is why it was written that way in the first place.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

@dblock
Copy link
Collaborator

dblock commented Jul 29, 2014

The tests succeed for me no-matter what value I use for the initial tokenSize. Do you have a consistent repro by setting a low initial size?

Please update CHANGELOG (via --amend), too.


throw new Win32Exception(rc);
}
} while ((rc == Secur32.SEC_E_BUFFER_TOO_SMALL) || (rc == Secur32.SEC_E_INSUFFICIENT_MEMORY));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you ever gotten a SEC_E_BUFFER_TOO_SMALL here? It's not a return value from this function. MSDN says that you can only get SEC_E_INSUFFICIENT_MEMORY and the Java Code doesn't check for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can get either error in the second ctor, but I can't remember whether I saw it in the first (probably not, but I'll check again tomorrow).

@kentcb
Copy link
Contributor Author

kentcb commented Jul 29, 2014

Yes I can get a consistent error with a small buffer size (eg. 1000). I am using Kerberos though - are you perhaps using NTLM? And if you debug through, is your token too large to fit in the initial buffer?

@dblock
Copy link
Collaborator

dblock commented Jul 31, 2014

Perfect, merged via 6a8bd45.

@dblock dblock closed this Jul 31, 2014
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.

None yet

2 participants