Skip to content

Commit 3d69b02

Browse files
rbmarlieregregkh
authored andcommitted
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>
1 parent 75c1e59 commit 3d69b02

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ static int vidioc_enum_input(struct file *file, void *priv,
855855
return -EINVAL;
856856

857857
inp->type = V4L2_INPUT_TYPE_CAMERA;
858-
sprintf((char *)inp->name, "Camera %u", inp->index);
858+
snprintf((char *)inp->name, sizeof(inp->name), "Camera %u", inp->index);
859859
return 0;
860860
}
861861

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,12 +1451,12 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service,
14511451
}
14521452

14531453
if (use_type == USE_TYPE_VCHIQ) {
1454-
sprintf(entity, "VCHIQ: ");
1454+
snprintf(entity, sizeof(entity), "VCHIQ: ");
14551455
entity_uc = &arm_state->peer_use_count;
14561456
} else if (service) {
1457-
sprintf(entity, "%p4cc:%03d",
1458-
&service->base.fourcc,
1459-
service->client_id);
1457+
snprintf(entity, sizeof(entity), "%p4cc:%03d",
1458+
&service->base.fourcc,
1459+
service->client_id);
14601460
entity_uc = &service->service_use_count;
14611461
} else {
14621462
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)
15061506
}
15071507

15081508
if (service) {
1509-
sprintf(entity, "%p4cc:%03d",
1510-
&service->base.fourcc,
1511-
service->client_id);
1509+
snprintf(entity, sizeof(entity), "%p4cc:%03d",
1510+
&service->base.fourcc,
1511+
service->client_id);
15121512
entity_uc = &service->service_use_count;
15131513
} else {
1514-
sprintf(entity, "PEER: ");
1514+
snprintf(entity, sizeof(entity), "PEER: ");
15151515
entity_uc = &arm_state->peer_use_count;
15161516
}
15171517

0 commit comments

Comments
 (0)