Skip to content

Commit

Permalink
HTTPCLIENT-1881: Allow truncated NTLM packets to work with this client.
Browse files Browse the repository at this point in the history
  • Loading branch information
DaddyWri committed Nov 18, 2017
1 parent 235348e commit 4235935
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,15 @@ static String getType3Message(final String user, final char[] password, final St

private static int readULong(final byte[] src, final int index) throws NTLMEngineException {
if (src.length < index + 4) {
throw new NTLMEngineException("NTLM authentication - buffer too small for DWORD");
return 0;
}
return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8)
| ((src[index + 2] & 0xff) << 16) | ((src[index + 3] & 0xff) << 24);
}

private static int readUShort(final byte[] src, final int index) throws NTLMEngineException {
if (src.length < index + 2) {
throw new NTLMEngineException("NTLM authentication - buffer too small for WORD");
return 0;
}
return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8);
}
Expand All @@ -287,8 +287,7 @@ private static byte[] readSecurityBuffer(final byte[] src, final int index) thro
final int length = readUShort(src, index);
final int offset = readULong(src, index + 4);
if (src.length < offset + length) {
throw new NTLMEngineException(
"NTLM authentication - buffer too small for data item");
return new byte[length];
}
final byte[] buffer = new byte[length];
System.arraycopy(src, offset, buffer, 0, length);
Expand Down

0 comments on commit 4235935

Please sign in to comment.