From 7d36590b4fe9f64f075433185f35e03978d491d1 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 25 May 2013 22:04:31 +0200 Subject: [PATCH] CAutoModeNotifier: avoid out-of-bounds access Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/7c6e91d0450be050036a3bc18fca4e8006249d0d Author: Stefan Seyfried Date: 2013-05-25 (Sat, 25 May 2013) --- src/system/setting_helpers.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index 36aef3354..7afbc03b1 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -556,9 +556,17 @@ bool CAutoModeNotifier::changeNotify(const neutrino_locale_t /*OptionName*/, voi int i; int modes[VIDEO_STD_MAX+1]; - memset(modes, 0, sizeof(int)*VIDEO_STD_MAX+1); + memset(modes, 0, sizeof(modes)); for(i = 0; i < VIDEOMENU_VIDEOMODE_OPTION_COUNT; i++) { + if (VIDEOMENU_VIDEOMODE_OPTIONS[i].key < 0) /* not available on this platform */ + continue; + if (VIDEOMENU_VIDEOMODE_OPTIONS[i].key >= VIDEO_STD_MAX) { + /* this must not happen */ + printf("CAutoModeNotifier::changeNotify VIDEOMODE_OPTIONS[%d].key = %d (>= %d)\n", + i, VIDEOMENU_VIDEOMODE_OPTIONS[i].key, VIDEO_STD_MAX); + continue; + } modes[VIDEOMENU_VIDEOMODE_OPTIONS[i].key] = g_settings.enabled_video_modes[i]; } videoDecoder->SetAutoModes(modes);