Ticket #1482: sectionreader_validation2.patch

File sectionreader_validation2.patch, 1023 bytes (added by Janne <janne-mythtv@…>, 18 years ago)
  • libs/libmythtv/dvbsiparser.cpp

     
    293293
    294294                int rsz = read(pollArray[i].fd, &buffer, MAX_SECTION_SIZE);
    295295
    296                 if (rsz > 0)
     296                /* minimal valid DVB section is the TDT of size 8
     297                   validate the size of the buffer against the encoded section_length */
     298                if (rsz >= 8 && (rsz-3 == ((buffer[1] & 0x0f) << 8 | buffer[2])))
    297299                {
    298300                    ParseTable(buffer, rsz,
    299301                               PIDfilterManager[pollArray[i].fd].pid);
     
    301303                    continue;
    302304                }
    303305
     306                if (rsz > 0)
     307                {
     308                    processed = true;
     309                    continue;
     310                }
     311
    304312                if (rsz == -1 && errno == EAGAIN)
    305313                {
    306314                    i--;