Bug 58261 - TcpBinaryFrameManager.MyBinaryWriter::GetSizeOfLength - Wrongly returns size of 7BitEncoder Int.
Summary: TcpBinaryFrameManager.MyBinaryWriter::GetSizeOfLength - Wrongly returns size ...
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-07-19 22:36 UTC by Tom Hindle
Modified: 2017-09-06 16:55 UTC (History)
1 user (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Tom Hindle 2017-07-19 22:36:55 UTC
TcpBinaryFrameManager.MyBinaryWriter::GetSizeOfLength - Wrong reads size of 7BitEncoder Init.


For Example:

MyBinaryWritter::GetSizeOfLength(210);

Actual Output: 1
Expected Output: 2

This bug breaks, at the very least, WCF with NetBindingTcp, using DataContractSerializer (not XmlSerializer)

Leads to error messages like (on .net clients):

System.ServiceModel.CommunicationException: Error in deserializing body of reply message for operation 'Sync'. Unexpected end of file. Following elements are not closed: Envelope. ---> System.Xml.XmlException: Unexpected end of file. Following elements are not closed: Envelope.


Suggested Patch:

diff -r 57e47df5b9f6 -r f373d5a934c0 System.ServiceModel/System.ServiceModel.Channels.NetTcp/TcpBinaryFrameManager.cs
--- a/System.ServiceModel/System.ServiceModel.Channels.NetTcp/TcpBinaryFrameManager.cs	Tue Jul 18 13:13:46 2017 -0600
+++ b/System.ServiceModel/System.ServiceModel.Channels.NetTcp/TcpBinaryFrameManager.cs	Wed Jul 19 16:29:21 2017 -0600
@@ -68,17 +68,17 @@ namespace System.ServiceModel.Channels.N
 			{
 				Write7BitEncodedInt (value);
 			}
 
 			public int GetSizeOfLength (int value)
 			{
 				int x = 0;
 				do {
-					value /= 0x100;
+					value /= 0x7f;
 					x++;
 				} while (value != 0);
 				return x;
 			}
 		}
 
 		class MyXmlBinaryWriterSession : XmlBinaryWriterSession
 		{
Comment 1 Tom Hindle 2017-07-19 22:44:23 UTC
Actually thinking about it:

prolly should be:

-					value /= 0x100;
+					value /= 0x80;

As MyBinaryWritter::GetSizeOfLength(127);

Should return 1

And As MyBinaryWritter::GetSizeOfLength(128);

Should return 2.

Note You need to log in before you can comment on or make changes to this bug.