summaryrefslogtreecommitdiff
path: root/diseqc.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2011-05-22 10:51:03 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2011-05-22 10:51:03 +0200
commitd7c07ecbfd1fe35784b809298db73ac26804085b (patch)
tree1d504cb6e2cdad3c264be410e3264101ba30f6de /diseqc.c
parent7978112850497d4a4587c142923c248747aed383 (diff)
downloadvdr-d7c07ecbfd1fe35784b809298db73ac26804085b.tar.gz
vdr-d7c07ecbfd1fe35784b809298db73ac26804085b.tar.bz2
Fixed a possible race condition in cDiseqc::Execute()
Diffstat (limited to 'diseqc.c')
-rw-r--r--diseqc.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/diseqc.c b/diseqc.c
index 0168362c..b65d82c6 100644
--- a/diseqc.c
+++ b/diseqc.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: diseqc.c 2.3 2011/05/21 22:07:08 kls Exp $
+ * $Id: diseqc.c 2.4 2011/05/22 10:36:12 kls Exp $
*/
#include "diseqc.h"
@@ -59,7 +59,7 @@ bool cDiseqc::Parse(const char *s)
polarization = char(toupper(polarization));
if (polarization == 'V' || polarization == 'H' || polarization == 'L' || polarization == 'R') {
parsing = true;
- char *CurrentAction = NULL;
+ const char *CurrentAction = NULL;
while (Execute(&CurrentAction) != daNone)
;
parsing = false;
@@ -75,7 +75,7 @@ bool cDiseqc::Parse(const char *s)
return result;
}
-char *cDiseqc::Wait(char *s)
+const char *cDiseqc::Wait(const char *s) const
{
char *p = NULL;
errno = 0;
@@ -89,19 +89,22 @@ char *cDiseqc::Wait(char *s)
return NULL;
}
-char *cDiseqc::Codes(char *s)
+const char *cDiseqc::Codes(const char *s) const
{
- char *e = strchr(s, ']');
+ const char *e = strchr(s, ']');
if (e) {
- numCodes = 0;
- char *t = s;
- char *p = s;
+ int NumCodes = 0;
+ const char *t = s;
+ char *p;
while (t < e) {
- if (numCodes < MaxDiseqcCodes) {
+ if (NumCodes < MaxDiseqcCodes) {
errno = 0;
int n = strtol(t, &p, 16);
if (!errno && p != t && 0 <= n && n <= 255) {
- codes[numCodes++] = uchar(n);
+ if (parsing) {
+ codes[NumCodes++] = uchar(n);
+ numCodes = NumCodes;
+ }
t = skipspace(p);
}
else {
@@ -121,7 +124,7 @@ char *cDiseqc::Codes(char *s)
return NULL;
}
-cDiseqc::eDiseqcActions cDiseqc::Execute(char **CurrentAction)
+cDiseqc::eDiseqcActions cDiseqc::Execute(const char **CurrentAction) const
{
if (!*CurrentAction)
*CurrentAction = commands;
@@ -146,10 +149,10 @@ cDiseqc::eDiseqcActions cDiseqc::Execute(char **CurrentAction)
cDiseqcs Diseqcs;
-cDiseqc *cDiseqcs::Get(int Device, int Source, int Frequency, char Polarization)
+const cDiseqc *cDiseqcs::Get(int Device, int Source, int Frequency, char Polarization) const
{
int Devices = 0;
- for (cDiseqc *p = First(); p; p = Next(p)) {
+ for (const cDiseqc *p = First(); p; p = Next(p)) {
if (p->Devices()) {
Devices = p->Devices();
continue;