mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-17 09:12:25 +00:00
FS-8905 #resolve [Heap overflow in img patch]
This commit is contained in:
parent
931e8b6633
commit
e0b303e2cb
@ -330,9 +330,9 @@ SWITCH_DECLARE(void) switch_png_free(switch_png_t **pngP);
|
|||||||
* \param[in] img The small Image descriptor
|
* \param[in] img The small Image descriptor
|
||||||
* \param[in] x Leftmost pos
|
* \param[in] x Leftmost pos
|
||||||
* \param[in] y Topmost pos
|
* \param[in] y Topmost pos
|
||||||
* \param[in] alpha Alaha value from 0(completely transparent) to 255(opaque)
|
* \param[in] percent Alaha value from 0(completely transparent) to 100(opaque)
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(void) switch_img_overlay(switch_image_t *IMG, switch_image_t *img, int x, int y, uint8_t alpha);
|
SWITCH_DECLARE(void) switch_img_overlay(switch_image_t *IMG, switch_image_t *img, int x, int y, uint8_t percent);
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_img_scale(switch_image_t *src, switch_image_t **destP, int width, int height);
|
SWITCH_DECLARE(switch_status_t) switch_img_scale(switch_image_t *src, switch_image_t **destP, int width, int height);
|
||||||
SWITCH_DECLARE(switch_status_t) switch_img_fit(switch_image_t **srcP, int width, int height, switch_img_fit_t fit);
|
SWITCH_DECLARE(switch_status_t) switch_img_fit(switch_image_t **srcP, int width, int height, switch_img_fit_t fit);
|
||||||
|
@ -123,7 +123,8 @@ struct local_stream_source {
|
|||||||
switch_timer_t timer;
|
switch_timer_t timer;
|
||||||
int logo_always;
|
int logo_always;
|
||||||
switch_img_position_t logo_pos;
|
switch_img_position_t logo_pos;
|
||||||
int logo_opacity;
|
uint8_t logo_opacity;
|
||||||
|
uint8_t text_opacity;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct local_stream_source local_stream_source_t;
|
typedef struct local_stream_source local_stream_source_t;
|
||||||
@ -1061,9 +1062,7 @@ static switch_status_t local_stream_file_read_video(switch_file_handle_t *handle
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (frame->img && context->banner_img && frame->img->d_w >= context->banner_img->d_w) {
|
if (frame->img && context->banner_img && frame->img->d_w >= context->banner_img->d_w) {
|
||||||
//switch_img_overlay(frame->img, context->banner_img, 0, frame->img->d_h - context->banner_img->d_h, 100);
|
switch_img_overlay(frame->img, context->banner_img, 0, frame->img->d_h - context->banner_img->d_h, context->source->text_opacity);
|
||||||
switch_img_patch(frame->img, context->banner_img, 0, frame->img->d_h - context->banner_img->d_h);
|
|
||||||
//switch_img_patch(frame->img, context->banner_img, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame->img && context->source->logo_img &&
|
if (frame->img && context->source->logo_img &&
|
||||||
@ -1079,11 +1078,7 @@ static switch_status_t local_stream_file_read_video(switch_file_handle_t *handle
|
|||||||
y -= context->banner_img->d_h;
|
y -= context->banner_img->d_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context->source->logo_opacity > 0 && context->source->logo_opacity < 100) {
|
switch_img_overlay(frame->img, context->source->logo_img, x, y, context->source->logo_opacity);
|
||||||
switch_img_overlay(frame->img, context->source->logo_img, x, y-1, context->source->logo_opacity);
|
|
||||||
} else {
|
|
||||||
switch_img_patch(frame->img, context->source->logo_img, x, y-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
@ -1156,6 +1151,8 @@ static void launch_thread(const char *name, const char *path, switch_xml_t direc
|
|||||||
source->stopped = 0;
|
source->stopped = 0;
|
||||||
source->hup = 0;
|
source->hup = 0;
|
||||||
source->chime_freq = 30;
|
source->chime_freq = 30;
|
||||||
|
source->logo_opacity = source->text_opacity = 100;
|
||||||
|
|
||||||
for (param = switch_xml_child(directory, "param"); param; param = param->next) {
|
for (param = switch_xml_child(directory, "param"); param; param = param->next) {
|
||||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||||
@ -1214,6 +1211,11 @@ static void launch_thread(const char *name, const char *path, switch_xml_t direc
|
|||||||
if (source->logo_opacity < 0 && source->logo_opacity > 100) {
|
if (source->logo_opacity < 0 && source->logo_opacity > 100) {
|
||||||
source->logo_opacity = 0;
|
source->logo_opacity = 0;
|
||||||
}
|
}
|
||||||
|
} else if (!strcasecmp(var, "text-opacity") && !zstr(val)) {
|
||||||
|
source->text_opacity = atoi(val);
|
||||||
|
if (source->text_opacity < 0 && source->text_opacity > 100) {
|
||||||
|
source->text_opacity = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,11 +580,13 @@ static inline void switch_img_get_rgb_pixel(switch_image_t *img, switch_rgb_colo
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_img_overlay(switch_image_t *IMG, switch_image_t *img, int x, int y, uint8_t alpha)
|
SWITCH_DECLARE(void) switch_img_overlay(switch_image_t *IMG, switch_image_t *img, int x, int y, uint8_t percent)
|
||||||
{
|
{
|
||||||
int i, j, len, max_h;
|
int i, j, len, max_h;
|
||||||
switch_rgb_color_t RGB = {0}, rgb = {0}, c = {0};
|
switch_rgb_color_t RGB = {0}, rgb = {0}, c = {0};
|
||||||
int xoff = 0, yoff = 0;
|
int xoff = 0, yoff = 0;
|
||||||
|
uint8_t alpha = (int8_t)((255 * percent) / 100);
|
||||||
|
|
||||||
|
|
||||||
switch_assert(IMG->fmt == SWITCH_IMG_FMT_I420);
|
switch_assert(IMG->fmt == SWITCH_IMG_FMT_I420);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user