Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DroneCAN: fixed handling of bad multi-frame pkts and check array bounds #26186

Merged
merged 4 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test_sitl_periph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ jobs:
- name: run dronecan dsdlc generator test
run: |
PATH="/github/home/.local/bin:$PATH"
python -m pip install --upgrade dronecan
python modules/DroneCAN/dronecan_dsdlc/dronecan_dsdlc.py -O dsdlc_generated modules/DroneCAN/DSDL/uavcan modules/DroneCAN/DSDL/dronecan modules/DroneCAN/DSDL/com --run-test

- name: build sitl_periph_universal
Expand Down
5 changes: 4 additions & 1 deletion Tools/AP_Periph/can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,10 @@ void AP_Periph_FW::handle_allocation_response(CanardInstance* canard_instance, C
// Copying the unique ID from the message
uavcan_protocol_dynamic_node_id_Allocation msg;

uavcan_protocol_dynamic_node_id_Allocation_decode(transfer, &msg);
if (uavcan_protocol_dynamic_node_id_Allocation_decode(transfer, &msg)) {
// failed decode
return;
}

// Obtaining the local unique ID
uint8_t my_unique_id[sizeof(msg.unique_id.data)];
Expand Down
11 changes: 8 additions & 3 deletions Tools/ardupilotwaf/dronecangen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os
import os.path
from xml.etree import ElementTree as et
import subprocess

class dronecangen(Task.Task):
"""generate uavcan header files"""
Expand All @@ -21,9 +22,10 @@ def run(self):
src = self.env.get_flat('SRC')
dsdlc = self.env.get_flat("DC_DSDL_COMPILER")

ret = self.exec_command(['{}'.format(python),
'{}'.format(dsdlc),
'-O{}'.format(out)] + [x.abspath() for x in self.inputs])
cmd = ['{}'.format(python),
'{}'.format(dsdlc),
'-O{}'.format(out)] + [x.abspath() for x in self.inputs]
ret = self.exec_command(cmd)
if ret != 0:
# ignore if there was a signal to the interpreter rather
# than a real error in the script. Some environments use a
Expand All @@ -32,6 +34,9 @@ def run(self):
Logs.warn('dronecangen crashed with code: {}'.format(ret))
ret = 0
else:
Logs.warn('dronecangen: cmd=%s ' % str(cmd))
# re-run command with stdout visible to see errors
subprocess.call(cmd)
Logs.error('dronecangen returned {} error code'.format(ret))
return ret

Expand Down
2 changes: 1 addition & 1 deletion wscript
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ def _build_dynamic_sources(bld):
if (bld.get_board().with_can or bld.env.HAL_NUM_CAN_IFACES) and not bld.env.AP_PERIPH:
bld(
features='dronecangen',
source=bld.srcnode.ant_glob('modules/DroneCAN/DSDL/* libraries/AP_DroneCAN/dsdl/*', dir=True, src=False),
source=bld.srcnode.ant_glob('modules/DroneCAN/DSDL/[a-z]* libraries/AP_DroneCAN/dsdl/[a-z]*', dir=True, src=False),
output_dir='modules/DroneCAN/libcanard/dsdlc_generated/',
name='dronecan',
export_includes=[
Expand Down
Loading