Repository navigation
Conversation
…-threadx#434) The SNMPv3 USM parser copies msgUserName into nx_snmp_agent_v3_security_user_name using _nx_snmp_utility_octet_get with sizeof(...) as the bound, and appends a null terminator at the returned size index. Because the array is 64 bytes (NX_SNMP_MAX_USER_NAME), a 64-byte user name writes a null terminator at index 64, which is one byte past the array. In NX_SNMP_AGENT, nx_snmp_agent_v3_security_user_name_size immediately follows nx_snmp_agent_v3_security_user_name with no padding. On little-endian architectures, writing 0 to index 64 clears the low byte of the size field, corrupting the length from 64 to 0 and causing the agent to handle the request as an empty-username discovery packet. _nx_snmp_utility_octet_get is now passed sizeof(...) - 1 at the call site, reserving room for the null terminator. Names exceeding 63 bytes are rejected as invalid packets, while valid names up to 63 bytes remain within bounds. Signed-off-by: Dev dev <kalpanagola9897@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #434
In addons/snmp/nxd_snmp.c, _nx_snmp_utility_octet_get was called with the full buffer size of nx_snmp_agent_v3_security_user_name (64 bytes), leaving no room for the null terminator. When a 64-byte username was received, writing the null terminator at index 64 wrote one byte past the array and corrupted the adjacent nx_snmp_agent_v3_security_user_name_size field, making the agent treat the request as an empty discovery packet. I fixed this by passing sizeof(agent_ptr -> nx_snmp_agent_v3_security_user_name) - 1 to _nx_snmp_utility_octet_get, which reserves one byte for the null terminator, safely keeping valid usernames within bounds and properly rejecting any username longer than 63 bytes.