Skip to content

Commit

Permalink
fix decode Type string (Encoding and length)
Browse files Browse the repository at this point in the history
  • Loading branch information
FREEWING-JP committed Mar 28, 2018
1 parent d86c958 commit 786265b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions InTheHand.Net.Personal/Net/ObexParser.cs
Expand Up @@ -81,6 +81,28 @@ internal static void ParseHeaders(byte[] packet, bool isConnectPacket, ref ushor
pos += bodySize;
break;

case ObexHeader.Type:
int typeSize = IPAddress.NetworkToHostOrder(BitConverter.ToInt16(packet, pos + 1));
if (typeSize > 3)
{
string typeString = System.Text.Encoding.ASCII.GetString(packet, pos + 3, typeSize - 4);
if (typeString != null)
{
int nullindex = typeString.IndexOf('\0');
if (nullindex > -1)
{
typeString = typeString.Substring(0, nullindex);
}

if (typeString != string.Empty)
{
headers.Add(header.ToString().ToUpper(), typeString);
}
}
}
pos += typeSize;
break;

default:
int headerSize = IPAddress.NetworkToHostOrder(BitConverter.ToInt16(packet, pos + 1));

Expand Down

0 comments on commit 786265b

Please sign in to comment.