fix(crane_sender): SSL/GrSim送信パスのrobot_states_境界チェック追加 - #1384
Open
HansRobo wants to merge 1 commit into
Open
Conversation
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.
概要
crane_senderの SSL/GrSim 送信パスにおいて、robot_states_への範囲外アクセスが発生しうる問題を修正します。IBIS 送信パスと同じ境界チェックを追加し、3 つの送信パスでガードを統一します。問題
sendSSLとsendGrSimはrobot_states_[command.robot_id]を境界チェックなしでアクセスしていました。robot_states_は固定長のstd::array<PerRobotState, CommConfig::AI_CMD_V2_ROBOT_NUM>(要素数 11)です。command.robot_idはuint8(0-255) のため、11 以上の値が渡されると配列範囲外参照が発生します。さらにconvertToLocalVelocityは受け取ったstateへの書き込みを行うため、範囲外書き込みによる未定義動作(メモリ破壊)につながります。原因
IBIS 送信パス
sendIbisにはif (command.robot_id < CommConfig::AI_CMD_V2_ROBOT_NUM)のガードが存在しますが、SSL/GrSim パスには同等のガードがありませんでした。上流の入力検証も不十分で、teleop の
robot_idパラメータは無検証で 11 以上を設定可能であり、local_planner のガードも 20 未満しか弾かないため、範囲外 ID が送信ノードに到達しえます。修正内容
sendSSLおよびsendGrSimのrobot_states_アクセス前に、sendIbisと同じ境界条件command.robot_id >= CommConfig::AI_CMD_V2_ROBOT_NUMを判定するガードを追加しました。範囲外 ID のコマンドはcontinueでスキップします。また、無言でスキップすると不具合の発見が困難になるため、スキップ時に
RCLCPP_WARN_THROTTLE(1 秒スロットル)で範囲外 ID を警告ログに出力します。これによりログ氾濫を避けつつ、異常な ID の混入を検知できます。これにより SSL / GrSim / IBIS の 3 送信パスで境界チェックが統一されました。
検証
cwm の独立オーバーレイ worktree 上で
colcon build(--no-rdeps)を実行し、crane_senderパッケージのコンパイルが正常に完了することを確認しました(Build complete.)。stderr は gtest_vendor 由来の CMake 非推奨警告のみで、本修正に起因するエラー・警告はありません。レビュー観点
本PRはソースコード監査ワークフローで検出・敵対的検証されたバグに対する単一修正です。