From patchwork Wed Oct 25 12:26:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ricardo B. Marliere" X-Patchwork-Id: 13436091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 22E40C0032E for ; Wed, 25 Oct 2023 12:28:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=lhZoUM419tq/X4p4+b+MsnA0coyFlk/ylns8FUNceFU=; b=TA/b/T+VgpDBm0 TTdbzbBLD9s4UujiHSwB0+bYnNHk8teOGeYZVOc6wgJBVZXn5iTljnL8Rukp3ZGv38RzsvLOotz6T BCRn1T0TN1/e0yYm90lTu9wm5/mwjU5Q3tL4kfW2+WK3v0kZk98K/w11hniIAKfxCyZmQ6Xsz4hoq uY2XSnRax3+2f2VSSrSUpPe/mwHAYqbgndy9w2pimJbml0G1Jwfc8Xs8zU4DKVTSitIfXPMCBjj1w lwQ83Cj9wrrfNBaLHNvbtnIn1YapEQ9OuJaHbH0VN2JleTN/JB0mZNXREtNx/IEKN5xSLMGj20D4C +vUgo8m4Gm/+LIpMVctg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvcz0-00CIrZ-25; Wed, 25 Oct 2023 12:27:34 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qvcyx-00CIq8-1h; Wed, 25 Oct 2023 12:27:32 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1bf55a81eeaso40706965ad.0; Wed, 25 Oct 2023 05:27:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698236850; x=1698841650; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dkim-signature:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=wG0ZUl3gifsade13W7t1FoQuB4FnC3hvjN14YAls8W8=; b=oo+N8mvTprgUMvbVKjW/c+ZP/3xM05DzCVAJuaOhwh8EyJzp89j+MRvzA1XkCStHfp dx6LmPiTowQZ0xJMKl74+FBANFUi65XfU5xe7T4bgVrOQ46SjquaXYGAPeUg6y3UxONk ukeCI95rLZuMEjtRGq9HiBsXhKT1xTmfsrfF5Wgyu9JrfjEWpVG7fwNxJhwa2lYKyxG/ jhn6+y/GWeNFBhqULBVyRJA5sX9ryngu0m+RFLrTmAA/BbqwGdl20+7ppvaYrvFAoDFp J5NZr89homPBigBv9AOCVCHqBLPFW8eibPjz+C/OVxO1NQ5NZmCDCG66xwGklO4zxB58 q8gQ== X-Gm-Message-State: AOJu0YzLmgAbLw4gv+hvQeTS39Z+jogm+CtSqQ+Kky0adaN8o/JnOtBb +Fb6iBLz6lJSxu6tpeGiJgExbT/d3K4xpLTh X-Google-Smtp-Source: AGHT+IE9tQK1viHVcwtIECPzpdaqlTjg12DIHJKqddhEn0ApTz8dcZuBMoyynsaPPV5aSo8wTScCuw== X-Received: by 2002:a17:903:3093:b0:1c3:749f:6a5d with SMTP id u19-20020a170903309300b001c3749f6a5dmr9969948plc.4.1698236849721; Wed, 25 Oct 2023 05:27:29 -0700 (PDT) Received: from mail.marliere.net ([24.199.118.162]) by smtp.gmail.com with ESMTPSA id w17-20020a1709029a9100b001b89466a5f4sm9019669plp.105.2023.10.25.05.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 05:27:29 -0700 (PDT) From: "Ricardo B. Marliere" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marliere.net; s=2023; t=1698236845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=wG0ZUl3gifsade13W7t1FoQuB4FnC3hvjN14YAls8W8=; b=inmdc+0K5wrUGW0jTTWmP30k8xL5pojISO2gfCEDgPacAcdySlLksFrrXJCPmcgd2OHuKQ IDnTVbt+oh9o88OMujxbSlHMtaYwrYB8hV12qV102WqDh+cbqWjGicpXFrm6jJQQBe4LKL izey6X3Msy+iTvA0tgfH8EcBPQmfMdTl8Jr2b29Ey5JmAB6CSYI+TTevDA7ZoUyWqw+TpQ FeSV9P8eCm/u8DPp00K+MxI2ePz42gJp+N2SPXjcDomRGPRfcgX0wIjpoAy/tnoCqH3YHC UGN1zxCfnPBpzItU1QLYfgz1E1feylSyorF6MnMQirNBStQct9NhRkmIHqwwuw== Authentication-Results: ORIGINATING; auth=pass smtp.auth=ricardo@marliere.net smtp.mailfrom=ricardo@marliere.net To: Greg Kroah-Hartman , Florian Fainelli , Ray Jui , Scott Branden , Umang Jain , Kieran Bingham , Laurent Pinchart , =?utf-8?q?Uwe_Kleine-?= =?utf-8?q?K=C3=B6nig?= , Stefan Wahren , Peter Zijlstra , Arnd Bergmann Cc: bcm-kernel-feedback-list@broadcom.com, linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, "Ricardo B. Marliere" , Dan Carpenter Subject: [PATCH] staging: vc04_services: use snprintf instead of sprintf Date: Wed, 25 Oct 2023 09:26:34 -0300 Message-ID: <20231025122632.307385-4-ricardo@marliere.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231025_052731_581979_C1080CB1 X-CRM114-Status: GOOD ( 10.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Suggested-by: Umang Jain Signed-off-by: Ricardo B. Marliere Reviewed-by: Umang Jain --- .../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; }