mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
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:
parent
77a3ab7aad
commit
af25a31861
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user