staging: vc04_services: use snprintf instead of sprintf

All the occurrences of sprintf usage under vc04_services can be safely
replaced by snprintf, so as to avoid any possible overflow.

Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
Suggested-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: "Ricardo B. Marliere" <ricardo@marliere.net>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20231025122632.307385-4-ricardo@marliere.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Ricardo B. Marliere 2023-10-25 09:26:34 -03:00 committed by Greg Kroah-Hartman
parent 75c1e5968f
commit 3d69b023a9
2 changed files with 9 additions and 9 deletions

View File

@ -855,7 +855,7 @@ static int vidioc_enum_input(struct file *file, void *priv,
return -EINVAL;
inp->type = V4L2_INPUT_TYPE_CAMERA;
sprintf((char *)inp->name, "Camera %u", inp->index);
snprintf((char *)inp->name, sizeof(inp->name), "Camera %u", inp->index);
return 0;
}

View File

@ -1451,12 +1451,12 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service,
}
if (use_type == USE_TYPE_VCHIQ) {
sprintf(entity, "VCHIQ: ");
snprintf(entity, sizeof(entity), "VCHIQ: ");
entity_uc = &arm_state->peer_use_count;
} else if (service) {
sprintf(entity, "%p4cc:%03d",
&service->base.fourcc,
service->client_id);
snprintf(entity, sizeof(entity), "%p4cc:%03d",
&service->base.fourcc,
service->client_id);
entity_uc = &service->service_use_count;
} else {
vchiq_log_error(state->dev, VCHIQ_SUSPEND, "%s null service ptr", __func__);
@ -1506,12 +1506,12 @@ vchiq_release_internal(struct vchiq_state *state, struct vchiq_service *service)
}
if (service) {
sprintf(entity, "%p4cc:%03d",
&service->base.fourcc,
service->client_id);
snprintf(entity, sizeof(entity), "%p4cc:%03d",
&service->base.fourcc,
service->client_id);
entity_uc = &service->service_use_count;
} else {
sprintf(entity, "PEER: ");
snprintf(entity, sizeof(entity), "PEER: ");
entity_uc = &arm_state->peer_use_count;
}