Merge "OBEX : Handle Negative index Exception"
This commit is contained in:
@@ -80,6 +80,9 @@ public final class ObexHelper {
|
|||||||
// The minimum allowed max packet size is 255 according to the OBEX specification
|
// The minimum allowed max packet size is 255 according to the OBEX specification
|
||||||
public static final int LOWER_LIMIT_MAX_PACKET_SIZE = 255;
|
public static final int LOWER_LIMIT_MAX_PACKET_SIZE = 255;
|
||||||
|
|
||||||
|
// The length of OBEX Byte Sequency Header Id according to the OBEX specification
|
||||||
|
public static final int OBEX_BYTE_SEQ_HEADER_LEN = 0x03;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Temporary workaround to be able to push files to Windows 7.
|
* Temporary workaround to be able to push files to Windows 7.
|
||||||
* TODO: Should be removed as soon as Microsoft updates their driver.
|
* TODO: Should be removed as soon as Microsoft updates their driver.
|
||||||
@@ -205,12 +208,15 @@ public final class ObexHelper {
|
|||||||
case 0x40:
|
case 0x40:
|
||||||
boolean trimTail = true;
|
boolean trimTail = true;
|
||||||
index++;
|
index++;
|
||||||
length = 0xFF & headerArray[index];
|
length = ((0xFF & headerArray[index]) << 8) +
|
||||||
length = length << 8;
|
(0xFF & headerArray[index + 1]);
|
||||||
index++;
|
index += 2;
|
||||||
length += 0xFF & headerArray[index];
|
if (length <= OBEX_BYTE_SEQ_HEADER_LEN) {
|
||||||
length -= 3;
|
Log.e(TAG, "Remote sent an OBEX packet with " +
|
||||||
index++;
|
"incorrect header length = " + length);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
length -= OBEX_BYTE_SEQ_HEADER_LEN;
|
||||||
value = new byte[length];
|
value = new byte[length];
|
||||||
System.arraycopy(headerArray, index, value, 0, length);
|
System.arraycopy(headerArray, index, value, 0, length);
|
||||||
if (length == 0 || (length > 0 && (value[length - 1] != 0))) {
|
if (length == 0 || (length > 0 && (value[length - 1] != 0))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user