mirror of
https://github.com/linux-can/can-utils.git
synced 2026-11-04 07:21:13 +01:00
j1939acd: check length and address of Commanded Address messages
The Commanded Address message contains the 8 byte NAME and the new source address. The received length was not checked, so the new source address was taken from stale or uninitialized content of the receive buffer for short messages. Also the idle and global addresses were passed to claim_address() which terminates the daemon when bind() fails. Check for the complete message length and only accept unicast addresses. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
This commit is contained in:
@@ -618,6 +618,12 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
break;
|
||||
case J1939_PGN_ADDRESS_COMMANDED:
|
||||
/* 8 bytes NAME + 1 byte new source address */
|
||||
if (ret < 9)
|
||||
break;
|
||||
/* only accept valid unicast addresses */
|
||||
if (dat[8] > J1939_MAX_UNICAST_ADDR)
|
||||
break;
|
||||
if (!host_is_little_endian())
|
||||
bswap(dat, 8);
|
||||
memcpy(&cmd_name, dat, 8);
|
||||
|
||||
Reference in New Issue
Block a user