<div dir="ltr">Angelo,<br><div><div class="gmail_extra"><br></div><div class="gmail_extra">Again thanks for finding this bug. I checked ITU-T Rec H.222.0 and you are correct. <br>At this point p_section->payload_start points at the beginning of the descriptors for this PSI section.<br>
<br></div><div class="gmail_extra">And adding 5 to the payload start at this point is plain wrong. I would not be surprised if more PSI sections<br>suffer from the same type of bug. Could you please sent a git-patch for each one you come across in your testing?<br>
</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 22, 2013 at 4:11 PM, Angelo Schiavone <span dir="ltr"><<a href="mailto:angelo.schiavone@gmail.com" target="_blank">angelo.schiavone@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<div>CAT decode function doesn't work very well in libpsisi 1.0.0, in fact</div><div>it may skip the last descriptor of the cat descriptor loop, according to its length. <br>
<div>the problem is that red highlighted +5 which is not necessary.</div>
<div><br></div><div><br></div><div><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">void</span><span style="color:rgb(192,192,192)"> </span>dvbpsi_cat_sections_decode(<span style="color:rgb(128,0,128)">dvbpsi_cat_t</span>*<span style="color:rgb(192,192,192)"> </span>p_cat,<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">dvbpsi_psi_section_t</span>*<span style="color:rgb(192,192,192)"> </span>p_section)</pre>

<pre style="margin-top:0px;margin-bottom:0px">{</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span>uint8_t*<span style="color:rgb(192,192,192)"> </span>p_byte;</pre><pre style="margin-top:0px;margin-bottom:0px">
<span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,128,0)">while</span><span style="color:rgb(192,192,192)"> </span>(p_section)</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span>{</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(0,128,0)">/*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">CAT</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">descriptors</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">*/</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span>p_byte<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>p_section->p_payload_start;</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,128,0)">while</span><span style="color:rgb(192,192,192)"> </span>(p_byte<span style="background-color:rgb(255,0,0)"> +5<span style="color:rgb(192,192,192)"> </span></span><=<span style="color:rgb(192,192,192)"> </span>p_section->p_payload_end)</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span>{</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">            </span>uint8_t<span style="color:rgb(192,192,192)"> </span>i_tag<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>p_byte[<span style="color:rgb(0,0,128)">0</span>];</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">            </span>uint8_t<span style="color:rgb(192,192,192)"> </span>i_length<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>p_byte[<span style="color:rgb(0,0,128)">1</span>];</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">            </span><span style="color:rgb(128,128,0)">if</span><span style="color:rgb(192,192,192)"> </span>(i_length<span style="color:rgb(192,192,192)"> </span>+<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">2</span><span style="color:rgb(192,192,192)"> </span><=<span style="color:rgb(192,192,192)"> </span>p_section->p_payload_end<span style="color:rgb(192,192,192)"> </span>-<span style="color:rgb(192,192,192)"> </span>p_byte)</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">                </span>dvbpsi_cat_descriptor_add(p_cat,<span style="color:rgb(192,192,192)"> </span>i_tag,<span style="color:rgb(192,192,192)"> </span>i_length,<span style="color:rgb(192,192,192)"> </span>p_byte<span style="color:rgb(192,192,192)"> </span>+<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">2</span>);</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">            </span>p_byte<span style="color:rgb(192,192,192)"> </span>+=<span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">2</span><span style="color:rgb(192,192,192)"> </span>+<span style="color:rgb(192,192,192)"> </span>i_length;</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span>}</pre><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span>p_section<span style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> </span>p_section->p_next;</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span>}</pre><pre style="margin-top:0px;margin-bottom:0px">}</pre></div></div>
<br>_______________________________________________<br>
libdvbpsi-devel mailing list<br>
<a href="mailto:libdvbpsi-devel@videolan.org">libdvbpsi-devel@videolan.org</a><br>
<a href="http://mailman.videolan.org/listinfo/libdvbpsi-devel" target="_blank">http://mailman.videolan.org/listinfo/libdvbpsi-devel</a><br>
<br></blockquote></div><br></div><div class="gmail_extra">Kind regards,<br><br></div><div class="gmail_extra">Jean-Paul Saman<br></div></div></div>