changeset 6415:cce9ada9668b

8007761: NTLM coding errors Reviewed-by: chegar
author weijun
date Fri, 08 Feb 2013 08:56:52 +0800
parents 665c9df34263
children a724ea5862a7
files src/share/classes/com/sun/security/ntlm/Client.java src/share/classes/com/sun/security/ntlm/NTLM.java
diffstat 2 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/security/ntlm/Client.java	Tue Feb 12 12:57:38 2013 +0000
+++ b/src/share/classes/com/sun/security/ntlm/Client.java	Fri Feb 08 08:56:52 2013 +0800
@@ -138,8 +138,7 @@
             domain = domainFromServer;
         }
         if (domain == null) {
-            throw new NTLMException(NTLMException.NO_DOMAIN_INFO,
-                    "No domain info");
+            domain = "";
         }
 
         int flags = 0x88200 | (inputFlags & 3);
--- a/src/share/classes/com/sun/security/ntlm/NTLM.java	Tue Feb 12 12:57:38 2013 +0000
+++ b/src/share/classes/com/sun/security/ntlm/NTLM.java	Fri Feb 08 08:56:52 2013 +0800
@@ -135,10 +135,10 @@
 
         int readInt(int offset) throws NTLMException {
             try {
-                return internal[offset] & 0xff +
-                        (internal[offset+1] & 0xff << 8) +
-                        (internal[offset+2] & 0xff << 16) +
-                        (internal[offset+3] & 0xff << 24);
+                return (internal[offset] & 0xff) +
+                        ((internal[offset+1] & 0xff) << 8) +
+                        ((internal[offset+2] & 0xff) << 16) +
+                        ((internal[offset+3] & 0xff) << 24);
             } catch (ArrayIndexOutOfBoundsException ex) {
                 throw new NTLMException(NTLMException.PACKET_READ_ERROR,
                         "Input message incorrect size");
@@ -147,8 +147,8 @@
 
         int readShort(int offset) throws NTLMException {
             try {
-                return internal[offset] & 0xff +
-                        (internal[offset+1] & 0xff << 8);
+                return (internal[offset] & 0xff) +
+                        ((internal[offset+1] & 0xff << 8));
             } catch (ArrayIndexOutOfBoundsException ex) {
                 throw new NTLMException(NTLMException.PACKET_READ_ERROR,
                         "Input message incorrect size");