File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
src/com/codebutler/android_websockets Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 3333import android .util .Log ;
3434
3535import java .io .*;
36- import java .math .BigInteger ;
3736import java .util .Arrays ;
3837import java .util .List ;
3938
@@ -327,7 +326,7 @@ private byte[] decode(String string) {
327326 }
328327
329328 private int getInteger (byte [] bytes ) throws ProtocolError {
330- long i = new BigInteger (bytes ). longValue ( );
329+ long i = byteArrayToLong (bytes , 0 , bytes . length );
331330 if (i < 0 || i > Integer .MAX_VALUE ) {
332331 throw new ProtocolError ("Bad integer: " + i );
333332 }
@@ -344,6 +343,18 @@ public ProtocolError(String detailMessage) {
344343 }
345344 }
346345
346+ private static long byteArrayToLong (byte [] b , int offset , int length ) {
347+ if (b .length < length )
348+ throw new IllegalArgumentException ("length must be less than or equal to b.length" );
349+
350+ long value = 0 ;
351+ for (int i = 0 ; i < length ; i ++) {
352+ int shift = (length - 1 - i ) * 8 ;
353+ value += (b [i + offset ] & 0x000000FF ) << shift ;
354+ }
355+ return value ;
356+ }
357+
347358 public static class HappyDataInputStream extends DataInputStream {
348359 public HappyDataInputStream (InputStream in ) {
349360 super (in );
You can’t perform that action at this time.
0 commit comments