[libdvbpsi-devel] TOT decode - bug

Angelo Schiavone angelo.schiavone at gmail.com
Tue Jan 22 17:03:46 CET 2013


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;

            }

        }

    }

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/libdvbpsi-devel/attachments/20130122/a59c3108/attachment-0001.html>


More information about the libdvbpsi-devel mailing list