Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2944939pxv; Sun, 18 Jul 2021 06:16:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJ2urqzvgSJyFRmwgKaVoqnheDuk5caG+XP22H3urAVM9B3jWkJxzHAUv5AeDJWNe5LXsm X-Received: by 2002:a05:6402:270d:: with SMTP id y13mr28774016edd.66.1626614164384; Sun, 18 Jul 2021 06:16:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626614164; cv=none; d=google.com; s=arc-20160816; b=v+b0MK0m4ZU3b5E+ibUWTJfUf5b53sLP6nF9SH4/mtHsrKj9ibgMX3lC9gyrSwcCR2 aa9ctBynWURKBnYVbmbETJZKP/FiQ+0clNF34h/n6fS+xMtDAb+sg+oh8x36oFE/oGZF C3Y0nSCnHqBhagy6EUg0lEYQL4CJWRa/3sUcRV99YoBU2SOQlQA8xd0bTMXznfeoJ/NC asdqqV051uC5kMGBqhi36Vn+INvHyehhqc+coLEJEbZqPcSix8ThukQ1osMpNVvQ71fJ ChRtMbKYNWCmEb9/ezjwBps3ja+HMO6e8u9vSsEFVDQ9LX0wcfMxXStNIPA+kgKfiARg OWnQ== 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:from:dkim-signature; bh=D3ALSLjzk3oRNyLeiGzBNRDwpFXKqcBx565BCY0urnQ=; b=sV46Tm9jpP/lDXpnmeI+QovlHD875WTVdSXRq2FwfqykBegd71G3hjbGArnkXiPvP8 iMmTV4njO2qEnkARXptu+t2w213lPDqV2ksz0JWC/if/m3rH1I/6dShBpxEEXKPvzZ6+ 44HP0aXdQMDgHafPvsQ8Dd+7BTjrupPpkcvRpkYId0GU11xdv+r3nfm/YPfo8SQzTvDs nf+P2/sjZARFG28IscxV7PZQK7cLhkDRkGY1poW7+M2Swe4Z9g3ziDwNuH3o6sCjEs/c wTk2u+7abZR2CmDRDfDHSjLH/Fhf0VKo5gNpWEwuJ6AZeMjFoQKJ7XSK9DmMBWLCaRwj VPVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=RTunmgyV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y62si18345011ede.555.2021.07.18.06.15.40; Sun, 18 Jul 2021 06:16:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=RTunmgyV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233819AbhGRNQC (ORCPT + 99 others); Sun, 18 Jul 2021 09:16:02 -0400 Received: from mout.gmx.net ([212.227.17.20]:36851 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232859AbhGRNQC (ORCPT ); Sun, 18 Jul 2021 09:16:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1626613967; bh=CMvGExjMQupZPMM62nT0Q6JQOogckE+ME36zM5PHuC8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=RTunmgyV+vLhQr3GLSNe+8yCGuvuj/oyle9SRy+kcJHqI2xoC05WSP3nEmuFGtu2t 2avtZSC7+8iVDW80mauCcOaQOZVkQMYNync8tOfcWhxFmPilvYi38E0DQSk17El7yB TUIKh++cVOB7sRT70pOjdf7nKxO/WsZD9Ug4MAh0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([83.52.228.41]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MOREc-1lkq9p1MKs-00PwA5; Sun, 18 Jul 2021 15:12:47 +0200 From: Len Baker To: Greg Kroah-Hartman , Nicolas Saenz Julienne , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com Cc: Len Baker , Stefan Wahren , Amarjargal Gundjalam , linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging/vc04_services: Remove all strcpy() uses in favor of strscpy() Date: Sun, 18 Jul 2021 15:12:17 +0200 Message-Id: <20210718131217.3806-1-len.baker@gmx.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:4CWYGQVn1yChMQul7TO5K5N/vYGRpc5gC1NngggoplhCLQvq7UR Z/HWFm+d+hcQkbIxIBasqT68H7KghdhPfDoEwZXfqRQMHyfxew4AXTZZDgrS8fpcnssK6DH W4V5u7iImiY9vaTuTNYLFph00vhSYuu5PWhUOGhJIKl4OPGrxh8o/2gZlCceTasze/aOe2i gF4kCIz1mIVAM7ILbQlhQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:6S41qTiwtB8=:8/PB9bpLTNhvOD307p5f5m qAR7TmxiE5IeX1VSkkeNG+N1SCzLdK0rD7iVYRE/mWrJGPMQRAG/xbLNkMWFGGFQOQONZ93kI cjH0MnbrVB3+DqTajN26pTH68IvJ1xxtVybFelcQQiM9W2j7QPO0LDkMRUkj4Z3LMWJMkuc9G YXVyCfisG+IMtdkOG5Ud/l1CRd92SjIlbqt2sXSgLVgtcdwQrOBNz5tJDgNYuLtAqpOgAJNng Wa2PWH4wuy+H/k/r+d1Vqeo1gVfoXC9HchmKplG2m7Vv0kJqLXu6esIjHWQD11wVW+2zs7GrT zdMN21BIBDTJCJ2CSm71poakUtC7xhnMyBAVTpkyyw/VjGKbei6dxprm0W/y1GO+geOK38lk8 vg1yWwuQEziy31IMsnBjxrkzAOcTeoWfo1PSEwchbskRIguAIWyQ+tStjIe6gLfDDXa+DSTUa RDFQ4cpHUH+phhMUIAsesr9Ug8cXbbTrV883f4KVINRmVL3f5KFDPQjrjkRRe3FmQyzrPiZso lwwtnMvr0F5s49JDIgjH3gR+X+nyogkoEFOo9QKKTDUyswj3VeMNAh+CwNHissBoR0LDWEJLn H4kzTKG5QVe+Db6Z3JdjMGO+uIT5cyw86N2dd9/4WDnct6g2f8VKEoUUrcg8tJjlEusuyJL2i tlH7qtEwZqOS4sb6vDhGP5lWk33GU7zJwEbhVoUdyQuzvTMSCqwmJPYf54tfLLi6PxkY+mf+N HNVqEV6osjVT09uG0ThYk2cD8BRNTYijVuUt46Bkf5eiphpsBb5l+3w5gxnGFJ1V1adt/7ADw bX2roppqSR7M6nZysQEY/phrzUlJfJWb6ImZTLUu2raNLUp4+z00U6HUAsGd3ib9Ye3eMK6SD r8EZoU+OFnCGKkpH1edwVzlNu0fWAV9gVlCek0XKT+NQXOkC7itr5WWQ5Z1nlcKk8ELubPki8 8eWwHmI9ezL72rPK6Bu23atfD/7VmkhONWbYlM4ABl/wF7ch2HbSlfzgSR1gcLyVRNRR0CqzA 3r8j5oUSH840OEQIkBBh4BNz84ezFFw0qRx2rwuXjW4ZmM43c78AFtFwy6MgxA7zXtPYILO5z iOMiVuvhtKwwYiopnQh7BXM0UCFGkcnP7FI Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org strcpy() performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement is strscpy(). Signed-off-by: Len Baker =2D-- drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c= b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index df90c1f9d148..1b184d5c6b82 100644 =2D-- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -884,7 +884,7 @@ static int vidioc_querycap(struct file *file, void *pr= iv, vchiq_mmal_version(dev->instance, &major, &minor); - strcpy((char *)cap->driver, "bm2835 mmal"); + strscpy(cap->driver, "bm2835 mmal", sizeof(cap->driver)); snprintf((char *)cap->card, sizeof(cap->card), "mmal service %d.%d", major, minor); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.= c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 4f43e4213bfe..9429b8a642fb 100644 =2D-- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3716,7 +3716,7 @@ int vchiq_dump_service_state(void *dump_context, str= uct vchiq_service *service) sizeof(remoteport) - len2, " (client %x)", service->client_id); } else { - strcpy(remoteport, "n/a"); + strscpy(remoteport, "n/a", sizeof(remoteport)); } len +=3D scnprintf(buf + len, sizeof(buf) - len, =2D- 2.25.1