From e6fefa10c1f21ece6e0b8e5dee68dc4dc0efee86 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 13 Jan 2013 18:11:36 +0100 Subject: [PATCH] triple: add a sanity check to cVideo::GetScreenImage --- libtriple/video_td.cpp | 6 ++++++ libtriple/video_td.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/libtriple/video_td.cpp b/libtriple/video_td.cpp index 079bfa4..f3dfaa7 100644 --- a/libtriple/video_td.cpp +++ b/libtriple/video_td.cpp @@ -942,6 +942,12 @@ bool cVideo::GetScreenImage(unsigned char * &video, int &xres, int &yres, bool g } uint16_t w = *(uint16_t *)(map + WIDTH_OFF); uint16_t h = *(uint16_t *)(map + HEIGHT_OFF); + if (w > 720 || h > 576) { + lt_info("%s: unhandled resolution %dx%d, is the tuner locked?\n", __func__, w, h); + munmap(map, VIDEO_SIZE); + close(mfd); + return false; + } uint8_t *luma, *chroma; int needmem = w * h * 5 / 4; /* chroma is 1/4 in size of luma */ int lumasize = w * h; diff --git a/libtriple/video_td.h b/libtriple/video_td.h index 8f4893b..f73bb04 100644 --- a/libtriple/video_td.h +++ b/libtriple/video_td.h @@ -6,6 +6,8 @@ //#define video_displayformat_t vidDispMode_t #include "../common/cs_types.h" +#define STB_HAL_VIDEO_HAS_GETSCREENIMAGE 1 + typedef enum { ANALOG_SD_RGB_SCART = 0x00, ANALOG_SD_YPRPB_SCART,