Changeset 693


Ignore:
Timestamp:
11/10/11 23:00:27 (6 months ago)
Author:
shiretu
Message:

-- emergency patch. This address the buffer overruns inside rtmp (de)serializer. Once again, many thanks to Josh Allmann who discovered it
-- prevent going over the maximum value for channels for RTMP protocol

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/1.0/sources/thelib/src/protocols/rtmp/amf0serializer.cpp

    r625 r693  
    6666bool AMF0Serializer::ReadShortString(IOBuffer &buffer, Variant &variant, 
    6767                bool readType) { 
    68  
    6968        if (readType) { 
    7069                AMF_CHECK_BOUNDARIES(buffer, 1); 
    7170                if (GETIBPOINTER(buffer)[0] != AMF0_SHORT_STRING) { 
    72                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     71                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    7372                                        AMF0_SHORT_STRING, GETIBPOINTER(buffer)[0]); 
    7473                        return false; 
     
    9089        variant = string((char *) (GETIBPOINTER(buffer)), length); 
    9190        if (!buffer.Ignore(length)) { 
    92                 FATAL("Unable to ignore %hu bytes", length); 
     91                FATAL("Unable to ignore %"PRIu16" bytes", length); 
    9392                return false; 
    9493        } 
     
    112111                AMF_CHECK_BOUNDARIES(buffer, 1); 
    113112                if (GETIBPOINTER(buffer)[0] != AMF0_LONG_STRING) { 
    114                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     113                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    115114                                        AMF0_LONG_STRING, GETIBPOINTER(buffer)[0]); 
    116115                        return false; 
     
    133132        variant = string((char *) (GETIBPOINTER(buffer)), length); 
    134133        if (!buffer.Ignore(length)) { 
    135                 FATAL("Unable to ignore %u bytes", length); 
     134                FATAL("Unable to ignore %"PRIu32" bytes", length); 
    136135                return false; 
    137136        } 
     
    156155                AMF_CHECK_BOUNDARIES(buffer, 1); 
    157156                if (GETIBPOINTER(buffer)[0] != AMF0_NUMBER) { 
    158                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     157                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    159158                                        AMF0_NUMBER, GETIBPOINTER(buffer)[0]); 
    160159                        return false; 
     
    195194                AMF_CHECK_BOUNDARIES(buffer, 1); 
    196195                if (GETIBPOINTER(buffer)[0] != AMF0_OBJECT) { 
    197                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     196                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    198197                                        AMF0_OBJECT, GETIBPOINTER(buffer)[0]); 
    199198                        return false; 
     
    294293                AMF_CHECK_BOUNDARIES(buffer, 1); 
    295294                if (GETIBPOINTER(buffer)[0] != AMF0_MIXED_ARRAY) { 
    296                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     295                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    297296                                        AMF0_MIXED_ARRAY, GETIBPOINTER(buffer)[0]); 
    298297                        return false; 
     
    404403 
    405404bool AMF0Serializer::ReadArray(IOBuffer &buffer, Variant &variant, bool readType) { 
    406  
    407405        if (readType) { 
    408406                AMF_CHECK_BOUNDARIES(buffer, 1); 
    409407                if (GETIBPOINTER(buffer)[0] != AMF0_ARRAY) { 
    410                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     408                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    411409                                        AMF0_ARRAY, GETIBPOINTER(buffer)[0]); 
    412410                        return false; 
     
    450448                AMF_CHECK_BOUNDARIES(buffer, 1); 
    451449                if (GETIBPOINTER(buffer)[0] != AMF0_AMF3_OBJECT) { 
    452                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     450                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    453451                                        AMF0_AMF3_OBJECT, GETIBPOINTER(buffer)[0]); 
    454452                        return false; 
     
    486484                AMF_CHECK_BOUNDARIES(buffer, 1); 
    487485                if (GETIBPOINTER(buffer)[0] != AMF0_BOOLEAN) { 
    488                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     486                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    489487                                        AMF0_BOOLEAN, GETIBPOINTER(buffer)[0]); 
    490488                        return false; 
     
    524522                AMF_CHECK_BOUNDARIES(buffer, 1); 
    525523                if (GETIBPOINTER(buffer)[0] != AMF0_TIMESTAMP) { 
    526                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     524                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    527525                                        AMF0_TIMESTAMP, GETIBPOINTER(buffer)[0]); 
    528526                        return false; 
     
    538536        if (!ReadDouble(buffer, doubleVariant, false)) { 
    539537                FATAL("Unable to read the value"); 
     538                return false; 
    540539        } 
    541540 
     
    569568        AMF_CHECK_BOUNDARIES(buffer, 1); 
    570569        if (GETIBPOINTER(buffer)[0] != AMF0_NULL) { 
    571                 FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     570                FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    572571                                AMF0_NULL, GETIBPOINTER(buffer)[0]); 
    573572                return false; 
     
    592591        AMF_CHECK_BOUNDARIES(buffer, 1); 
    593592        if (GETIBPOINTER(buffer)[0] != AMF0_UNDEFINED) { 
    594                 FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     593                FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    595594                                AMF0_UNDEFINED, GETIBPOINTER(buffer)[0]); 
    596595                return false; 
     
    728727                default: 
    729728                { 
    730                         FATAL("Unable to de-serialize type %hhu; Buffer: %s", 
     729                        FATAL("Unable to de-serialize type %"PRIu8"; Buffer: %s", 
    731730                                        GETIBPOINTER(buffer)[0], STR(buffer)); 
    732731                        return false; 
  • branches/1.0/sources/thelib/src/protocols/rtmp/basertmpprotocol.cpp

    r650 r693  
    668668                } 
    669669 
     670                if (_selectedChannel >= MAX_CHANNELS_COUNT) { 
     671                        FATAL("Bogus connection. Drop it like is hot"); 
     672                        return false; 
     673                } 
     674 
    670675                Channel &channel = _channels[_selectedChannel]; 
    671676                Header &header = channel.lastInHeader; 
  • branches/1.0/sources/thelib/src/protocols/rtmp/rtmpprotocolserializer.cpp

    r467 r693  
    2121#include "protocols/rtmp/rtmpprotocolserializer.h" 
    2222#include "protocols/rtmp/messagefactories/messagefactories.h" 
     23#include "protocols/rtmp/amftypes.h" 
    2324 
    2425RTMPProtocolSerializer::RTMPProtocolSerializer() { 
    25  
    26  
    2726} 
    2827 
    2928RTMPProtocolSerializer::~RTMPProtocolSerializer() { 
    30  
    3129} 
    3230 
     
    453451                                uint32_t length = buffer.GetCurrentWritePosition() 
    454452                                                - rawLengthPosition - 4; 
    455                                 EHTONLP(buffer.GetPointer() + rawLengthPosition,length); 
     453                                EHTONLP(buffer.GetPointer() + rawLengthPosition, length); 
    456454                                break; 
    457455                        } 
     
    511509 
    512510bool RTMPProtocolSerializer::DeserializeFlexStreamSend(IOBuffer &buffer, Variant &message) { 
    513         if (GETAVAILABLEBYTESCOUNT(buffer) < 1) { 
    514                 FATAL("Incorrect buffer:\n%s", STR(buffer)); 
    515                 return false; 
    516         } 
    517  
     511        AMF_CHECK_BOUNDARIES(buffer, 1); 
    518512        message[RM_FLEXSTREAMSEND_UNKNOWNBYTE] = (uint8_t) GETIBPOINTER(buffer)[0]; 
    519  
    520513        if (!buffer.Ignore(1)) { 
    521514                FATAL("Unable to ignore 1 byte"); 
     
    563556bool RTMPProtocolSerializer::DeserializeAck(IOBuffer &buffer, 
    564557                Variant &message) { 
     558        AMF_CHECK_BOUNDARIES(buffer, 4); 
    565559        message = (uint32_t) ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    566560        return buffer.Ignore(4); 
     
    568562 
    569563bool RTMPProtocolSerializer::DeserializeUsrCtrl(IOBuffer &buffer, Variant &message) { 
     564        AMF_CHECK_BOUNDARIES(buffer, 2); 
    570565        message[RM_USRCTRL_TYPE] = ENTOHSP(GETIBPOINTER(buffer)); //----MARKED-SHORT---- 
    571566        message[RM_USRCTRL_TYPE_STRING] = GetUserCtrlTypeString(message[RM_USRCTRL_TYPE]); 
     
    581576                case RM_USRCTRL_TYPE_STREAM_IS_RECORDED: 
    582577                { 
     578                        AMF_CHECK_BOUNDARIES(buffer, 4); 
    583579                        message[RM_USRCTRL_STREAMID] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    584580                        if (!buffer.Ignore(4)) { 
     
    590586                case RM_USRCTRL_TYPE_STREAM_SET_BUFFER_LENGTH: 
    591587                { 
     588                        AMF_CHECK_BOUNDARIES(buffer, 8); 
    592589                        message[RM_USRCTRL_STREAMID] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    593590                        if (!buffer.Ignore(4)) { 
     
    604601                case RM_USRCTRL_TYPE_PING_REQUEST: 
    605602                { 
     603                        AMF_CHECK_BOUNDARIES(buffer, 4); 
    606604                        message[RM_USRCTRL_PING] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    607605                        if (!buffer.Ignore(4)) { 
     
    613611                case RM_USRCTRL_TYPE_PING_RESPONSE: 
    614612                { 
     613                        AMF_CHECK_BOUNDARIES(buffer, 4); 
    615614                        message[RM_USRCTRL_PONG] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    616615                        if (!buffer.Ignore(4)) { 
     
    623622                case RM_USRCTRL_TYPE_UNKNOWN2: 
    624623                { 
     624                        AMF_CHECK_BOUNDARIES(buffer, 4); 
    625625                        message[RM_USRCTRL_UNKNOWN_U32] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    626626                        if (!buffer.Ignore(4)) { 
     
    641641bool RTMPProtocolSerializer::DeserializeChunkSize(IOBuffer &buffer, 
    642642                Variant &message) { 
     643        AMF_CHECK_BOUNDARIES(buffer, 4); 
    643644        message = (uint32_t) ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    644645        return buffer.Ignore(4); 
     
    646647 
    647648bool RTMPProtocolSerializer::DeserializeWinAckSize(IOBuffer &buffer, Variant &message) { 
     649        AMF_CHECK_BOUNDARIES(buffer, 4); 
    648650        message = (uint32_t) ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    649651        return buffer.Ignore(4); 
     
    651653 
    652654bool RTMPProtocolSerializer::DeserializePeerBW(IOBuffer &buffer, Variant &message) { 
     655        AMF_CHECK_BOUNDARIES(buffer, 4); 
    653656        message[RM_PEERBW_VALUE] = (uint32_t) ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    654657        if (!buffer.Ignore(4)) { 
     
    661664 
    662665bool RTMPProtocolSerializer::DeserializeAbortMessage(IOBuffer &buffer, Variant &message) { 
     666        AMF_CHECK_BOUNDARIES(buffer, 4); 
    663667        message = (uint32_t) ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    664668        if (!buffer.Ignore(4)) { 
     
    671675bool RTMPProtocolSerializer::DeserializeFlexSharedObject(IOBuffer &buffer, 
    672676                Variant &message) { 
     677        AMF_CHECK_BOUNDARIES(buffer, 1); 
    673678        if (GETIBPOINTER(buffer)[0] != 0) { 
    674                 FATAL("Encoding %hhu not supported yet", GETIBPOINTER(buffer)[0]); 
     679                FATAL("Encoding %"PRIu8" not supported yet", GETIBPOINTER(buffer)[0]); 
    675680                return false; 
    676681        } 
     
    706711 
    707712        //4. Skip 4 unknown bytes 
     713        AMF_CHECK_BOUNDARIES(buffer, 4); 
    708714        if (!buffer.Ignore(4)) { 
    709715                FATAL("Unable to ignore 4 bytes"); 
     
    731737                } 
    732738                uint32_t rawLength = primitive[RM_SHAREDOBJECTPRIMITIVE_RAWLENGTH]; 
    733                 if (GETAVAILABLEBYTESCOUNT(buffer) < rawLength) { 
    734                         FATAL("Not enough data to parse a SO primitive"); 
    735                         return false; 
    736                 } 
     739                AMF_CHECK_BOUNDARIES(buffer, rawLength); 
    737740 
    738741                //8. Read the rest of the primitive based on it's type 
  • trunk/sources/thelib/src/protocols/rtmp/amf0serializer.cpp

    r625 r693  
    6666bool AMF0Serializer::ReadShortString(IOBuffer &buffer, Variant &variant, 
    6767                bool readType) { 
    68  
    6968        if (readType) { 
    7069                AMF_CHECK_BOUNDARIES(buffer, 1); 
    7170                if (GETIBPOINTER(buffer)[0] != AMF0_SHORT_STRING) { 
    72                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     71                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    7372                                        AMF0_SHORT_STRING, GETIBPOINTER(buffer)[0]); 
    7473                        return false; 
     
    9089        variant = string((char *) (GETIBPOINTER(buffer)), length); 
    9190        if (!buffer.Ignore(length)) { 
    92                 FATAL("Unable to ignore %hu bytes", length); 
     91                FATAL("Unable to ignore %"PRIu16" bytes", length); 
    9392                return false; 
    9493        } 
     
    112111                AMF_CHECK_BOUNDARIES(buffer, 1); 
    113112                if (GETIBPOINTER(buffer)[0] != AMF0_LONG_STRING) { 
    114                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     113                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    115114                                        AMF0_LONG_STRING, GETIBPOINTER(buffer)[0]); 
    116115                        return false; 
     
    133132        variant = string((char *) (GETIBPOINTER(buffer)), length); 
    134133        if (!buffer.Ignore(length)) { 
    135                 FATAL("Unable to ignore %u bytes", length); 
     134                FATAL("Unable to ignore %"PRIu32" bytes", length); 
    136135                return false; 
    137136        } 
     
    156155                AMF_CHECK_BOUNDARIES(buffer, 1); 
    157156                if (GETIBPOINTER(buffer)[0] != AMF0_NUMBER) { 
    158                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     157                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    159158                                        AMF0_NUMBER, GETIBPOINTER(buffer)[0]); 
    160159                        return false; 
     
    195194                AMF_CHECK_BOUNDARIES(buffer, 1); 
    196195                if (GETIBPOINTER(buffer)[0] != AMF0_OBJECT) { 
    197                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     196                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    198197                                        AMF0_OBJECT, GETIBPOINTER(buffer)[0]); 
    199198                        return false; 
     
    294293                AMF_CHECK_BOUNDARIES(buffer, 1); 
    295294                if (GETIBPOINTER(buffer)[0] != AMF0_MIXED_ARRAY) { 
    296                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     295                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    297296                                        AMF0_MIXED_ARRAY, GETIBPOINTER(buffer)[0]); 
    298297                        return false; 
     
    404403 
    405404bool AMF0Serializer::ReadArray(IOBuffer &buffer, Variant &variant, bool readType) { 
    406  
    407405        if (readType) { 
    408406                AMF_CHECK_BOUNDARIES(buffer, 1); 
    409407                if (GETIBPOINTER(buffer)[0] != AMF0_ARRAY) { 
    410                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     408                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    411409                                        AMF0_ARRAY, GETIBPOINTER(buffer)[0]); 
    412410                        return false; 
     
    450448                AMF_CHECK_BOUNDARIES(buffer, 1); 
    451449                if (GETIBPOINTER(buffer)[0] != AMF0_AMF3_OBJECT) { 
    452                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     450                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    453451                                        AMF0_AMF3_OBJECT, GETIBPOINTER(buffer)[0]); 
    454452                        return false; 
     
    486484                AMF_CHECK_BOUNDARIES(buffer, 1); 
    487485                if (GETIBPOINTER(buffer)[0] != AMF0_BOOLEAN) { 
    488                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     486                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    489487                                        AMF0_BOOLEAN, GETIBPOINTER(buffer)[0]); 
    490488                        return false; 
     
    524522                AMF_CHECK_BOUNDARIES(buffer, 1); 
    525523                if (GETIBPOINTER(buffer)[0] != AMF0_TIMESTAMP) { 
    526                         FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     524                        FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    527525                                        AMF0_TIMESTAMP, GETIBPOINTER(buffer)[0]); 
    528526                        return false; 
     
    538536        if (!ReadDouble(buffer, doubleVariant, false)) { 
    539537                FATAL("Unable to read the value"); 
     538                return false; 
    540539        } 
    541540 
     
    569568        AMF_CHECK_BOUNDARIES(buffer, 1); 
    570569        if (GETIBPOINTER(buffer)[0] != AMF0_NULL) { 
    571                 FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     570                FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    572571                                AMF0_NULL, GETIBPOINTER(buffer)[0]); 
    573572                return false; 
     
    592591        AMF_CHECK_BOUNDARIES(buffer, 1); 
    593592        if (GETIBPOINTER(buffer)[0] != AMF0_UNDEFINED) { 
    594                 FATAL("AMF type not valid: want: %hhu; got: %hhu", 
     593                FATAL("AMF type not valid: want: %"PRIu8"; got: %"PRIu8, 
    595594                                AMF0_UNDEFINED, GETIBPOINTER(buffer)[0]); 
    596595                return false; 
     
    728727                default: 
    729728                { 
    730                         FATAL("Unable to de-serialize type %hhu; Buffer: %s", 
     729                        FATAL("Unable to de-serialize type %"PRIu8"; Buffer: %s", 
    731730                                        GETIBPOINTER(buffer)[0], STR(buffer)); 
    732731                        return false; 
  • trunk/sources/thelib/src/protocols/rtmp/basertmpprotocol.cpp

    r650 r693  
    668668                } 
    669669 
     670                if (_selectedChannel >= MAX_CHANNELS_COUNT) { 
     671                        FATAL("Bogus connection. Drop it like is hot"); 
     672                        return false; 
     673                } 
     674 
    670675                Channel &channel = _channels[_selectedChannel]; 
    671676                Header &header = channel.lastInHeader; 
  • trunk/sources/thelib/src/protocols/rtmp/rtmpprotocolserializer.cpp

    r467 r693  
    2121#include "protocols/rtmp/rtmpprotocolserializer.h" 
    2222#include "protocols/rtmp/messagefactories/messagefactories.h" 
     23#include "protocols/rtmp/amftypes.h" 
    2324 
    2425RTMPProtocolSerializer::RTMPProtocolSerializer() { 
    25  
    26  
    2726} 
    2827 
    2928RTMPProtocolSerializer::~RTMPProtocolSerializer() { 
    30  
    3129} 
    3230 
     
    453451                                uint32_t length = buffer.GetCurrentWritePosition() 
    454452                                                - rawLengthPosition - 4; 
    455                                 EHTONLP(buffer.GetPointer() + rawLengthPosition,length); 
     453                                EHTONLP(buffer.GetPointer() + rawLengthPosition, length); 
    456454                                break; 
    457455                        } 
     
    511509 
    512510bool RTMPProtocolSerializer::DeserializeFlexStreamSend(IOBuffer &buffer, Variant &message) { 
    513         if (GETAVAILABLEBYTESCOUNT(buffer) < 1) { 
    514                 FATAL("Incorrect buffer:\n%s", STR(buffer)); 
    515                 return false; 
    516         } 
    517  
     511        AMF_CHECK_BOUNDARIES(buffer, 1); 
    518512        message[RM_FLEXSTREAMSEND_UNKNOWNBYTE] = (uint8_t) GETIBPOINTER(buffer)[0]; 
    519  
    520513        if (!buffer.Ignore(1)) { 
    521514                FATAL("Unable to ignore 1 byte"); 
     
    563556bool RTMPProtocolSerializer::DeserializeAck(IOBuffer &buffer, 
    564557                Variant &message) { 
     558        AMF_CHECK_BOUNDARIES(buffer, 4); 
    565559        message = (uint32_t) ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    566560        return buffer.Ignore(4); 
     
    568562 
    569563bool RTMPProtocolSerializer::DeserializeUsrCtrl(IOBuffer &buffer, Variant &message) { 
     564        AMF_CHECK_BOUNDARIES(buffer, 2); 
    570565        message[RM_USRCTRL_TYPE] = ENTOHSP(GETIBPOINTER(buffer)); //----MARKED-SHORT---- 
    571566        message[RM_USRCTRL_TYPE_STRING] = GetUserCtrlTypeString(message[RM_USRCTRL_TYPE]); 
     
    581576                case RM_USRCTRL_TYPE_STREAM_IS_RECORDED: 
    582577                { 
     578                        AMF_CHECK_BOUNDARIES(buffer, 4); 
    583579                        message[RM_USRCTRL_STREAMID] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    584580                        if (!buffer.Ignore(4)) { 
     
    590586                case RM_USRCTRL_TYPE_STREAM_SET_BUFFER_LENGTH: 
    591587                { 
     588                        AMF_CHECK_BOUNDARIES(buffer, 8); 
    592589                        message[RM_USRCTRL_STREAMID] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    593590                        if (!buffer.Ignore(4)) { 
     
    604601                case RM_USRCTRL_TYPE_PING_REQUEST: 
    605602                { 
     603                        AMF_CHECK_BOUNDARIES(buffer, 4); 
    606604                        message[RM_USRCTRL_PING] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    607605                        if (!buffer.Ignore(4)) { 
     
    613611                case RM_USRCTRL_TYPE_PING_RESPONSE: 
    614612                { 
     613                        AMF_CHECK_BOUNDARIES(buffer, 4); 
    615614                        message[RM_USRCTRL_PONG] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    616615                        if (!buffer.Ignore(4)) { 
     
    623622                case RM_USRCTRL_TYPE_UNKNOWN2: 
    624623                { 
     624                        AMF_CHECK_BOUNDARIES(buffer, 4); 
    625625                        message[RM_USRCTRL_UNKNOWN_U32] = ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    626626                        if (!buffer.Ignore(4)) { 
     
    641641bool RTMPProtocolSerializer::DeserializeChunkSize(IOBuffer &buffer, 
    642642                Variant &message) { 
     643        AMF_CHECK_BOUNDARIES(buffer, 4); 
    643644        message = (uint32_t) ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    644645        return buffer.Ignore(4); 
     
    646647 
    647648bool RTMPProtocolSerializer::DeserializeWinAckSize(IOBuffer &buffer, Variant &message) { 
     649        AMF_CHECK_BOUNDARIES(buffer, 4); 
    648650        message = (uint32_t) ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    649651        return buffer.Ignore(4); 
     
    651653 
    652654bool RTMPProtocolSerializer::DeserializePeerBW(IOBuffer &buffer, Variant &message) { 
     655        AMF_CHECK_BOUNDARIES(buffer, 4); 
    653656        message[RM_PEERBW_VALUE] = (uint32_t) ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    654657        if (!buffer.Ignore(4)) { 
     
    661664 
    662665bool RTMPProtocolSerializer::DeserializeAbortMessage(IOBuffer &buffer, Variant &message) { 
     666        AMF_CHECK_BOUNDARIES(buffer, 4); 
    663667        message = (uint32_t) ENTOHLP(GETIBPOINTER(buffer)); //----MARKED-LONG--- 
    664668        if (!buffer.Ignore(4)) { 
     
    671675bool RTMPProtocolSerializer::DeserializeFlexSharedObject(IOBuffer &buffer, 
    672676                Variant &message) { 
     677        AMF_CHECK_BOUNDARIES(buffer, 1); 
    673678        if (GETIBPOINTER(buffer)[0] != 0) { 
    674                 FATAL("Encoding %hhu not supported yet", GETIBPOINTER(buffer)[0]); 
     679                FATAL("Encoding %"PRIu8" not supported yet", GETIBPOINTER(buffer)[0]); 
    675680                return false; 
    676681        } 
     
    706711 
    707712        //4. Skip 4 unknown bytes 
     713        AMF_CHECK_BOUNDARIES(buffer, 4); 
    708714        if (!buffer.Ignore(4)) { 
    709715                FATAL("Unable to ignore 4 bytes"); 
     
    731737                } 
    732738                uint32_t rawLength = primitive[RM_SHAREDOBJECTPRIMITIVE_RAWLENGTH]; 
    733                 if (GETAVAILABLEBYTESCOUNT(buffer) < rawLength) { 
    734                         FATAL("Not enough data to parse a SO primitive"); 
    735                         return false; 
    736                 } 
     739                AMF_CHECK_BOUNDARIES(buffer, rawLength); 
    737740 
    738741                //8. Read the rest of the primitive based on it's type 
Note: See TracChangeset for help on using the changeset viewer.