From: Lars Op den Kamp Date: Thu, 8 Dec 2011 00:04:55 +0000 (+0100) Subject: cec: removed 'retries' from cec_command, to avoid stack smashing when upgrading the... X-Git-Tag: upstream/2.2.0~1^2~44^2~12 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=e107f073245c22d58a99d6efc7d2e70a13c82d38;p=deb_libcec.git cec: removed 'retries' from cec_command, to avoid stack smashing when upgrading the libcec binary without recompiling --- diff --git a/include/cectypes.h b/include/cectypes.h index 7bce7e2..9759fd3 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -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 diff --git a/src/lib/AdapterCommunication.cpp b/src/lib/AdapterCommunication.cpp index 2bdbb04..54077d6 100644 --- a/src/lib/AdapterCommunication.cpp +++ b/src/lib/AdapterCommunication.cpp @@ -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 diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index e1e03b8..a3c22df 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -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 */ diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index c58a606..5c6a52f 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -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); diff --git a/src/lib/implementations/CECCommandHandler.h b/src/lib/implementations/CECCommandHandler.h index f6f397d..e5d19ed 100644 --- a/src/lib/implementations/CECCommandHandler.h +++ b/src/lib/implementations/CECCommandHandler.h @@ -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);