From 13b74854b37a3a0f855ee8bf723ee3d9a2c360a5 Mon Sep 17 00:00:00 2001
From: Klaus Schmidinger <vdr@tvdr.de>
Date: Fri, 2 Sep 2005 12:52:37 +0200
Subject: Made LIRC command parsing more robust

---
 CONTRIBUTORS | 1 +
 HISTORY      | 1 +
 lirc.c       | 7 +++++--
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 98a23c54..f090c00b 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -1387,6 +1387,7 @@ Roman Krenick
 Ville Skytt� <ville.skytta@iki.fi>
  for reporting several compiler warnings in gcc 4.0
  for including the optional user defined Make.config from the 'libsi' Makefile
+ for making LIRC command parsing more robust
 
 Steffen Beyer <cpunk@reactor.de>
  for fixing setting the colored button help after deleting a recording in case the next
diff --git a/HISTORY b/HISTORY
index 89d04074..0d0ac259 100644
--- a/HISTORY
+++ b/HISTORY
@@ -3762,3 +3762,4 @@ Video Disk Recorder Revision History
 - Updated the Swedish OSD texts (thanks to Tomas Prybil).
 - Updated the Slovenian OSD texts (thanks to Matjaz Thaler).
 - Updated the Danish OSD texts (thanks to Mogens Elneff).
+- Made LIRC command parsing more robust (thanks to Ville Skytt�).
diff --git a/lirc.c b/lirc.c
index 2eee9cc0..ac9de010 100644
--- a/lirc.c
+++ b/lirc.c
@@ -6,7 +6,7 @@
  *
  * LIRC support added by Carsten Koch <Carsten.Koch@icem.de>  2000-06-16.
  *
- * $Id: lirc.c 1.12 2005/08/15 12:28:10 kls Exp $
+ * $Id: lirc.c 1.13 2005/09/02 12:51:35 kls Exp $
  */
 
 #include "lirc.h"
@@ -76,7 +76,10 @@ void cLircRemote::Action(void)
         if (ready && ret > 21) {
            int count;
            char KeyName[LIRC_KEY_BUF];
-           sscanf(buf, "%*x %x %29s", &count, KeyName); // '29' in '%29s' is LIRC_KEY_BUF-1!
+           if (sscanf(buf, "%*x %x %29s", &count, KeyName) != 2) { // '29' in '%29s' is LIRC_KEY_BUF-1!
+              esyslog("ERROR: unparseable lirc command: %s", buf);
+              continue;
+              }
            if (count == 0) {
               if (strcmp(KeyName, LastKeyName) == 0 && FirstTime.Elapsed() < KEYPRESSDELAY)
                  continue; // skip keys coming in too fast
-- 
cgit v1.2.3