According to specification bits from the first octet and bit 8 from the second octet...
authorPawel Jakub Dawidek <pawel@dawidek.net>
Thu, 2 Feb 2012 20:48:56 +0000 (21:48 +0100)
committerPawel Jakub Dawidek <pawel@dawidek.net>
Thu, 2 Feb 2012 21:46:23 +0000 (22:46 +0100)
Before that change integer >= 0xFF80 was encoded into two bytes instead of three.
While here also add support for encoding integers into three bytes.

libfreerdp-core/ber.c

index 3cd611c..86b69f5 100644 (file)
@@ -383,12 +383,19 @@ int ber_write_integer(STREAM* s, uint32 value)
                stream_write_uint8(s, value);
                return 2;
        }
-       else if (value <= 0xFFFF)
+       else if (value < 0xFF80)
        {
                ber_write_length(s, 2);
                stream_write_uint16_be(s, value);
                return 3;
        }
+       else if (value < 0xFF8000)
+       {
+               ber_write_length(s, 3);
+               stream_write_uint8(s, (value >> 16));
+               stream_write_uint16_be(s, (value & 0xFFFF));
+               return 4;
+       }
        else if (value <= 0xFFFFFFFF)
        {
                ber_write_length(s, 4);