From c6f627fb16447239a4ec8c28c2da3608d9a39ba5 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 30 Aug 2014 17:15:35 -0300 Subject: [PATCH] libdvbv5: Fix parameters dvb_add_parms_for_sys() The way this function is declared, userspace cannot actually use, as the properties are opaque. Signed-off-by: Mauro Carvalho Chehab --- lib/include/libdvbv5/dvb-fe.h | 2 -- lib/libdvbv5/dvb-fe.c | 11 ++++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/include/libdvbv5/dvb-fe.h b/lib/include/libdvbv5/dvb-fe.h index d0a806d..acf65a5 100644 --- a/lib/include/libdvbv5/dvb-fe.h +++ b/lib/include/libdvbv5/dvb-fe.h @@ -142,8 +142,6 @@ int dvb_fe_store_parm(struct dvb_v5_fe_parms *parms, unsigned cmd, uint32_t value); int dvb_set_sys(struct dvb_v5_fe_parms *parms, fe_delivery_system_t sys); -int dvb_add_parms_for_sys(struct dtv_property *dvb_prop, - unsigned max_size, fe_delivery_system_t sys); int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms, uint32_t desired_system); diff --git a/lib/libdvbv5/dvb-fe.c b/lib/libdvbv5/dvb-fe.c index 8fb3125..9ff40f4 100644 --- a/lib/libdvbv5/dvb-fe.c +++ b/lib/libdvbv5/dvb-fe.c @@ -289,10 +289,12 @@ void dvb_fe_close(struct dvb_v5_fe_parms *p) } -int dvb_add_parms_for_sys(struct dtv_property *dvb_prop, - unsigned max_size, +int dvb_add_parms_for_sys(struct dvb_v5_fe_parms *p, fe_delivery_system_t sys) { + struct dvb_v5_fe_parms_priv *parms = (void *)p; + struct dtv_property *dvb_prop = parms->dvb_prop; + unsigned max_size = ARRAY_SIZE(parms->dvb_prop); const unsigned int *sys_props; int n; @@ -303,7 +305,7 @@ int dvb_add_parms_for_sys(struct dtv_property *dvb_prop, return EINVAL; n = 0; - while (sys_props[n]) { + while (sys_props[n] && n < max_size - 1) { dvb_prop[n].cmd = sys_props[n]; dvb_prop[n].u.data = 0; n++; @@ -343,8 +345,7 @@ int dvb_set_sys(struct dvb_v5_fe_parms *p, fe_delivery_system_t sys) } } - rc = dvb_add_parms_for_sys(parms->dvb_prop, - ARRAY_SIZE(parms->dvb_prop), sys); + rc = dvb_add_parms_for_sys(&parms->p, sys); if (rc < 0) return EINVAL; -- 2.7.4