Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2351720pxv; Sat, 24 Jul 2021 13:23:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqxh4Eim6wUFj2u1h37/d4nSgkLbESlJW9Gh3I6FAiBgLbbiuy2QDUtcyKGDLwR61EZqBs X-Received: by 2002:a17:906:7848:: with SMTP id p8mr2990826ejm.212.1627158230867; Sat, 24 Jul 2021 13:23:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627158230; cv=none; d=google.com; s=arc-20160816; b=iDJT7ydbVuNKodX8VBRSr7IKYvQZD5yfyKvT7SAn7r8kgbZICD1IB0pZlCJOLp8EGt cNV2URNtlbzz1gxCiejy3uaJnxL604SmrKZ3GQ+3X/3wVf5NJ0WtiJD0FeAj9vlFNQKw AWHyuECkJL3Io6mIlqkdqr4XX42meedUt/OOAfpHwmUsR7D3j3hIpivNJtm+i9riiclo OC5yUiGIKh8duwVk+HvJXalPoJXbPfClyz8JYTjk7N6T36feYR/cl1b0fbi67bxe3urN 1OmcQadfYNVa2JjvmYeh4RGkDd/GHqlEGfdm9ox6O0IeV4dDwKmLs5DnqDcd0V5QUglW fbFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=CaGEdpDA93dZP0T/+1LD+f5/OqGOURSdBO4AdBPyvbk=; b=Q6+XAJ4W0CkJ1gRkA/ensxaAquIYQg37LtGd03VP2sK2HAjB1emSPkOV1bnYzznwkd 0gUtL73/Bk9K4xePpoTwZqe3fs6KD6wKksFeJTO7vd9rHPnGItpY8fVfCLQYgiZCwMmx 2yyWiUk+MO38YoNa5qYmL1/dJPM2LcPSPigM1v+6YsNAksNje7BRqOVIF6YBz7i2bpM9 TsAjvieDRLq759t09UpVd8KBWsKqUfuKrmk+fZJJ1vFl0DldhwSOfn7ZOeXIjCnKrspP p1MOfXc1rwDfRvRQRlr9na8uMLyZcw09XYMi3Q6yd7iTt4vVo4K5h1EecF4/yXhTEh0u ih1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AI4mpHFj; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bz6si37992157ejc.610.2021.07.24.13.23.27; Sat, 24 Jul 2021 13:23:50 -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=@gmail.com header.s=20161025 header.b=AI4mpHFj; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229665AbhGXTlK (ORCPT + 99 others); Sat, 24 Jul 2021 15:41:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbhGXTlJ (ORCPT ); Sat, 24 Jul 2021 15:41:09 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6552CC061575; Sat, 24 Jul 2021 13:21:41 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id e2-20020a17090a4a02b029016f3020d867so8633029pjh.3; Sat, 24 Jul 2021 13:21:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CaGEdpDA93dZP0T/+1LD+f5/OqGOURSdBO4AdBPyvbk=; b=AI4mpHFjoc+Y2m9BVS+3RhJtiRCm72bWPg5xeFX3yUwqR9Kdvzh37YFqhkJlkxPQt7 kgl/LMUCRXv8Cpzf/xkr1Mk29l5n/cBKw8q/Pzzs17W0xS8iRR0G/dA4p2WktS3yTBD5 vkvSfAvXlt7/VtugQrsqlNR7rSq+e/qVLW61GE+/jOBJCTfHwLRuuX6u0aRQ960n8uab 2P+UTPnucB2iQqQRZ/IIdNbmc/T7yfMNUddULY9b7pa3CzHYN5sitUrElKRkuglqSVqd hD04yQtRjEzvbJneJ2RZwezrBm7zI8/YRhcxZRGfhuKJax+aTmEryBLZPU1NqIUQicG6 qFew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CaGEdpDA93dZP0T/+1LD+f5/OqGOURSdBO4AdBPyvbk=; b=tqmDHnqlrPSLEE3+SD/cl4JHapR5UWAtJ947e6ieKlaug9ey0RxnStvZI3TneMquM8 LugvTGv5vxbcV2uS31123v+6U12cvQ59PCNZO3RSfg6zu20Z08Kfam3ftxVWQeLJfi3a P82LglJgQKfquyEYHBOjuywr7ysm34JzivkYmoHznHEvl/CHZK8PNy6qjJNgZM54n2s/ YppEIPNA11QYf6/nRIUgQ2yPEhPoVu/A3F2Dz/rS/TTIqVvstXYFGXlZpTNl6sVQ1xCO KMT+i4NImaSzAIkzlhVZrZn1PwrXSFWUaRUoBqb2Ugs1yXA+k6lBZ6Delh02VBQjeCYj pfxA== X-Gm-Message-State: AOAM531zKUHzdDcZ5IG7nMB+pDdKsuDr6tl3Q0kBez5hTXnFszMe2J5P ejy+7w0H8QRAOOPBmXO7DG65jwoOiEGu+Ny5Oww= X-Received: by 2002:a63:cf0a:: with SMTP id j10mr11150254pgg.4.1627158100931; Sat, 24 Jul 2021 13:21:40 -0700 (PDT) MIME-Version: 1.0 References: <20210724151411.9531-1-len.baker@gmx.com> <20210724151411.9531-2-len.baker@gmx.com> In-Reply-To: <20210724151411.9531-2-len.baker@gmx.com> From: Andy Shevchenko Date: Sat, 24 Jul 2021 23:21:04 +0300 Message-ID: Subject: Re: [PATCH v2 1/3] staging/fbtft: Remove all strcpy() uses To: Len Baker Cc: Greg Kroah-Hartman , Andy Shevchenko , Phil Reid , Geert Uytterhoeven , dri-devel , "open list:FRAMEBUFFER LAYER" , linux-staging@lists.linux.dev, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 24, 2021 at 7:05 PM Len Baker wrote: > > 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. ... > - char msg[128]; 128 / 4 = 32. So, this buffer is enough to debug print only up to 32 bytes. Hence %*ph replacement won't cut output earlier than requested. ... > + for (j = i + 1; par->init_sequence[j] >= 0; j++); Why is i + 1 initial for the j? You may rather access the 'i + 1 + j'th element in the array... ... > + par->init_sequence[i], j - i - 1, ...and get rid of the ' - i -1' part here. -- With Best Regards, Andy Shevchenko