@@ -192,7 +192,10 @@ public static String getDefaultHostIp() {
192192 }
193193
194194 String [] info = NetUtils .getNetworkParams (nic );
195- return info [0 ];
195+ if (info != null ) {
196+ return info [0 ];
197+ }
198+ return null ;
196199 }
197200 }
198201
@@ -489,7 +492,10 @@ public static boolean isSiteLocalAddress(String ipAddress) {
489492 return false ;
490493 } else {
491494 InetAddress ip = parseIpAddress (ipAddress );
492- return ip .isSiteLocalAddress ();
495+ if (ip != null ) {
496+ return ip .isSiteLocalAddress ();
497+ }
498+ return false ;
493499 }
494500 }
495501
@@ -1252,16 +1258,21 @@ public static String getIp6FromRange(String ip6Range) {
12521258 while (next .compareTo (gap ) >= 0 ) {
12531259 next = new BigInteger (gap .bitLength (), s_rand );
12541260 }
1261+ InetAddress resultAddr = null ;
12551262 BigInteger startInt = convertIPv6AddressToBigInteger (start );
1256- BigInteger resultInt = startInt .add (next );
1257- InetAddress resultAddr ;
1258- try {
1259- resultAddr = InetAddress .getByAddress (resultInt .toByteArray ());
1260- } catch (UnknownHostException e ) {
1261- return null ;
1263+ if (startInt != null ) {
1264+ BigInteger resultInt = startInt .add (next );
1265+ try {
1266+ resultAddr = InetAddress .getByAddress (resultInt .toByteArray ());
1267+ } catch (UnknownHostException e ) {
1268+ return null ;
1269+ }
12621270 }
1263- IPv6Address ip = IPv6Address .fromInetAddress (resultAddr );
1264- return ip .toString ();
1271+ if ( resultAddr != null ) {
1272+ IPv6Address ip = IPv6Address .fromInetAddress (resultAddr );
1273+ return ip .toString ();
1274+ }
1275+ return null ;
12651276 }
12661277
12671278 //RFC3315, section 9.4
@@ -1300,8 +1311,10 @@ public static BigInteger countIp6InRange(String ip6Range) {
13001311 }
13011312 BigInteger startInt = convertIPv6AddressToBigInteger (start );
13021313 BigInteger endInt = convertIPv6AddressToBigInteger (end );
1303- if (startInt .compareTo (endInt ) > 0 ) {
1304- return null ;
1314+ if (endInt != null ) {
1315+ if (startInt .compareTo (endInt ) > 0 ) {
1316+ return null ;
1317+ }
13051318 }
13061319 return endInt .subtract (startInt ).add (BigInteger .ONE );
13071320 }
0 commit comments