Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2523003rda; Wed, 25 Oct 2023 05:27:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNH8K3C2/UGa1shvRDvRUtTMsKoiwKENusbL/YpUR6PeN9vC1MT+Q1KLyWx6dy9tWV4odx X-Received: by 2002:a05:6808:96:b0:3a7:d566:8b5e with SMTP id s22-20020a056808009600b003a7d5668b5emr15125458oic.44.1698236870090; Wed, 25 Oct 2023 05:27:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698236870; cv=none; d=google.com; s=arc-20160816; b=xQDbV8zWADt/J1JPvWy4R/rb3Sv3KUgpDAS9vMmykycyLbe+OONst6JYzTLO5e+DSN MPpZp1FCQElDOdWUhedLO16vVqzqH/hnsXv/u79KBIuPUr9k3MRwgYrrLdiWMX5kE4w5 h0mkP52+aW4quryfZuPjecDu+ha6FRlPgykhLA77gJp5mHHpyqVpRymV9rz0PncUqJwJ v1uBowI1gC8HXNnutal6Cr+qtzAQTqYQLFSNSW5MUWkimSplazXYupYZd1kVhNLBgMFT 7/psnszPhjNEN6qjVm1+NTmUhlauRU1v0AFtdRXQX2OhCWugCivajb6m2XPSGodTNDd/ tODg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:dkim-signature:from; bh=wG0ZUl3gifsade13W7t1FoQuB4FnC3hvjN14YAls8W8=; fh=vSbTWslP7pPJiV4t5n5KpLddhnwSdC/6Ar6/fMaqK34=; b=mptiWsgWNS6ti6uTkuFm4NAXJNDparWmB2vaWfZGVzH2q5KHES3biG2qA1kc1hYqSw L8WHACdzeJqkrTgk6VtKmYOPfomPPYmHOWJLNm4y2mij5JcNRqDjl6S30V6caK9ViPSb fHUToErnh3+iaywStyTKkm7wBWJUfb49tV3+RYkuLruarizTk7FR1aduxIr7kYKCXe7u WUl63DI9/Trx1Ji4hV0uFSpsJVlm/RJRsYB6xAFbpLRlEKwvQJxk5/CutL3Vf5pW/L/0 4tVKT76Qfk78BvagGAnZmNxKtbO+rJMHm69OwdLmpg5AzEroR4ZdzwgfGWIH+dS79p2L j23g== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@marliere.net header.s=2023 header.b=inmdc+0K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id g22-20020a25b116000000b00d9ab6c99aa4si10411273ybj.589.2023.10.25.05.27.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 05:27:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@marliere.net header.s=2023 header.b=inmdc+0K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E46FC8027A07; Wed, 25 Oct 2023 05:27:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343922AbjJYM1e (ORCPT + 99 others); Wed, 25 Oct 2023 08:27:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234863AbjJYM1c (ORCPT ); Wed, 25 Oct 2023 08:27:32 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 653D8C1 for ; Wed, 25 Oct 2023 05:27:30 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1cace3e142eso37249615ad.3 for ; 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=I16se2PyjeUFHVVOmxV4LaG1wS9TjN31n6uTxQwsWXshj918Q5DpcUel2QSWzoQ1RV JALxtLE6j6KARK1WDgkuLME6K4v0Blf18t5faPoCTCaq6GfWKyZjiTiV0uFmZnynClTz tZMUoemFfNdKDqBBSmsKeibp1EQmR5VCMSZm7KiTJErU0PgZbcwpWZOOWoD8zswHEDie f/yJn//B1lsQ/xzKYGwJRIzrUL0iMpNljNMbUv/1Db+fMpulOFTuWOsSLyCPtXCK9Fds eo6vm5wDKAhrhqpgQ+bR6btz2uXZ59gb7nRWsgv4dhKwno33QRXg3xz1moM61B+pYVAz m0Gg== X-Gm-Message-State: AOJu0YwsZyiO75Sl8LkMtzVS743I7eS3QJwtKpCmNKXKLVmP6dHKyus/ bBoJU4x0tJTjZnhuC+eKC0Q= 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=20Kleine-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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 25 Oct 2023 05:27:47 -0700 (PDT) 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 --- .../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; } -- 2.42.0