Commit 3d69b023 authored by Ricardo B. Marliere's avatar Ricardo B. Marliere Committed by Greg Kroah-Hartman
Browse files

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: default avatarDan Carpenter <dan.carpenter@linaro.org>
Suggested-by: default avatarUmang Jain <umang.jain@ideasonboard.com>
Signed-off-by: default avatar"Ricardo B. Marliere" <ricardo@marliere.net>
Reviewed-by: default avatarUmang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20231025122632.307385-4-ricardo@marliere.net


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 75c1e596
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
}

+8 −8
Original line number Diff line number Diff line
@@ -1451,10 +1451,10 @@ 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",
		snprintf(entity, sizeof(entity), "%p4cc:%03d",
			 &service->base.fourcc,
			 service->client_id);
		entity_uc = &service->service_use_count;
@@ -1506,12 +1506,12 @@ vchiq_release_internal(struct vchiq_state *state, struct vchiq_service *service)
	}

	if (service) {
		sprintf(entity, "%p4cc:%03d",
		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;
	}