cec: removed 'retries' from cec_command, to avoid stack smashing when upgrading the...
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 8 Dec 2011 00:04:55 +0000 (01:04 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 8 Dec 2011 00:04:55 +0000 (01:04 +0100)
include/cectypes.h
src/lib/AdapterCommunication.cpp
src/lib/CECProcessor.cpp
src/lib/implementations/CECCommandHandler.cpp
src/lib/implementations/CECCommandHandler.h

index 7bce7e2bb75a63bf750d697d2358a04e2f564eca..9759fd37119a75a0bb09a8d172b226018c7d9daf 100644 (file)
@@ -699,7 +699,6 @@ typedef struct cec_command
   cec_datapacket      parameters;
   int8_t              opcode_set;
   int32_t             transmit_timeout;
-  int8_t              retries;
 
 #ifdef __cplusplus
   cec_command &operator =(const struct cec_command &command)
@@ -712,7 +711,6 @@ typedef struct cec_command
     opcode_set       = command.opcode_set;
     transmit_timeout = command.transmit_timeout;
     parameters       = command.parameters;
-    retries          = command.retries;
 
     return *this;
   }
@@ -755,7 +753,6 @@ typedef struct cec_command
     opcode_set       = 0;
     opcode           = CEC_OPCODE_FEATURE_ABORT;
     transmit_timeout = CEC_DEFAULT_TRANSMIT_TIMEOUT;
-    retries          = CEC_DEFAULT_TRANSMIT_RETRIES;
     parameters.Clear();
   };
 #endif
index 2bdbb04deded358fa721a2305cb254479a02f8fa..54077d6ed776b4b6ef72f0dcc0d76cffd948ab45 100644 (file)
@@ -43,7 +43,6 @@ using namespace CEC;
 CCECAdapterMessage::CCECAdapterMessage(const cec_command &command)
 {
   clear();
-  maxTries = command.retries + 1;
 
   //set ack polarity to high when transmitting to the broadcast address
   //set ack polarity low when transmitting to any other address
index e1e03b868d1ee6925bf319fd26c6f2b29fb801a8..a3c22df3169ad9f3851b3b34a30fd38c22cd96c7 100644 (file)
@@ -717,6 +717,13 @@ bool CCECProcessor::Transmit(const cec_command &data)
   LogOutput(data);
 
   CCECAdapterMessage *output = new CCECAdapterMessage(data);
+
+  /* set the number of retries */
+  if (data.opcode == CEC_OPCODE_NONE)
+    output->maxTries = 1;
+  else if (data.initiator != CECDEVICE_BROADCAST)
+    output->maxTries = m_busDevices[data.initiator]->GetHandler()->GetTransmitRetries() + 1;
+
   bReturn = Transmit(output);
 
   /* set to "not present" on failed ack */
index c58a606a1f69a8f0349a17091f4a630a0f642aa6..5c6a52f0abc2e9d4d82ea2b1e944f8361cf5a077 100644 (file)
@@ -899,8 +899,6 @@ bool CCECCommandHandler::TransmitKeyRelease(const cec_logical_address iInitiator
 bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /* = true */)
 {
   command.transmit_timeout = m_iTransmitTimeout;
-  if (command.retries == CEC_DEFAULT_TRANSMIT_RETRIES)
-    command.retries = m_iTransmitRetries;
 
   CLockObject writeLock(&m_processor->m_transmitMutex);
   CLockObject receiveLock(&m_receiveMutex);
index f6f397d46964254c56067df66a4857fa27663d97..e5d19ed102097c1a1e7901dd644365ffc60a675c 100644 (file)
@@ -53,6 +53,7 @@ namespace CEC
     virtual bool HandleReceiveFailed(void);
 
     virtual bool InitHandler(void) { return true; }
+    virtual uint8_t GetTransmitRetries(void) const { return m_iTransmitRetries; }
 
     virtual bool TransmitPowerOn(const cec_logical_address iInitiator, const cec_logical_address iDestination);
     virtual bool TransmitStandby(const cec_logical_address iInitiator, const cec_logical_address iDestination);