Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2223555pxv; Sat, 24 Jul 2021 09:07:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPk8KSAQmKRTiUU2CzlCwppW9M1Ugd6V1zNrrRgrHECa9etW2jQPOtJP53zkihUzkMGQh9 X-Received: by 2002:a02:9648:: with SMTP id c66mr9113052jai.73.1627142837032; Sat, 24 Jul 2021 09:07:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627142837; cv=none; d=google.com; s=arc-20160816; b=rme6C3gqRCVx9lqW0WWLKz3RH/VTBWQu7hubX8s++FTRHMv5BNJ760r73vJwu6js5B dG8ZxeXUu5+FLm4LS9WXgGXqsuNMqSx6lTF/v6+nDUx8y2t6AoTWbcesOGlOLgS7VVY0 ezNw6FSM/7azubCpCufDDh4/qnxn9EpHADrV+8yRbE6Rg1M5ZeHE/Ir6AngmbUr+6h6L ++CSBkzmo6o1jebaD+WzuRrBOPj0M4Pim5Enxa2p54wJDaPGXSepgREjINgeaJsWpbK6 hdm8K0G+ztNlrNi0+dZhg3+XuO6ZcKBp/UNYD0HcgCF8cFQSyDIV3NwfYvGMZz5APEVY A+XA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ktYea7j6GoeJm55glJC9yfFfNc6Hhv2p7yv6dkKbbxk=; b=Gn/6mp1/Mj1OY1ExiMmuS5NUxy5qA3OBPsZzQzpSwytfJQGw5UqDGcU/ODZNDuWEgN tC4TvvjFJIv+KlV7wwY7ahAm9rGennPTnnen1tHdSqx4t0ntwtzOvKxnTav5xr586nXr BhyRKGwleK4cuWD+HBEnLeAQJt7CavlQ93ZEBvf4j1WgJfzMdgrrX5VGMeSMjwB0TPRP Ch7J+NzOoFTSdR3vGzk35VlYbLdsN2rlZC7M7HdjRZZjVP//m1G7EqRLTMr49tkP8Ted husoFyfY8MunXQiQ/WoShGYuBIgjetZFtC3w1NqQhZrVrG5yMI0Y8CA9fqaHT5YJ3NYg dPkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=R5FpRZPb; 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 o2si25936423ilo.2.2021.07.24.09.07.03; Sat, 24 Jul 2021 09:07:17 -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=R5FpRZPb; 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 S229602AbhGXPYS (ORCPT + 99 others); Sat, 24 Jul 2021 11:24:18 -0400 Received: from mout.gmx.net ([212.227.15.19]:56719 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbhGXPYR (ORCPT ); Sat, 24 Jul 2021 11:24:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1627142669; bh=6kxx24+tNiTwiGUNlCYc0+udJ3yXQxBElRKKameUdnU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=R5FpRZPbkKdGoKh2n+vPr4/m9cWtCOYSGhFzS82nJ5xdfjbwNs4MkQgGaStaD2DrD +ZbHrcIjDX5WFd0sw2Z2kqfFhs5nYyENqw8zeyel8ZB39umdgVqdrLhcxQ1dO39tRj ayjON7htm0vVuFmzQ+W8cxDY4ADwYJW7TQm6kmhg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([83.52.228.41]) by mail.gmx.net (mrgmx005 [212.227.17.184]) with ESMTPSA (Nemesis) id 1MDQiS-1lxwU702L8-00AS7x; Sat, 24 Jul 2021 18:04:29 +0200 From: Len Baker To: Greg Kroah-Hartman Cc: Len Baker , Andy Shevchenko , Phil Reid , Geert Uytterhoeven , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] staging/fbtft: Remove all strcpy() uses Date: Sat, 24 Jul 2021 17:14:09 +0200 Message-Id: <20210724151411.9531-2-len.baker@gmx.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210724151411.9531-1-len.baker@gmx.com> References: <20210724151411.9531-1-len.baker@gmx.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:329MDQ8YYI419jtmxMfrFBjESTzOsFnksAGa5ruA+GfDttL7lWO wte8/djM2LhNs6aEPzKc7JtdjaOdDdMoNv0o6C+eFtqCWikMKFXqUIciDbQgSo5yVwiDl6X ZH/WD1FmYzPF1ja/WrdY5hztftD5klqmo8f6g8Ol4tUTKicTr8nD7tszuqCgpzW+TwDEApL QuYGl5kqbhqENSGRWrAvQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:TlzSNjjpZCc=:WL3ahatTWMY6d26wj6FmBM feg2Cl66/zRO4QSieaqZMJmneHGcFh76xjVo7ovVPictW2u806BykZUnKxUPCocZztniypk3X nF77c76931fexpNuPWQ2CDD2YK7k9mhpXvirYAUQ230vxEiWd1DvQ9Q6pdpTzCLySIXt73+5v iubuY58rFsK6vZ4NeQQcB8sslt4xyrKFt6dHj4MB06R43PwyV5+vPDoqRSlNHvuYfkiXDVu4E SNsJhb+MSAl3JkY+jkziYyTtEI5GopguWnXT8xP9tH1V1Xhh+azjhZdMZiuqjJV9dRCeXllac oTHd5PPv8EDrYF50oiP/bfhdNR6VthWzecALMNPdXYbFK2bueG58tkexxFnj/yz2HPiAMYmM9 YqRAtqKGJFpa0xUNodwuSTt3f2wY3VJxrIwf1AraROCYDIAEpfRrDtczFauKjI8L11KFubuXw KKi+39RRPA9JtZUuI6QlT/Gos8dAJvi4v5292TSnM07UNDiUMN30BT2Vynt7QKz3ijY1HZDfH KL69SaknYSuQryW9QQiaOOFzqWoIi99et87BAyfEYzVsobPvpfFPzNYXzx0Ju/tvdjVAVnnQq 2btdxJqc6G+FGoA7kN+/lSS+y8vgRPSRYLWt2Np16v/y1PLAM4S5bMCMLtErbfde+BJsRv60Z uZbW95IL2WcLSu8hGmN3Ry8T4CQuSwXk53VCdGLJdUk89TWTJSuIldTRKxcFk3Z5bWBJ9XbYA bM/IOxVOnE7E0U9YzisEUx8BEOEp9yz7DjGlKshpP+s2pKh0FFQihPmXjRHe8GCcmVJyFJrNG Ymg2ntUbT9jWgnyRFkE3UJabppENEfQGI6YqmS1XQLyAUxIZ12feKHrVeayFtsZjkjL4ypFrX ubUQqv/VY+4EdFB+gKv/8EgP8Lp2bbC4DlkSXLV31h9rS2ewwTdozl+XRsUVN3RvKWuGVVGkF bK/ICNuLwdfozsoDj7b/EfkguzjAU+YoOGVxntFb9PnOdQ7cHj55/QVlz4W+WDd/Y6vDTPxZw JwN/wrpYnQez/f4wlg7qXsouYPXJ0rMw9rxMxIAkpJww2eiIX2mu+NVsZAUGkrj1W3ATm7TV2 t5KEU48QHESBP4XdDI5zoR/xcGYY0676nUd 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() but in this case it is simpler to use the "%*ph" format specifier. Signed-off-by: Len Baker =2D-- drivers/staging/fbtft/fbtft-core.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fb= tft-core.c index 3723269890d5..be20da3c4a5c 100644 =2D-- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -992,8 +992,6 @@ static int fbtft_init_display_from_property(struct fbt= ft_par *par) int fbtft_init_display(struct fbtft_par *par) { int buf[64]; - char msg[128]; - char str[16]; int i =3D 0; int j; @@ -1036,17 +1034,14 @@ int fbtft_init_display(struct fbtft_par *par) switch (par->init_sequence[i]) { case -1: i++; + /* make debug message */ - strcpy(msg, ""); - j =3D i + 1; - while (par->init_sequence[j] >=3D 0) { - sprintf(str, "0x%02X ", par->init_sequence[j]); - strcat(msg, str); - j++; - } + for (j =3D i + 1; par->init_sequence[j] >=3D 0; j++); + fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, - "init: write(0x%02X) %s\n", - par->init_sequence[i], msg); + "init: write(0x%02X) %*ph\n", + par->init_sequence[i], j - i - 1, + &par->init_sequence[i + 1]); /* Write */ j =3D 0; =2D- 2.25.1