Menu

#1 OBEX type header not terminated by 0x00 (OBEXConnection)

open
nobody
None
5
2005-04-22
2005-04-22
No

In de.avetana.bluetooth.obex.OBEXConnection in the
method parseHeaders there is a bugfix for that problem.
But this bugfix causes another problem.

case HeaderSetImpl.TYPE:
try {
if (data[offset + len - 1] != 0) len++ // Fix for
implementations that do not end the TYPE Header with a
0-byte
String typeObj = new String (data, offset + 3, len
- 1 - 3, "iso-8859-1");
hs.setHeader(id, typeObj);
break;
} catch (Exception e) { e.printStackTrace(); }
break;

So the "len" gets increased which fixes the bug for the
length of the Type, but this will also cause to loose
the next byte (ID of the next header)!

Proposed fix (working fine):
case HeaderSetImpl.TYPE:
try {
String typeObj = null;
// Fix for implementations that do not end the
TYPE Header with a 0-byte
if (data[offset + len - 1] != 0)
typeObj = new String (data, offset + 3, len - 3,
"iso-8859-1");
else
typeObj = new String (data, offset + 3, len - 1 -
3, "iso-8859-1");
hs.setHeader(id, typeObj);
break;
} catch (Exception e) { e.printStackTrace(); }
break;

Greetings,
Michael Diener

Discussion


Log in to post a comment.

MongoDB Logo MongoDB