lib/net/ssh/kerberos/drivers/sspi.rb in net-ssh-kerberos-0.2.4 vs lib/net/ssh/kerberos/drivers/sspi.rb in net-ssh-kerberos-0.2.5
- old
+ new
@@ -60,11 +60,11 @@
SecHandle = struct2([ "ULONG lower", "ULONG upper" ]) do def nil?; lower.zero? && upper.zero? end end
typealias "PSecHandle", "P"
typealias "PCredHandle", "PSecHandle"
typealias "PCtxtHandle", "PSecHandle"
SecBuffer = struct2 [ "ULONG length", "ULONG type", "PCharBuffer data" ] do
- def to_s; data.to_s(length) end
+ def to_s; length.zero? ? '' : data.to_s(length) end
end
typealias "PSecBuffer", "P"
SecBufferDesc = struct2 [ "ULONG version", "ULONG count", "PSecBuffer buffers" ] do
def buffer(n) SecBuffer.new(@ptr[:buffers] + SecBuffer.size * n) end
end
@@ -162,10 +162,11 @@
ISC_REQ_DELEGATE | ISC_REQ_MUTUAL_AUTH | ISC_REQ_INTEGRITY, 0,
SECURITY_NATIVE_DREP, input, 0, ctx, output, 0, ts=API::TimeStamp.malloc
result.failure? and raise GeneralError, "Error initializing security context: #{result}"
result = API.completeAuthToken ctx, output if result.incomplete?
result.failure? and raise GeneralError, "Error initializing security context: #{result}"
- @state = State.new(ctx, result, output.buffers ? output.buffer(0).to_s : nil, ts)
+ bdata = output.buffer(0).to_s if output.buffers and output.count > 0 and output.buffer(0)
+ @state = State.new(ctx, result, bdata, ts)
if result.complete?
result = API.queryContextAttributes @state.handle, SECPKG_ATTR_SIZES, @sizes=API::SecPkgSizes.malloc
result.failure? and raise GeneralError, "Error initializing security context: #{result}"
@handle = @state.handle
end