libdvbv5/dvb-scan: Remove dead code and add a check after realloc()

As reported by Coverity scan, the code just before the .init
if check warrants that tbl is always filled. So, checking it again
makes no sense. However, it makes sense to check after calling
realloc().

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
libdvbv5: don't use realloc() inside pat.c

The usage of realloc() inside pat is wrong, as the newly reallocated
data could have a different address, and this is not returned back
to dvb-scan's dvb_read_section_with_id().

While we could do some other tricks to pass the new pointer back,
the entire logic is really not good. Also, the PAT handler uses a
different model than the other tables.

So, change it to use a linked list for the programs. This can, however,
break the API for other applications using it.

Fortunately, the dvb_pat_program_foreach() macro abstracts this
API difference, so, the breakage will not actually happen, if the
other apps use this macro (with is the case of tvdaemon).

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
dvbv5-scan: fix detection of duplicated freqs at the input file

As reported by Coverity, the dvb_scan_handler is always null on
that point. Just removing its check is enough to fix the issue.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
libdvbv5: fix error condition on ATSC service location descriptor

It should return if an error occur.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
libdvbv5: fix error condition on ISDBT delivery descriptor

It should return if an error occur.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
libdvbv5: Fix other error conditions for out of memory

As Coverity points, there are other places where this error also occurs.

Fix all of them.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
dvb5-zap: Better handle the MPEG TS header

The code is now a little more elegant and easier to read.

No functional changes.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
libdvbv5/dvb-scan: all tables should have an specified size

If a table has a zero size, reject it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
libdvbv5: pack NIT table

As all tables, this one should be packed.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
libdvbv5: fix other error conditions for out of memory

As Coverity points, there are other places where this error also occurs.

Fix them.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
libdvbv5: fix some out-of-bound acesses on hexdump()

As Coverity points, there are some risk of getting out of bound
on some places. Fix it, and fix the coding style.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
libdvbv5: Simplify PAT handling

Coverity thinks that there's a resource leak by having a pgm
not being properly stored.

While I don't agree with Coverity, the code could be simplified,
and use just one pointer instead of two, in order to fill the
programs linked list.

That makes it easier to be analyzed by both automatic tools and
by manual inspection.

So, simplify it.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
libdvbv5: simplify NIT table parser

Do a cleanup at the code, simplifying it, and removing
the second pointer for the linked list.

That makes the code easier to analyse and review.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
libdvbv5: cleanup PAT table parser

Do a cleanup at the code, fixing coding style and moving
the head initialization to the beginning of the file.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
libdvbv5: simplify PMT table parser

Do a cleanup at the code, simplifying it, and removing
the second pointer for the linked list.

While here, add support for multisection PMT.

That makes the code easier to analyse and review.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
libdvbv5: simplify SDT table parser

Do a cleanup at the code, simplifying it, and removing
the second pointer for the linked list.

That makes the code easier to analyse and review.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
libdvbv5: simplify VCT table parser

Do a cleanup at the code, simplifying it, and removing
the second pointer for the linked list.

That makes the code easier to analyse and review.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
dvb/README: Remove some obsolete data

The descriptors handling is now completely different. Remove the
description of the old library from README file, as it doesn't apply
any more.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
dvbv5-zap: fix all-pids record mode

the -P switch was not working fine, as the recorded mpeg file
were being corrupting. Fix it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
libdvbv5: fix memory leak at ISDB partial reception handler

This descriptor handles allocates memory but never frees it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>