From 786265b24eb54f87cabd432f322501c40bbe28e7 Mon Sep 17 00:00:00 2001 From: "FREEWING.JP" Date: Wed, 28 Mar 2018 20:50:34 +0900 Subject: [PATCH] fix decode Type string (Encoding and length) --- InTheHand.Net.Personal/Net/ObexParser.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/InTheHand.Net.Personal/Net/ObexParser.cs b/InTheHand.Net.Personal/Net/ObexParser.cs index c9da249..a3d8b44 100644 --- a/InTheHand.Net.Personal/Net/ObexParser.cs +++ b/InTheHand.Net.Personal/Net/ObexParser.cs @@ -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));