@@ -6508,7 +6508,7 @@ public override bool ReadObject( out MessagePackObject result )
65086508 }
65096509
65106510 #endregion UnpackRawContent
6511- var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue ) ) ;
6511+ var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue , false ) ) ;
65126512 this . InternalCollectionType = CollectionType . None ;
65136513 result = resultMpoValue ;
65146514 return true ;
@@ -6718,6 +6718,36 @@ public override bool ReadObject( out MessagePackObject result )
67186718 return true ;
67196719 }
67206720 case MessagePackCode . Bin8 :
6721+ {
6722+ byte length ;
6723+ #region UnpackScalar
6724+
6725+ var read = source . Read ( buffer , 0 , 1 ) ;
6726+ if ( read == 1 )
6727+ {
6728+ length = BigEndianBinary . ToByte ( buffer , 0 ) ;
6729+ }
6730+ else
6731+ {
6732+ throw new InvalidMessagePackStreamException ( "Stream unexpectedly ends." ) ;
6733+ }
6734+
6735+ #endregion UnpackScalar
6736+ var resultValue = new byte [ length ] ;
6737+ #region UnpackRawContent
6738+
6739+ var bytesRead = source . Read ( resultValue , 0 , length ) ;
6740+ if ( bytesRead < length )
6741+ {
6742+ throw new InvalidMessagePackStreamException ( "Stream unexpectedly ends." ) ;
6743+ }
6744+
6745+ #endregion UnpackRawContent
6746+ var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue , true ) ) ;
6747+ this . InternalCollectionType = CollectionType . None ;
6748+ result = resultMpoValue ;
6749+ return true ;
6750+ }
67216751 case MessagePackCode . Str8 :
67226752 {
67236753 byte length ;
@@ -6744,12 +6774,42 @@ public override bool ReadObject( out MessagePackObject result )
67446774 }
67456775
67466776 #endregion UnpackRawContent
6747- var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue ) ) ;
6777+ var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue , false ) ) ;
67486778 this . InternalCollectionType = CollectionType . None ;
67496779 result = resultMpoValue ;
67506780 return true ;
67516781 }
67526782 case MessagePackCode . Bin16 :
6783+ {
6784+ ushort length ;
6785+ #region UnpackScalar
6786+
6787+ var read = source . Read ( buffer , 0 , 2 ) ;
6788+ if ( read == 2 )
6789+ {
6790+ length = BigEndianBinary . ToUInt16 ( buffer , 0 ) ;
6791+ }
6792+ else
6793+ {
6794+ throw new InvalidMessagePackStreamException ( "Stream unexpectedly ends." ) ;
6795+ }
6796+
6797+ #endregion UnpackScalar
6798+ var resultValue = new byte [ length ] ;
6799+ #region UnpackRawContent
6800+
6801+ var bytesRead = source . Read ( resultValue , 0 , length ) ;
6802+ if ( bytesRead < length )
6803+ {
6804+ throw new InvalidMessagePackStreamException ( "Stream unexpectedly ends." ) ;
6805+ }
6806+
6807+ #endregion UnpackRawContent
6808+ var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue , true ) ) ;
6809+ this . InternalCollectionType = CollectionType . None ;
6810+ result = resultMpoValue ;
6811+ return true ;
6812+ }
67536813 case MessagePackCode . Raw16 :
67546814 {
67556815 ushort length ;
@@ -6776,12 +6836,48 @@ public override bool ReadObject( out MessagePackObject result )
67766836 }
67776837
67786838 #endregion UnpackRawContent
6779- var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue ) ) ;
6839+ var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue , false ) ) ;
67806840 this . InternalCollectionType = CollectionType . None ;
67816841 result = resultMpoValue ;
67826842 return true ;
67836843 }
67846844 case MessagePackCode . Bin32 :
6845+ {
6846+ uint length ;
6847+ #region UnpackScalar
6848+
6849+ var read = source . Read ( buffer , 0 , 4 ) ;
6850+ if ( read == 4 )
6851+ {
6852+ length = BigEndianBinary . ToUInt32 ( buffer , 0 ) ;
6853+ }
6854+ else
6855+ {
6856+ throw new InvalidMessagePackStreamException ( "Stream unexpectedly ends." ) ;
6857+ }
6858+
6859+ #endregion UnpackScalar
6860+ if ( length > Int32 . MaxValue )
6861+ {
6862+ throw new MessageNotSupportedException ( "MessagePack for CLI cannot handle large binary which has more than Int32.MaxValue bytes." ) ;
6863+ }
6864+
6865+ var size = unchecked ( ( int ) length ) ;
6866+ var resultValue = new byte [ size ] ;
6867+ #region UnpackRawContent
6868+
6869+ var bytesRead = source . Read ( resultValue , 0 , size ) ;
6870+ if ( bytesRead < size )
6871+ {
6872+ throw new InvalidMessagePackStreamException ( "Stream unexpectedly ends." ) ;
6873+ }
6874+
6875+ #endregion UnpackRawContent
6876+ var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue , true ) ) ;
6877+ this . InternalCollectionType = CollectionType . None ;
6878+ result = resultMpoValue ;
6879+ return true ;
6880+ }
67856881 case MessagePackCode . Raw32 :
67866882 {
67876883 uint length ;
@@ -6814,7 +6910,7 @@ public override bool ReadObject( out MessagePackObject result )
68146910 }
68156911
68166912 #endregion UnpackRawContent
6817- var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue ) ) ;
6913+ var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue , false ) ) ;
68186914 this . InternalCollectionType = CollectionType . None ;
68196915 result = resultMpoValue ;
68206916 return true ;
@@ -7255,7 +7351,7 @@ internal bool ReadSubtreeObject( out MessagePackObject result )
72557351 }
72567352
72577353 #endregion UnpackRawContent
7258- var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue ) ) ;
7354+ var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue , false ) ) ;
72597355 this . InternalCollectionType = CollectionType . None ;
72607356 result = resultMpoValue ;
72617357 return true ;
@@ -7465,6 +7561,36 @@ internal bool ReadSubtreeObject( out MessagePackObject result )
74657561 return true ;
74667562 }
74677563 case MessagePackCode . Bin8 :
7564+ {
7565+ byte length ;
7566+ #region UnpackScalar
7567+
7568+ var read = source . Read ( buffer , 0 , 1 ) ;
7569+ if ( read == 1 )
7570+ {
7571+ length = BigEndianBinary . ToByte ( buffer , 0 ) ;
7572+ }
7573+ else
7574+ {
7575+ throw new InvalidMessagePackStreamException ( "Stream unexpectedly ends." ) ;
7576+ }
7577+
7578+ #endregion UnpackScalar
7579+ var resultValue = new byte [ length ] ;
7580+ #region UnpackRawContent
7581+
7582+ var bytesRead = source . Read ( resultValue , 0 , length ) ;
7583+ if ( bytesRead < length )
7584+ {
7585+ throw new InvalidMessagePackStreamException ( "Stream unexpectedly ends." ) ;
7586+ }
7587+
7588+ #endregion UnpackRawContent
7589+ var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue , true ) ) ;
7590+ this . InternalCollectionType = CollectionType . None ;
7591+ result = resultMpoValue ;
7592+ return true ;
7593+ }
74687594 case MessagePackCode . Str8 :
74697595 {
74707596 byte length ;
@@ -7491,12 +7617,42 @@ internal bool ReadSubtreeObject( out MessagePackObject result )
74917617 }
74927618
74937619 #endregion UnpackRawContent
7494- var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue ) ) ;
7620+ var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue , false ) ) ;
74957621 this . InternalCollectionType = CollectionType . None ;
74967622 result = resultMpoValue ;
74977623 return true ;
74987624 }
74997625 case MessagePackCode . Bin16 :
7626+ {
7627+ ushort length ;
7628+ #region UnpackScalar
7629+
7630+ var read = source . Read ( buffer , 0 , 2 ) ;
7631+ if ( read == 2 )
7632+ {
7633+ length = BigEndianBinary . ToUInt16 ( buffer , 0 ) ;
7634+ }
7635+ else
7636+ {
7637+ throw new InvalidMessagePackStreamException ( "Stream unexpectedly ends." ) ;
7638+ }
7639+
7640+ #endregion UnpackScalar
7641+ var resultValue = new byte [ length ] ;
7642+ #region UnpackRawContent
7643+
7644+ var bytesRead = source . Read ( resultValue , 0 , length ) ;
7645+ if ( bytesRead < length )
7646+ {
7647+ throw new InvalidMessagePackStreamException ( "Stream unexpectedly ends." ) ;
7648+ }
7649+
7650+ #endregion UnpackRawContent
7651+ var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue , true ) ) ;
7652+ this . InternalCollectionType = CollectionType . None ;
7653+ result = resultMpoValue ;
7654+ return true ;
7655+ }
75007656 case MessagePackCode . Raw16 :
75017657 {
75027658 ushort length ;
@@ -7523,12 +7679,48 @@ internal bool ReadSubtreeObject( out MessagePackObject result )
75237679 }
75247680
75257681 #endregion UnpackRawContent
7526- var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue ) ) ;
7682+ var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue , false ) ) ;
75277683 this . InternalCollectionType = CollectionType . None ;
75287684 result = resultMpoValue ;
75297685 return true ;
75307686 }
75317687 case MessagePackCode . Bin32 :
7688+ {
7689+ uint length ;
7690+ #region UnpackScalar
7691+
7692+ var read = source . Read ( buffer , 0 , 4 ) ;
7693+ if ( read == 4 )
7694+ {
7695+ length = BigEndianBinary . ToUInt32 ( buffer , 0 ) ;
7696+ }
7697+ else
7698+ {
7699+ throw new InvalidMessagePackStreamException ( "Stream unexpectedly ends." ) ;
7700+ }
7701+
7702+ #endregion UnpackScalar
7703+ if ( length > Int32 . MaxValue )
7704+ {
7705+ throw new MessageNotSupportedException ( "MessagePack for CLI cannot handle large binary which has more than Int32.MaxValue bytes." ) ;
7706+ }
7707+
7708+ var size = unchecked ( ( int ) length ) ;
7709+ var resultValue = new byte [ size ] ;
7710+ #region UnpackRawContent
7711+
7712+ var bytesRead = source . Read ( resultValue , 0 , size ) ;
7713+ if ( bytesRead < size )
7714+ {
7715+ throw new InvalidMessagePackStreamException ( "Stream unexpectedly ends." ) ;
7716+ }
7717+
7718+ #endregion UnpackRawContent
7719+ var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue , true ) ) ;
7720+ this . InternalCollectionType = CollectionType . None ;
7721+ result = resultMpoValue ;
7722+ return true ;
7723+ }
75327724 case MessagePackCode . Raw32 :
75337725 {
75347726 uint length ;
@@ -7561,7 +7753,7 @@ internal bool ReadSubtreeObject( out MessagePackObject result )
75617753 }
75627754
75637755 #endregion UnpackRawContent
7564- var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue ) ) ;
7756+ var resultMpoValue = new MessagePackObject ( new MessagePackString ( resultValue , false ) ) ;
75657757 this . InternalCollectionType = CollectionType . None ;
75667758 result = resultMpoValue ;
75677759 return true ;
0 commit comments