From: Umang Jain <umang.jain@ideasonboard.com>
To: "Ricardo B. Marliere" <ricardo@marliere.net>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Florian Fainelli" <florian.fainelli@broadcom.com>,
"Ray Jui" <rjui@broadcom.com>,
"Scott Branden" <sbranden@broadcom.com>,
"Kieran Bingham" <kieran.bingham@ideasonboard.com>,
"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Stefan Wahren" <stefan.wahren@i2se.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Arnd Bergmann" <arnd@arndb.de>
Cc: Dan Carpenter <dan.carpenter@linaro.org>,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
bcm-kernel-feedback-list@broadcom.com,
linux-rpi-kernel@lists.infradead.org,
linux-kernel-mentees@lists.linuxfoundation.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] staging: vc04_services: use snprintf instead of sprintf
Date: Wed, 25 Oct 2023 18:20:12 +0530 [thread overview]
Message-ID: <92b54548-6276-29c3-01af-80136c28da0c@ideasonboard.com> (raw)
In-Reply-To: <20231025122632.307385-4-ricardo@marliere.net>
Hi Ricardo,
Thank you for the patch
On 10/25/23 5:56 PM, Ricardo B. Marliere wrote:
> 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>
LGTM,
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
> .../bcm2835-camera/bcm2835-camera.c | 2 +-
> .../interface/vchiq_arm/vchiq_arm.c | 16 ++++++++--------
> 2 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
> index e860fb89d42e..e6e89784d84b 100644
> --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
> +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
> @@ -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;
> }
>
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> index de6a24304a4d..9fb8f657cc78 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> @@ -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;
> }
>
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
prev parent reply other threads:[~2023-10-25 12:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-25 12:26 [PATCH] staging: vc04_services: use snprintf instead of sprintf Ricardo B. Marliere
2023-10-25 12:50 ` Umang Jain [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=92b54548-6276-29c3-01af-80136c28da0c@ideasonboard.com \
--to=umang.jain@ideasonboard.com \
--cc=arnd@arndb.de \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=dan.carpenter@linaro.org \
--cc=florian.fainelli@broadcom.com \
--cc=gregkh@linuxfoundation.org \
--cc=kieran.bingham@ideasonboard.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=linux-staging@lists.linux.dev \
--cc=peterz@infradead.org \
--cc=ricardo@marliere.net \
--cc=rjui@broadcom.com \
--cc=sbranden@broadcom.com \
--cc=stefan.wahren@i2se.com \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).