mirror of
https://gitee.com/openharmony/developtools_hdc
synced 2024-11-23 23:20:43 +00:00
forward payload size check
Change-Id: Ibe92b35b922832601c3f9b25ad2916f4054b3b63 Signed-off-by: leiguangyu <leiguangyu@huawei.com>
This commit is contained in:
parent
f559a74682
commit
5e59f8db7d
@ -601,8 +601,12 @@ inline bool HdcForwardBase::FilterCommand(uint8_t *bufCmdIn, uint32_t *idOut, ui
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HdcForwardBase::SlaveConnect(uint8_t *bufCmd, bool bCheckPoint, string &sError)
|
||||
bool HdcForwardBase::SlaveConnect(uint8_t *bufCmd, const int bufSize, bool bCheckPoint, string &sError)
|
||||
{
|
||||
if (bufSize <= DWORD_SERIALIZE_SIZE + forwardParameterBufSize) {
|
||||
WRITE_LOG(LOG_FATAL, "PayloadSize is shorter than header size");
|
||||
return false;
|
||||
}
|
||||
bool ret = false;
|
||||
char *content = nullptr;
|
||||
uint32_t idSlaveOld = 0;
|
||||
@ -786,6 +790,10 @@ bool HdcForwardBase::CommandForwardCheckResult(HCtxForward ctx, uint8_t *payload
|
||||
|
||||
bool HdcForwardBase::ForwardCommandDispatch(const uint16_t command, uint8_t *payload, const int payloadSize)
|
||||
{
|
||||
if (payloadSize <= DWORD_SERIALIZE_SIZE) {
|
||||
WRITE_LOG(LOG_FATAL, "PayloadSize is shorter than header size");
|
||||
return false;
|
||||
}
|
||||
bool ret = true;
|
||||
uint8_t *pContent = nullptr;
|
||||
int sizeContent = 0;
|
||||
@ -851,14 +859,14 @@ bool HdcForwardBase::CommandDispatch(const uint16_t command, uint8_t *payload, c
|
||||
return true;
|
||||
} else if (command == CMD_FORWARD_CHECK) {
|
||||
// Detect remote if it's reachable
|
||||
if (!SlaveConnect(payload, true, sError)) {
|
||||
if (!SlaveConnect(payload, payloadSize, true, sError)) {
|
||||
ret = false;
|
||||
goto Finish;
|
||||
}
|
||||
return true;
|
||||
} else if (command == CMD_FORWARD_ACTIVE_SLAVE) {
|
||||
// slave connect target port when activating
|
||||
if (!SlaveConnect(payload, false, sError)) {
|
||||
if (!SlaveConnect(payload, payloadSize, false, sError)) {
|
||||
ret = false;
|
||||
goto Finish;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ private:
|
||||
|
||||
bool SetupPoint(HCtxForward ctxPoint);
|
||||
void *MallocContext(bool masterSlave);
|
||||
bool SlaveConnect(uint8_t *bufCmd, bool bCheckPoint, string &sError);
|
||||
bool SlaveConnect(uint8_t *bufCmd, const int bufSize, bool bCheckPoint, string &sError);
|
||||
bool SendToTask(const uint32_t cid, const uint16_t command, uint8_t *bufPtr, const int bufSize);
|
||||
bool FilterCommand(uint8_t *bufCmdIn, uint32_t *idOut, uint8_t **pContentBuf);
|
||||
void *AdminContext(const uint8_t op, const uint32_t id, HCtxForward hInput);
|
||||
|
Loading…
Reference in New Issue
Block a user