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

Temporary fixes for failed segment and forgotten min_stat exception #29

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/gssapi/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ def initialize(maj_stat = nil, min_stat = nil)

if(maj_stat.nil? && min_stat.nil?)
@s = '(no error info)'
elsif (min_stat.nil?)
min = FFI::MemoryPointer.new :OM_uint32
message_context = FFI::MemoryPointer.new :OM_uint32
@s = ''
oid = GssOID.gss_c_no_oid
message_context.write_int 0
begin
out_buff = ManagedGssBufferDesc.new
maj = gss_display_status(min, maj_stat, GSS_C_GSS_CODE, oid, message_context, out_buff.pointer)
if (maj != 0)
@s += "failed to retrieve GSSAPI display for status #{maj_stat}"
@s += " of major status #{maj_stat}\n"
@s += "(with major status #{maj}, minor status #{min.read_uint32}\n"
break
end
@s += out_buff.value.to_s + "\n"
end while message_context.read_int != 0
else
min = FFI::MemoryPointer.new :OM_uint32
message_context = FFI::MemoryPointer.new :OM_uint32
Expand Down
2 changes: 1 addition & 1 deletion lib/gssapi/lib_gssapi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def self.release_ptr(name_ptr)
class GssCtxIdT < GssPointer
def self.release_ptr(context_ptr)
min_stat = FFI::MemoryPointer.new :OM_uint32
maj_stat = LibGSSAPI.gss_delete_sec_context(min_stat, context_ptr, LibGSSAPI::GSS_C_NO_BUFFER)
Copy link
Author

Choose a reason for hiding this comment

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

Suspecting that C implementation has been already clean up memory. So, In here it's called again and failing with segmentation.

# maj_stat = LibGSSAPI.gss_delete_sec_context(min_stat, context_ptr, LibGSSAPI::GSS_C_NO_BUFFER)
end

def self.gss_c_no_context
Expand Down
2 changes: 1 addition & 1 deletion lib/gssapi/simple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def unwrap_message(msg, encrypted = true)
# @param [String] keytab the path to the keytab
def set_keytab(keytab)
maj_stat = LibGSSAPI.krb5_gss_register_acceptor_identity(keytab)
raise GssApiError.new(maj_stat, min_stat), "krb5_gss_register_acceptor_identity did not return GSS_S_COMPLETE" if maj_stat != 0
Copy link
Author

Choose a reason for hiding this comment

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

min_stat will be nil in here, but still, it's trying to get some status from here.

Copy link
Author

@Zogoo Zogoo Nov 25, 2020

Choose a reason for hiding this comment

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

@zenchild in this method there is no min_stat defined in here right? Any explanation that why you use undefined min_stat in here?

Copy link
Owner

Choose a reason for hiding this comment

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

Hmmm, that looks like an oversight. There are a few things implemented in this library that I haven't used. I was coding most of it from documentation. 😄 I'll create a new issue to look into it.

Copy link
Owner

Choose a reason for hiding this comment

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

So I looked at the MIT source and this PR should fix the issue (#33 ). I'll push to a new gem soon.

raise GssApiError.new(maj_stat), "krb5_gss_register_acceptor_identity did not return GSS_S_COMPLETE" if maj_stat != 0
true
end

Expand Down