Re: Section CRC not being checked
Jean-Paul Saman <[email protected]>
| Newsgroups | gmane.comp.video.videolan.libdvbpsi.devel |
|---|---|
| Message-ID | <CAK9US3ANi9tBhfv7tS9vkMOp3kCPQbFZwA_PsV=tSXS2HOGSGw@mail.gmail.com> |
Brad, On Wed, Oct 2, 2013 at 5:27 PM, Brad Bitterman <[email protected]> wrote: > We were testing libdvbpsi 1.1.0 with an ATSC tuner and found that we were > getting corrupted data sometimes for the VCT. After looking at the code we > found that the CRC was not being checked. > > In the function dvbpsi_packet_push around line 400 the boolean variable is > declared and initialized by calling dvbpsi_has_crc( p_section ). This > function uses p_section->b_syntax_indicator to check to see if the CRC > should be validated. The p_section->b_syntax_indicator is not initialized > until a few lines down. This cause the CRC to never be check. > > I moved the call to dvbpsi_has_crc down after b_syntax_indicator gets > initialized and I now see the CRC check happening. Is this correct or is > there a reason that the code is the way it is? > Good catch it is indeed a bug. Could you try attached patch? Kind regards, Jean-Paul Saman _______________________________________________ libdvbpsi-devel mailing list [email protected] https://mailman.videolan.org/listinfo/libdvbpsi-devel
0001-src-dvbpsi.c-b_syntax_indicator-and-i_table_id-were-.patch
(application/octet-stream, 1.6 KB)
From 00af91a247bc7d1fc0246fd141c2c323c983594c Mon Sep 17 00:00:00 2001 From: Jean-Paul Saman <[email protected]> Date: Wed, 2 Oct 2013 18:41:49 +0200 Subject: [PATCH] src/dvbpsi.c: b_syntax_indicator and i_table_id were used before being initialized. --- src/dvbpsi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dvbpsi.c b/src/dvbpsi.c index 4d27720..a94bd5c 100644 --- a/src/dvbpsi.c +++ b/src/dvbpsi.c @@ -404,13 +404,15 @@ bool dvbpsi_packet_push(dvbpsi_t *p_dvbpsi, uint8_t* p_data) else { bool b_valid_crc32 = false; - bool has_crc32 = dvbpsi_has_CRC32(p_section); + bool has_crc32; /* PSI section is complete */ + p_section->i_table_id = p_section->p_data[0]; p_section->b_syntax_indicator = p_section->p_data[1] & 0x80; p_section->b_private_indicator = p_section->p_data[1] & 0x40; /* Update the end of the payload if CRC_32 is present */ + has_crc32 = dvbpsi_has_CRC32(p_section); if (p_section->b_syntax_indicator || has_crc32) p_section->p_payload_end -= 4; @@ -421,7 +423,6 @@ bool dvbpsi_packet_push(dvbpsi_t *p_dvbpsi, uint8_t* p_data) if (!has_crc32 || b_valid_crc32) { /* PSI section is valid */ - p_section->i_table_id = p_section->p_data[0]; if (p_section->b_syntax_indicator) { p_section->i_extension = (p_section->p_data[3] << 8) -- 1.8.1.4