From: Nikolaus Schulz <schulz@macnetix.de>
To: Mauro Carvalho Chehab <m.chehab@samsung.com>
Cc: <linux-media@vger.kernel.org>, Nikolaus Schulz <ns@htonl.de>,
"Nikolaus Schulz" <schulz@macnetix.de>
Subject: [PATCH] libdvbv5: more fixes in the T2 delivery descriptor handler
Date: Thu, 5 Dec 2013 16:10:03 +0100 [thread overview]
Message-ID: <1386256203-3007-1-git-send-email-schulz@macnetix.de> (raw)
* Fix a couple of memcpy calls, and remove a bogus one
* Properly use lengths of centre_frequency loop and subcell_info loop
(they count bytes, not entries)
Signed-off-by: Nikolaus Schulz <schulz@macnetix.de>
---
lib/libdvbv5/descriptors/desc_t2_delivery.c | 35 ++++++++++++++-------------
1 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/lib/libdvbv5/descriptors/desc_t2_delivery.c b/lib/libdvbv5/descriptors/desc_t2_delivery.c
index ab4361d..07a0956 100644
--- a/lib/libdvbv5/descriptors/desc_t2_delivery.c
+++ b/lib/libdvbv5/descriptors/desc_t2_delivery.c
@@ -32,6 +32,7 @@ void dvb_desc_t2_delivery_init(struct dvb_v5_fe_parms *parms,
struct dvb_desc_t2_delivery *d = desc;
unsigned char *p = (unsigned char *) buf;
size_t desc_len = ext->length - 1, len, len2;
+ uint8_t nmemb;
int i;
len = offsetof(struct dvb_desc_t2_delivery, bitfield);
@@ -42,7 +43,7 @@ void dvb_desc_t2_delivery_init(struct dvb_v5_fe_parms *parms,
return;
}
if (desc_len < len2) {
- memcpy(p, buf, len);
+ memcpy(d, p, len);
bswap16(d->system_id);
if (desc_len != len)
@@ -50,44 +51,41 @@ void dvb_desc_t2_delivery_init(struct dvb_v5_fe_parms *parms,
return;
}
- memcpy(p, buf, len2);
+ memcpy(d, p, len2);
p += len2;
- len = desc_len - (p - buf);
- memcpy(&d->centre_frequency, p, len);
- p += len;
-
if (d->tfs_flag)
- d->frequency_loop_length = 1;
+ d->frequency_loop_length = sizeof(*d->centre_frequency);
else {
d->frequency_loop_length = *p;
p++;
}
+ nmemb = d->frequency_loop_length / sizeof(*d->centre_frequency);
- d->centre_frequency = calloc(d->frequency_loop_length,
- sizeof(*d->centre_frequency));
+ d->centre_frequency = calloc(nmemb, sizeof(*d->centre_frequency));
if (!d->centre_frequency) {
dvb_perror("Out of memory");
return;
}
- memcpy(d->centre_frequency, p, sizeof(*d->centre_frequency) * d->frequency_loop_length);
- p += sizeof(*d->centre_frequency) * d->frequency_loop_length;
+ memcpy(d->centre_frequency, p, d->frequency_loop_length);
+ p += d->frequency_loop_length;
- for (i = 0; i < d->frequency_loop_length; i++)
+ for (i = 0; i < nmemb; i++)
bswap32(d->centre_frequency[i]);
d->subcel_info_loop_length = *p;
p++;
+ nmemb = d->subcel_info_loop_length / sizeof(*d->subcell);
- d->subcell = calloc(d->subcel_info_loop_length, sizeof(*d->subcell));
+ d->subcell = calloc(nmemb, sizeof(*d->subcell));
if (!d->subcell) {
dvb_perror("Out of memory");
return;
}
- memcpy(d->subcell, p, sizeof(*d->subcell) * d->subcel_info_loop_length);
+ memcpy(d->subcell, p, d->subcel_info_loop_length);
- for (i = 0; i < d->subcel_info_loop_length; i++)
+ for (i = 0; i < nmemb; i++)
bswap16(d->subcell[i].transposer_frequency);
}
@@ -97,6 +95,7 @@ void dvb_desc_t2_delivery_print(struct dvb_v5_fe_parms *parms,
{
const struct dvb_desc_t2_delivery *d = desc;
int i;
+ uint8_t nmemb;
dvb_log("| DVB-T2 delivery");
dvb_log("| plp_id %d", d->plp_id);
@@ -113,10 +112,12 @@ void dvb_desc_t2_delivery_print(struct dvb_v5_fe_parms *parms,
dvb_log("| bandwidth %d", d->bandwidth);
dvb_log("| SISO MISO %d", d->SISO_MISO);
- for (i = 0; i < d->frequency_loop_length; i++)
+ nmemb = d->frequency_loop_length / sizeof(*d->centre_frequency);
+ for (i = 0; i < nmemb; i++)
dvb_log("| centre frequency[%d] %d", i, d->centre_frequency[i]);
- for (i = 0; i < d->subcel_info_loop_length; i++) {
+ nmemb = d->subcel_info_loop_length / sizeof(*d->subcell);
+ for (i = 0; i < nmemb; i++) {
dvb_log("| cell_id_extension[%d] %d", i, d->subcell[i].cell_id_extension);
dvb_log("| transposer frequency %d", d->subcell[i].transposer_frequency);
}
--
1.7.2.5
next reply other threads:[~2013-12-05 15:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-05 15:10 Nikolaus Schulz [this message]
2013-12-18 12:49 ` [PATCH] libdvbv5: more fixes in the T2 delivery descriptor handler Mauro Carvalho Chehab
2013-12-19 2:37 ` Nikolaus Schulz
2013-12-19 11:30 ` Mauro Carvalho Chehab
2013-12-19 21:25 ` Nikolaus Schulz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1386256203-3007-1-git-send-email-schulz@macnetix.de \
--to=schulz@macnetix.de \
--cc=linux-media@vger.kernel.org \
--cc=m.chehab@samsung.com \
--cc=ns@htonl.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox