From ee9f8620d71680740617fe97bb462ebda8c3f7aa Mon Sep 17 00:00:00 2001 From: aleks Date: Mon, 8 Feb 2021 09:25:25 +0100 Subject: [PATCH] freemodbus: potential loss of significant bits and auto merge issues * Original commit: espressif/esp-idf@9457555173612749ea08e138855b8aebdca3c6b0 --- components/freemodbus/modbus/functions/mbfuncholding.c | 2 +- .../freemodbus/tcp_master/modbus_controller/mbc_tcp_master.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/freemodbus/modbus/functions/mbfuncholding.c b/components/freemodbus/modbus/functions/mbfuncholding.c index e51b7de..6038738 100644 --- a/components/freemodbus/modbus/functions/mbfuncholding.c +++ b/components/freemodbus/modbus/functions/mbfuncholding.c @@ -184,7 +184,7 @@ eMBFuncReadHoldingRegister( UCHAR * pucFrame, USHORT * usLen ) usRegAddress++; usRegCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF] << 8 ); - usRegCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF + 1] ); + usRegCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF + 1] ); /* Check if the number of registers to read is valid. If not * return Modbus illegal data value exception. diff --git a/components/freemodbus/tcp_master/modbus_controller/mbc_tcp_master.c b/components/freemodbus/tcp_master/modbus_controller/mbc_tcp_master.c index 158aa7a..ab8964e 100644 --- a/components/freemodbus/tcp_master/modbus_controller/mbc_tcp_master.c +++ b/components/freemodbus/tcp_master/modbus_controller/mbc_tcp_master.c @@ -384,7 +384,7 @@ static esp_err_t mbc_tcp_master_set_request(char* name, mb_param_mode_t mode, mb continue; // The length of strings is different then check next record in the table } // Compare the name of parameter with parameter key from table - uint8_t comp_result = memcmp((const char*)name, (const char*)reg_ptr->param_key, (size_t)param_key_len); + int comp_result = memcmp((const void*)name, (const void*)reg_ptr->param_key, (size_t)param_key_len); if (comp_result == 0) { // The correct line is found in the table and reg_ptr points to the found parameter description request->slave_addr = reg_ptr->mb_slave_addr;