aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>2006-04-05 10:33:41 +0000
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>2006-04-05 10:33:41 +0000
commit3d942915a3aaf28d3c38cc7f94e1cc730f5f60d9 (patch)
treee7a3b22a89c457776dbc746e8f6e2ddbdcbeefbb /lib
parent1609175bb343a0e8e7c0b634b9582f76d6d72eb8 (diff)
downloadenigma2-3d942915a3aaf28d3c38cc7f94e1cc730f5f60d9.tar.gz
enigma2-3d942915a3aaf28d3c38cc7f94e1cc730f5f60d9.zip
fix setCommandString
Diffstat (limited to 'lib')
-rw-r--r--lib/dvb/frontend.cpp38
1 files changed, 34 insertions, 4 deletions
diff --git a/lib/dvb/frontend.cpp b/lib/dvb/frontend.cpp
index cb853e2b..eba474e8 100644
--- a/lib/dvb/frontend.cpp
+++ b/lib/dvb/frontend.cpp
@@ -57,10 +57,40 @@ void eDVBDiseqcCommand::setCommandString(const char *str)
{
if (!str)
return;
- len = strlen(str);
- if (len > MAX_DISEQC_LENGTH)
- len = MAX_DISEQC_LENGTH;
- memcpy(data, str, len);
+ len=0;
+ int slen = strlen(str);
+ if (slen % 2)
+ {
+ eDebug("invalid diseqc command string length (not 2 byte aligned)");
+ return;
+ }
+ if (slen > MAX_DISEQC_LENGTH*2)
+ {
+ eDebug("invalid diseqc command string length (string is to long)");
+ return;
+ }
+ unsigned char val=0;
+ for (int i=0; i < slen; ++i)
+ {
+ unsigned char c = str[i];
+ switch(c)
+ {
+ case '0' ... '9': c-=48; break;
+ case 'a' ... 'f': c-=87; break;
+ case 'A' ... 'F': c-=55; break;
+ default:
+ eDebug("invalid character in hex string..ignore complete diseqc command !");
+ return;
+ }
+ if ( i % 2 )
+ {
+ val |= c;
+ data[i/2] = val;
+ }
+ else
+ val = c << 4;
+ }
+ len = slen/2;
}
void eDVBFrontendParametersSatellite::set(const SatelliteDeliverySystemDescriptor &descriptor)