Selaa lähdekoodia

NPE fix and wrong byte to int conversions

Julian 16 vuotta sitten
vanhempi
sitoutus
51a33b1b9d
1 muutettua tiedostoa jossa 4 lisäystä ja 3 poistoa
  1. 4 3
      L2_GameServer/java/net/sf/l2j/util/Util.java

+ 4 - 3
L2_GameServer/java/net/sf/l2j/util/Util.java

@@ -38,12 +38,13 @@ public class Util
 		try
 		{
 			addr = java.net.InetAddress.getByName(ipAddress);
+			return addr.isSiteLocalAddress() || addr.isLoopbackAddress();
 		}
 		catch (UnknownHostException e)
 		{
 			e.printStackTrace();
 		}
-		return addr.isSiteLocalAddress() || addr.isLoopbackAddress();
+		return false;
 	}
 	
 	public static String printData(byte[] data, int len)
@@ -68,7 +69,7 @@ public class Util
 				int charpoint = i - 15;
 				for (int a = 0; a < 16; a++)
 				{
-					int t1 = data[charpoint++];
+					int t1 = 0xFF & data[charpoint++];
 					if (t1 > 0x1f && t1 < 0x80)
 					{
 						result.append((char) t1);
@@ -95,7 +96,7 @@ public class Util
 			int charpoint = data.length - rest;
 			for (int a = 0; a < rest; a++)
 			{
-				int t1 = data[charpoint++];
+				int t1 = 0xFF & data[charpoint++];
 				if (t1 > 0x1f && t1 < 0x80)
 				{
 					result.append((char) t1);