From f4f61109479eb9d894ca0a7c88e2bc52b6e5b24d Mon Sep 17 00:00:00 2001 From: "[CST] Bas" Date: Mon, 16 Feb 2015 22:24:10 +0800 Subject: [PATCH 01/10] lib/libcoolstream2/cnxtfb.h: only define FBIO_WAITFORVSYNC if it's not defined yet by kernel headers. --- lib/libcoolstream2/cnxtfb.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/libcoolstream2/cnxtfb.h b/lib/libcoolstream2/cnxtfb.h index 4a51357a3..218c9f057 100644 --- a/lib/libcoolstream2/cnxtfb.h +++ b/lib/libcoolstream2/cnxtfb.h @@ -196,7 +196,9 @@ extern void cnxtfb_register_evnt_clbk(cnxtfb_notify pfnotify); #define FB_TEST_HW_ACCELERATION #define FBIOGET_CNXTFBHANDLE 0x4620 +#ifndef FBIO_WAITFORVSYNC #define FBIO_WAITFORVSYNC 0x4621 +#endif #define FBIO_STARTDISPLAY 0x4622 #define FBIO_STOPDISPLAY 0x4623 #define FBIO_SETBLENDMODE 0x4624 From e9f049c67771c66253851f2c9ecd671df6753cd4 Mon Sep 17 00:00:00 2001 From: "[CST] Bas" Date: Tue, 17 Feb 2015 19:41:24 +0800 Subject: [PATCH 02/10] src/driver/framebuffer.cpp: fix-up reading raw icons. If read failed or it read an corrupted header it could lead to bad allocations. Prevent that. --- src/driver/framebuffer.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/driver/framebuffer.cpp b/src/driver/framebuffer.cpp index b890a43f4..24bc2a527 100644 --- a/src/driver/framebuffer.cpp +++ b/src/driver/framebuffer.cpp @@ -1099,10 +1099,25 @@ bool CFrameBuffer::paintIcon(const std::string & filename, const int x, const in //printf("paintIcon: error while loading icon: %s\n", newname.c_str()); return false; } - read(lfd, &header, sizeof(struct rawHeader)); + + ssize_t s = read(lfd, &header, sizeof(struct rawHeader)); + if (s < 0) { + perror("read"); + return false; + } + + if (s < (ssize_t) sizeof(rawHeader)){ + printf("paintIcon: error while loading icon: %s, header too small\n", newname.c_str()); + return false; + } + tmpIcon.width = width = (header.width_hi << 8) | header.width_lo; tmpIcon.height = height = (header.height_hi << 8) | header.height_lo; + if (!width || !height) { + printf("paintIcon: error while loading icon: %s, wrong dimensions (%dHx%dW)\n", newname.c_str(), height, width); + return false; + } int dsize = width*height*sizeof(fb_pixel_t); From 6fdaa869d748c0af845c150592d533a9cbafb86e Mon Sep 17 00:00:00 2001 From: "[CST] Bas" Date: Sun, 22 Feb 2015 20:18:07 +0800 Subject: [PATCH 03/10] src/system/sysload.cpp: fix possible divide by zero bug, stats are not guarantueed to be different for each sample. --- src/system/sysload.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/system/sysload.cpp b/src/system/sysload.cpp index 5338adcc9..341a8c189 100644 --- a/src/system/sysload.cpp +++ b/src/system/sysload.cpp @@ -62,8 +62,11 @@ void *cSysLoad::Run(void *arg) while (getline(in, line)) { unsigned long _stat_user, _stat_nice, _stat_system, _stat_idle; if (4 == sscanf(line.c_str(), "cpu %lu %lu %lu %lu", &_stat_user, &_stat_nice, &_stat_system, &_stat_idle)) { + unsigned long _stat_total = _stat_user + _stat_nice + _stat_system + _stat_idle; if (stat_total) { - unsigned long div = _stat_user + _stat_nice + _stat_system + _stat_idle - stat_total; + unsigned long div = _stat_total - stat_total; + if (!div) // prevent division by zero if previous stat_total is equal to new. + break; caller->data_last = (int)(1000 - 1000 * (_stat_idle - stat_idle) / div); if (caller->data_avail < caller->data_size) { caller->data[caller->data_avail++] = caller->data_last; @@ -73,7 +76,7 @@ void *cSysLoad::Run(void *arg) } } stat_idle = _stat_idle; - stat_total = _stat_user + _stat_nice + _stat_system + _stat_idle; + stat_total = _stat_total; break; } } From 51fddab5a620b594d34027e8d8e08d4610b5efe7 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 21 Feb 2015 18:21:13 +0100 Subject: [PATCH 04/10] streaminfo: don't paint outside of the framebuffer Signed-off-by: Jacek Jendrzej --- src/gui/streaminfo2.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/gui/streaminfo2.cpp b/src/gui/streaminfo2.cpp index 029c76046..624ca1550 100644 --- a/src/gui/streaminfo2.cpp +++ b/src/gui/streaminfo2.cpp @@ -700,12 +700,10 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos) #define NUM_CAIDS 11 void CStreamInfo2::paintCASystem(int xpos, int ypos) { - unsigned short i, ypos1 = 0; + unsigned short i; int box_width = width*2/3-10; - if(box_h2 > 0) - { - frameBuffer->paintBoxRel (0, ypos+(iheight*2), box_width, box_h2, COL_MENUHEAD_PLUS_0); - } + if (box_h2 > 0) + frameBuffer->paintBox(0, ypos+(iheight*2), box_width, box_h2, COL_MENUHEAD_PLUS_0); std::string casys[NUM_CAIDS]={"Irdeto:","Betacrypt:","Seca:","Viaccess:","Nagra:","Conax: ","Cryptoworks:","Videoguard:","EBU:","XCrypt:","PowerVU:"}; bool caids[NUM_CAIDS]; @@ -782,6 +780,10 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos) cryptsysteme = false; } ypos += sheight; + if (ypos > max_height) { + ypos -= sheight; + break; + } int width_txt = 0, index = 0; const char *tok = " "; std::string::size_type last_pos = casys[ca_id].find_first_not_of(tok, 0); @@ -800,8 +802,8 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos) } } } - if(box_h2 == 0) - box_h2 = ypos - ypos1; + if (box_h2 < ypos) + box_h2 = ypos; } /* From cf0b9f944a7b54f32fff4b57af46ebe613c41188 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 21 Feb 2015 15:58:45 +0100 Subject: [PATCH 05/10] CC-Clock: remove unnecessary cast Signed-off-by: Jacek Jendrzej --- src/gui/components/cc_frm_clock.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index a26f95d28..68955fbcb 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -98,7 +98,7 @@ void CComponentsFrmClock::initTimeString() struct tm t; time_t ltime; ltime=time(NULL); - strftime((char*) &cl_timestr, sizeof(cl_timestr), getTimeFormat(ltime), localtime_r(<ime, &t)); + strftime(cl_timestr, sizeof(cl_timestr), getTimeFormat(ltime), localtime_r(<ime, &t)); } // How does it works? From bc0c0484745c8849b093ecccf1d9ca1636688567 Mon Sep 17 00:00:00 2001 From: "[CST] Bas" Date: Sun, 22 Feb 2015 23:26:16 +0800 Subject: [PATCH 06/10] src/driver/framebuffer.cpp: check dimension in int_convertRGB2FB and if it's not valid, spit out a warning and return NULL. --- src/driver/framebuffer.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/driver/framebuffer.cpp b/src/driver/framebuffer.cpp index 24bc2a527..6060ddb39 100644 --- a/src/driver/framebuffer.cpp +++ b/src/driver/framebuffer.cpp @@ -1825,7 +1825,15 @@ void * CFrameBuffer::int_convertRGB2FB(unsigned char *rgbbuff, unsigned long x, { unsigned long i; unsigned int *fbbuff; - unsigned long count = x * y; + unsigned long count; + + if (!x || !y) { + printf("convertRGB2FB%s: Error: invalid dimensions (%luX x %luY)\n", + ((alpha) ? " (Alpha)" : ""), x, y); + return NULL; + } + + count = x * y; fbbuff = (unsigned int *) cs_malloc_uncached(count * sizeof(unsigned int)); if(fbbuff == NULL) { From 16ccbafe693747d8ba7d6afdcf6360ed34eb6467 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Sun, 22 Feb 2015 19:00:51 +0300 Subject: [PATCH 07/10] system/flashtool.cpp: call saveEpg in shutdown mode, to prevent any events --- src/system/flashtool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/flashtool.cpp b/src/system/flashtool.cpp index 04ddd4d43..e845dd7e0 100644 --- a/src/system/flashtool.cpp +++ b/src/system/flashtool.cpp @@ -159,7 +159,7 @@ bool CFlashTool::program( const std::string & filename, int globalProgressEndEra int globalProgressBegin = 0; if(g_settings.epg_save) - CNeutrinoApp::getInstance()->saveEpg(false); + CNeutrinoApp::getInstance()->saveEpg(true); if(statusViewer) statusViewer->showLocalStatus(0); From 839f78b9e514dbfe33f3203c556700732b707a56 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Sun, 22 Feb 2015 19:01:12 +0300 Subject: [PATCH 08/10] eitd/xmlutil.cpp: add sync() after epg save is done --- src/eitd/xmlutil.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/eitd/xmlutil.cpp b/src/eitd/xmlutil.cpp index 056235116..7dd9cdb8f 100644 --- a/src/eitd/xmlutil.cpp +++ b/src/eitd/xmlutil.cpp @@ -562,11 +562,10 @@ _done: write_indexxml_footer(indexfile); fclose(indexfile); - printf("[sectionsd] Writing Information finished\n"); - filename = (std::string)epgdir + "/index.xml"; - rename(tmpname.c_str(), filename.c_str()); + sync(); + printf("[sectionsd] Writing Information finished\n"); return ; } From 35c5faac6773d3753b6c86788fb25689aa7bb8a8 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Tue, 24 Feb 2015 18:05:52 +0100 Subject: [PATCH 09/10] nhttpd: neutrinoapi.cpp disable unused func --- src/nhttpd/tuxboxapi/coolstream/neutrinoapi.cpp | 6 +++--- src/nhttpd/tuxboxapi/coolstream/neutrinoapi.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/nhttpd/tuxboxapi/coolstream/neutrinoapi.cpp b/src/nhttpd/tuxboxapi/coolstream/neutrinoapi.cpp index b9a09482e..93671d5b8 100644 --- a/src/nhttpd/tuxboxapi/coolstream/neutrinoapi.cpp +++ b/src/nhttpd/tuxboxapi/coolstream/neutrinoapi.cpp @@ -227,14 +227,14 @@ t_channel_id CNeutrinoAPI::ChannelNameToChannelId(std::string search_channel_nam //------------------------------------------------------------------------- // Get functions //------------------------------------------------------------------------- - +#if 0 /* unused funktion*/ bool CNeutrinoAPI::GetStreamInfo(int bitInfo[10]) { char /* *key,*/ *tmpptr, buf[100]; long value; int pos = 0; - memset(bitInfo, 0, sizeof(bitInfo)); + memset(bitInfo, 0, 10); FILE *fd = fopen("/proc/bus/bitstream", "rt"); @@ -261,7 +261,7 @@ bool CNeutrinoAPI::GetStreamInfo(int bitInfo[10]) return true; } - +#endif //------------------------------------------------------------------------- bool CNeutrinoAPI::GetChannelEvents(void) diff --git a/src/nhttpd/tuxboxapi/coolstream/neutrinoapi.h b/src/nhttpd/tuxboxapi/coolstream/neutrinoapi.h index a98a7b5bf..4d504eae0 100644 --- a/src/nhttpd/tuxboxapi/coolstream/neutrinoapi.h +++ b/src/nhttpd/tuxboxapi/coolstream/neutrinoapi.h @@ -53,7 +53,9 @@ class CNeutrinoAPI // get functions to collect data bool GetChannelEvents(void); +#if 0 /* unused funktion*/ bool GetStreamInfo(int bitinfo[10]); +#endif std::string GetServiceName(t_channel_id channel_id); CZapitClient::BouquetChannelList *GetBouquet(unsigned int BouquetNr, int Mode); CZapitClient::BouquetChannelList *GetChannelList(int Mode); From 24c4f5c0cdbfb0cf954d53a7b1e0b10b78b3664f Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Wed, 25 Feb 2015 16:55:03 +0100 Subject: [PATCH 10/10] fix crash in user_menue when ITEM_EPG_MISC is selected --- src/gui/user_menue.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/user_menue.cpp b/src/gui/user_menue.cpp index 6596035b0..79368a759 100644 --- a/src/gui/user_menue.cpp +++ b/src/gui/user_menue.cpp @@ -100,6 +100,7 @@ CUserMenu::~CUserMenu() bool CUserMenu::showUserMenu(neutrino_msg_t msg) { int button = -1; + int dummy = 0; unsigned ums = g_settings.usermenu.size(); for (unsigned int i = 0; i < ums; i++) if (g_settings.usermenu[i]->key == msg) { @@ -235,7 +236,7 @@ bool CUserMenu::showUserMenu(neutrino_msg_t msg) break; case SNeutrinoSettings::ITEM_EPG_MISC: { - int dummy = g_Sectionsd->getIsScanningActive(); + dummy = g_Sectionsd->getIsScanningActive(); keyhelper.get(&key,&icon); // new CMenuOptionChooser(LOCALE_VIDEOMENU_VIDEOMODE, &g_settings.video_Mode, VIDEOMENU_VIDEOMODE_OPTIONS, VIDEOMENU_VIDEOMODE_OPTION_COUNT, true, this, CRCInput::RC_nokey, "", true); menu_item = new CMenuOptionChooser(LOCALE_MAINMENU_PAUSESECTIONSD, &dummy, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, this , key, icon );