diff --git a/src/main/java/com/hierynomus/ntlm/functions/NtlmFunctions.java b/src/main/java/com/hierynomus/ntlm/functions/NtlmFunctions.java index 64c8d806..d9374ffd 100644 --- a/src/main/java/com/hierynomus/ntlm/functions/NtlmFunctions.java +++ b/src/main/java/com/hierynomus/ntlm/functions/NtlmFunctions.java @@ -192,7 +192,9 @@ public byte[] getNTLMv2ClientChallenge(TargetInfo targetInformation) { ccBuf.putLong(nowAsFileTime); // Timestamp (8) ccBuf.putRawBytes(challengeFromClient); // ChallengeFromClient (8) ccBuf.putUInt32(0); // Reserved3 (4) - targetInformation.writeTo(ccBuf); // AvPairs (variable) + if (targetInformation != null) { + targetInformation.writeTo(ccBuf); // AvPairs (variable) + } ccBuf.putUInt32(0); // Last AV Pair indicator return ccBuf.getCompactData(); diff --git a/src/main/java/com/hierynomus/ntlm/messages/NtlmAuthenticate.java b/src/main/java/com/hierynomus/ntlm/messages/NtlmAuthenticate.java index 983be829..e5222f28 100644 --- a/src/main/java/com/hierynomus/ntlm/messages/NtlmAuthenticate.java +++ b/src/main/java/com/hierynomus/ntlm/messages/NtlmAuthenticate.java @@ -124,12 +124,12 @@ public byte[] getVersion() { return plainBuffer.getCompactData(); } - private int writeOffsettedByteArrayFields(Buffer.PlainBuffer buffer, byte[] array, int offset) { - byte[] _array = array != null ? array : EMPTY; - buffer.putUInt16(_array.length); // ArrayLen - buffer.putUInt16(_array.length); // ArrayMaxLen + private int writeOffsettedByteArrayFields(Buffer.PlainBuffer buffer, byte[] bytes, int offset) { + byte[] arr = bytes != null ? bytes : EMPTY; + buffer.putUInt16(arr.length); // ArrayLen + buffer.putUInt16(arr.length); // ArrayMaxLen buffer.putUInt32(offset); // ArrayOffset - return offset + _array.length; + return offset + arr.length; } private byte[] ensureNotNull(byte[] possiblyNull) {