From dafe573e4d5a6de588634e1476707dce5acaad36 Mon Sep 17 00:00:00 2001 From: Torsten Jager Date: Tue, 14 Feb 2012 22:06:31 +0200 Subject: Fix video driver crash when accessing unsupported properties --- src/video_out/video_out_syncfb.c | 8 ++++++++ src/video_out/video_out_vidix.c | 8 ++++++++ src/video_out/video_out_xcbxv.c | 9 +++++++++ src/video_out/video_out_xv.c | 9 +++++++++ src/video_out/video_out_xvmc.c | 8 ++++++++ src/video_out/video_out_xxmc.c | 8 ++++++++ 6 files changed, 50 insertions(+) diff --git a/src/video_out/video_out_syncfb.c b/src/video_out/video_out_syncfb.c index 68a04c33d..4df568c76 100644 --- a/src/video_out/video_out_syncfb.c +++ b/src/video_out/video_out_syncfb.c @@ -663,6 +663,8 @@ static int syncfb_get_property(vo_driver_t* this_gen, int property) { syncfb_driver_t* this = (syncfb_driver_t *) this_gen; + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) return 0; + switch (property) { case VO_PROP_WINDOW_WIDTH: this->props[property].value = this->sc.gui_width; @@ -691,6 +693,8 @@ static int syncfb_set_property(vo_driver_t* this_gen, int property, int value) { syncfb_driver_t* this = (syncfb_driver_t *) this_gen; + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) return 0; + switch (property) { case VO_PROP_INTERLACED: this->props[property].value = value; @@ -801,6 +805,10 @@ static void syncfb_get_property_min_max(vo_driver_t *this_gen, { syncfb_driver_t* this = (syncfb_driver_t *) this_gen; + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) { + *min = *max = 0; + return; + } *min = this->props[property].min; *max = this->props[property].max; } diff --git a/src/video_out/video_out_vidix.c b/src/video_out/video_out_vidix.c index 0a7f6a8f6..19e9d0520 100644 --- a/src/video_out/video_out_vidix.c +++ b/src/video_out/video_out_vidix.c @@ -697,6 +697,8 @@ static int vidix_get_property (vo_driver_t *this_gen, int property) { vidix_driver_t *this = (vidix_driver_t *) this_gen; + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) return 0; + switch (property) { case VO_PROP_WINDOW_WIDTH: this->props[property].value = this->sc.gui_width; @@ -731,6 +733,8 @@ static int vidix_set_property (vo_driver_t *this_gen, vidix_driver_t *this = (vidix_driver_t *) this_gen; int err; + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) return 0; + if ((value >= this->props[property].min) && (value <= this->props[property].max)) { @@ -853,6 +857,10 @@ static void vidix_get_property_min_max (vo_driver_t *this_gen, vidix_driver_t *this = (vidix_driver_t *) this_gen; + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) { + *min = *max = 0; + return; + } *min = this->props[property].min; *max = this->props[property].max; } diff --git a/src/video_out/video_out_xcbxv.c b/src/video_out/video_out_xcbxv.c index 1f580bd69..a627c802b 100644 --- a/src/video_out/video_out_xcbxv.c +++ b/src/video_out/video_out_xcbxv.c @@ -770,6 +770,8 @@ static void xv_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { static int xv_get_property (vo_driver_t *this_gen, int property) { xv_driver_t *this = (xv_driver_t *) this_gen; + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) return (0); + switch (property) { case VO_PROP_WINDOW_WIDTH: this->props[property].value = this->sc.gui_width; @@ -810,6 +812,8 @@ static int xv_set_property (vo_driver_t *this_gen, int property, int value) { xv_driver_t *this = (xv_driver_t *) this_gen; + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) return 0; + if (this->props[property].atom != XCB_NONE) { xcb_xv_get_port_attribute_cookie_t get_attribute_cookie; xcb_xv_get_port_attribute_reply_t *get_attribute_reply; @@ -899,6 +903,11 @@ static void xv_get_property_min_max (vo_driver_t *this_gen, int property, int *min, int *max) { xv_driver_t *this = (xv_driver_t *) this_gen; + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) { + *min = *max = 0; + return; + } + *min = this->props[property].min; *max = this->props[property].max; } diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index af1752158..0fd8ca89a 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -875,6 +875,8 @@ static void xv_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { static int xv_get_property (vo_driver_t *this_gen, int property) { xv_driver_t *this = (xv_driver_t *) this_gen; + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) return (0); + switch (property) { case VO_PROP_WINDOW_WIDTH: this->props[property].value = this->sc.gui_width; @@ -916,6 +918,8 @@ static int xv_set_property (vo_driver_t *this_gen, int property, int value) { xv_driver_t *this = (xv_driver_t *) this_gen; + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) return 0; + if (this->props[property].atom != None) { /* value is out of bound */ @@ -1000,6 +1004,11 @@ static void xv_get_property_min_max (vo_driver_t *this_gen, int property, int *min, int *max) { xv_driver_t *this = (xv_driver_t *) this_gen; + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) { + *min = *max = 0; + return; + } + *min = this->props[property].min; *max = this->props[property].max; } diff --git a/src/video_out/video_out_xvmc.c b/src/video_out/video_out_xvmc.c index aeb50271a..5644307ef 100644 --- a/src/video_out/video_out_xvmc.c +++ b/src/video_out/video_out_xvmc.c @@ -1009,6 +1009,8 @@ static int xvmc_get_property (vo_driver_t *this_gen, int property) { lprintf ("xvmc_get_property\n"); + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) return 0; + switch (property) { case VO_PROP_WINDOW_WIDTH: this->props[property].value = this->sc.gui_width; @@ -1051,6 +1053,8 @@ static int xvmc_set_property (vo_driver_t *this_gen, lprintf ("xvmc_set_property %d value %d\n",property,value); + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) return 0; + if (this->props[property].atom != None) { /* value is out of bound */ if((value < this->props[property].min) || (value > this->props[property].max)) @@ -1129,6 +1133,10 @@ static void xvmc_get_property_min_max (vo_driver_t *this_gen, lprintf ("xvmc_get_property_min_max\n"); + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) { + *min = *max = 0; + return; + } *min = this->props[property].min; *max = this->props[property].max; } diff --git a/src/video_out/video_out_xxmc.c b/src/video_out/video_out_xxmc.c index f8caec755..929e4462c 100644 --- a/src/video_out/video_out_xxmc.c +++ b/src/video_out/video_out_xxmc.c @@ -1754,6 +1754,8 @@ static void xxmc_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) static int xxmc_get_property (vo_driver_t *this_gen, int property) { xxmc_driver_t *this = (xxmc_driver_t *) this_gen; + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) return 0; + switch (property) { case VO_PROP_WINDOW_WIDTH: this->props[property].value = this->sc.gui_width; @@ -1804,6 +1806,8 @@ static int xxmc_set_property (vo_driver_t *this_gen, int property, int value) { xxmc_driver_t *this = (xxmc_driver_t *) this_gen; + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) return 0; + if (this->props[property].atom != None) { /* value is out of bound */ @@ -1892,6 +1896,10 @@ static void xxmc_get_property_min_max (vo_driver_t *this_gen, int property, int *min, int *max) { xxmc_driver_t *this = (xxmc_driver_t *) this_gen; + if ((property < 0) || (property >= VO_NUM_PROPERTIES)) { + *min = *max = 0; + return; + } *min = this->props[property].min; *max = this->props[property].max; } -- cgit v1.2.3