uavcannode: Fix VCS Version Reporting in Node Info for UAVCAN Nodes (#26567)

long is a 32-bit signed integer, which means the maximum it will hold is 0x7FFFFFFF.

strtol is overflowing, resulting in clamping the value to LONG_MAX (or 0x7FFFFFFF) and returns that instead.

Fixes by using strtoul, which corrects the returned value.

Can be tested by building a UAVCAN Node on the tag v1.16.1, flashing and checking the value displayed in dronecan_gui_tool. Screenshot added for convenience.
This commit is contained in:
James 2026-02-24 12:47:38 +11:00 committed by GitHub
parent 77a3ab7aad
commit af25a31861
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -468,7 +468,7 @@ UavcanNode::fill_node_info()
char fw_git_short[9] = {};
std::memmove(fw_git_short, px4_firmware_version_string(), 8);
char *end = nullptr;
swver.vcs_commit = std::strtol(fw_git_short, &end, 16);
swver.vcs_commit = std::strtoul(fw_git_short, &end, 16);
swver.optional_field_flags |= swver.OPTIONAL_FIELD_FLAG_VCS_COMMIT;
// Too verbose for normal operation

View File

@ -284,7 +284,7 @@ void UavcanNode::fill_node_info()
char fw_git_short[9] = {};
std::memmove(fw_git_short, px4_firmware_version_string(), 8);
char *end = nullptr;
swver.vcs_commit = std::strtol(fw_git_short, &end, 16);
swver.vcs_commit = std::strtoul(fw_git_short, &end, 16);
swver.optional_field_flags |= swver.OPTIONAL_FIELD_FLAG_VCS_COMMIT;
swver.major = AppDescriptor.major_version;
swver.minor = AppDescriptor.minor_version;