- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the code generated for the SMBusSlave_v5_20 component there is an error in the code that validates the buffer length:
In the header, the validity of the index is checked as follows:
/* Helpers to check if a command size is valid. Greater or equal is used to take
* into account the PEC byte. For example, when the PEC is enabled and a host
* writes to a word command, the correct index value is 2 if the host does not
* send PEC, and 3 if it does. The index value greater than 3 results in a Host
* Sends Too Many Bytes fault and is detected in the ISR.
*/
#define HOST_PMBusSlave_CMD_LEN_VALID (HOST_PMBusSlave_bufferIndex >= HOST_PMBusSlave_bufferSize)
So the check is valid when the index exceeds the size of the buffer.
Here is the usage of the above check:
case HOST_PMBusSlave_MFR_ID:
if(HOST_PMBusSlave_CMD_LEN_VALID)
{
(void)memcpy((void *)HOST_PMBusSlave_cmdDataPtr, (const void *)HOST_PMBusSlave_buffer, (uint32)HOST_PMBusSlave_bufferSize);
}
break;
The sign in the expression should be changed to "<="
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The term "buffersize" is used in Cypress components to indicate the number of bytes in the buffer, not the maximum count the buffer can hold. As you can see the SMBusSlave_1_bufferSize is an uint8 and not a fixed #define.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The term "buffersize" is used in Cypress components to indicate the number of bytes in the buffer, not the maximum count the buffer can hold. As you can see the SMBusSlave_1_bufferSize is an uint8 and not a fixed #define.
Bob