security: fix strcpy into fixed-size buffer in netjack2 driver

Memory Safety: Low

strcpy() into the fixed-size params.type[8] buffer has no bounds
checking. While the current literal string "params" fits exactly,
this pattern is fragile and would silently overflow if the string
were ever changed. Use snprintf() with sizeof() for bounds safety,
consistent with how params.name and params.follower_name are
handled on the lines immediately following.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Wim Taymans 2026-04-27 16:13:34 +02:00
parent 9b845f4415
commit d456be1943

View file

@ -1006,7 +1006,7 @@ static int send_follower_available(struct impl *impl)
client_name = DEFAULT_CLIENT_NAME;
spa_zero(params);
strcpy(params.type, "params");
snprintf(params.type, sizeof(params.type), "params");
params.version = htonl(NJ2_NETWORK_PROTOCOL);
params.packet_id = htonl(NJ2_ID_FOLLOWER_AVAILABLE);
snprintf(params.name, sizeof(params.name), "%s", client_name);