diff options
author | Fred Sundvik <fsundvik@gmail.com> | 2016-02-20 15:28:42 +0200 |
---|---|---|
committer | Fred Sundvik <fsundvik@gmail.com> | 2016-02-20 15:28:42 +0200 |
commit | ea346125e8ef0c14e1566070380ec777d4a1a56a (patch) | |
tree | 60b66797048791077b035e90f1bfe2ce61b1c748 /serial_link/protocol | |
parent | 532f98eef6a29ae83d7ed61fbc4e25e23ad972d5 (diff) |
Add some validation for invalid router destinations
Diffstat (limited to 'serial_link/protocol')
-rw-r--r-- | serial_link/protocol/frame_router.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/serial_link/protocol/frame_router.c b/serial_link/protocol/frame_router.c index c61c50ebd6..890ebbe9ea 100644 --- a/serial_link/protocol/frame_router.c +++ b/serial_link/protocol/frame_router.c @@ -33,7 +33,9 @@ void router_set_master(bool master) { void route_incoming_frame(uint8_t link, uint8_t* data, uint16_t size){ if (is_master) { - transport_recv_frame(data[size-1], data, size - 1); + if (link == DOWN_LINK) { + transport_recv_frame(data[size-1], data, size - 1); + } } else { if (link == UP_LINK) { @@ -52,11 +54,15 @@ void route_incoming_frame(uint8_t link, uint8_t* data, uint16_t size){ void router_send_frame(uint8_t destination, uint8_t* data, uint16_t size) { if (destination == 0) { - data[size] = 1; - validator_send_frame(UP_LINK, data, size + 1); + if (!is_master) { + data[size] = 1; + validator_send_frame(UP_LINK, data, size + 1); + } } else { - data[size] = destination; - validator_send_frame(DOWN_LINK, data, size + 1); + if (is_master) { + data[size] = destination; + validator_send_frame(DOWN_LINK, data, size + 1); + } } } |