TOT decode - bug

Angelo Schiavone <[email protected]>
Newsgroups gmane.comp.video.videolan.libdvbpsi.devel
Message-ID <CADyCdYczfN8Yt43EGoRqOj9cPXPj-RscwU1uKAVR4sz+MAstnw@mail.gmail.com>
Hi again, TOT table does not decode correctly, it miss descriptors in the
descriptors loop.
That's because  p_byte += 7; is incremented after p_end is calculated

p_end = p_byte + (   ((uint16_t)(p_section->p_payload_start[5] & 0x0f) << 8)

                                 | p_section->p_payload_start[6]);


Instead it should happen before p_end assignment, attached the correct version.


void dvbpsi_tot_sections_decode(dvbpsi_t* p_dvbpsi, dvbpsi_tot_t* p_tot,

                              dvbpsi_psi_section_t* p_section)

{

    if (p_section)

    {

        uint8_t* p_byte;

         if (!dvbpsi_tot_section_valid(p_dvbpsi, p_section))

            return;

         p_byte = p_section->p_payload_start;

        if (p_byte + 5 <= p_section->p_payload_end)

        {

            p_tot->i_utc_time = ((uint64_t)p_byte[0] << 32) |

                                ((uint64_t)p_byte[1] << 24) |

                                ((uint64_t)p_byte[2] << 16) |

                                ((uint64_t)p_byte[3] << 8) |

                                 (uint64_t)p_byte[4];

        }

         /* If we have a TOT, extract the descriptors */

        if (p_section->i_table_id == 0x73)

        {

            uint8_t* p_end;

            p_byte += 7;

            p_end = p_byte + (
((uint16_t)(p_section->p_payload_start[5] & 0x0f) << 8)

                                 | p_section->p_payload_start[6]);

            while (p_byte+2 <= p_end)

            {

                uint8_t i_tag = p_byte[0];

                uint8_t i_length = p_byte[1];

                if (i_length + 2 <= p_section->p_payload_end - p_byte)

                    dvbpsi_tot_descriptor_add(p_tot, i_tag, i_length,
p_byte + 2);

                p_byte += 2 + i_length;

            }

        }

    }

}

_______________________________________________
libdvbpsi-devel mailing list
[email protected]
http://mailman.videolan.org/listinfo/libdvbpsi-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.