Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp141297rdb; Wed, 18 Oct 2023 22:52:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/jzncC4J0XAdhqc5G39YDmQIkruZ2EI7tbVKhRdnuj+G+Eo23ZE7cuqd9uFbjTKQf2NY1 X-Received: by 2002:a05:6870:7998:b0:1e9:faca:bd1d with SMTP id he24-20020a056870799800b001e9facabd1dmr1537710oab.24.1697694728589; Wed, 18 Oct 2023 22:52:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697694728; cv=none; d=google.com; s=arc-20160816; b=HbzrvBwd0xLL5f2lyvD2YImLw5ytu8dr/f9R99EzIPmBv6g1jM9xf8CMbnGV3ZjggI DYggNaglBKhVJskixjz3FrvTIbRbm0A9tihgBOIVfFdAmQgLJuamdtebXzNbjCXohR6m Ux0BdinAPRQrxJFu1iXFeAPbpcDo2flu6LMnArNoOLFMeaxCr1xXw7fvLx47xWlY/tDt hPA8ebC3TdVLexaPVnM3sqKyq101rdn43gMSI2buij1m9/Su4sCGElXFnCG3H06ILs8d Ezf8CTokCjlV9KcTYNuxIS/CrrXqPEhjS27CsthDZec0JlwTRLEmcyXw2v1yMEscxN9Y 5hHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=q4KPSAVtKqgOLeDR7mdK9Is2A/SYRmO80toMUaOj5BI=; fh=Ze0iNn4EYZG6Yufa/m+SemAX66mguvcTKrLF/4dvRfU=; b=boB0RHR/oN+OpAiuvimkkrabVNcJ0S4LLSrdGPUROM+myPjiXkrl04OLBKJZihW1lt w0IHAvpdmCWvJPRRaMnzkqlydfoOCC65BWNuq87sS8AIBKUd5KyAZexdGXD8K4BuAUyO iMgaBuABOsxhFj/U7ZdlsJw1NVcatT57slmQTYh+ppktrhU45aZncBvIGxLvnrp5Rj/E F/1fD7qlIJf5t/53EzZK4eRsvmhYd5oQpIwmHARD7dh/eeKpMUYerppGXsHKOha3MOcn eAaa3kHqLaDbH8euP67T+aMroYm0umLyhtKziw/mduKElcHLS3e00jNiW/VvVz5G0hrf CzUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EONVw+xE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id b185-20020a6334c2000000b005b74de09ee0si3771470pga.108.2023.10.18.22.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 22:52:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EONVw+xE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 0AB858077920; Wed, 18 Oct 2023 22:51:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231284AbjJSFvI (ORCPT + 99 others); Thu, 19 Oct 2023 01:51:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230262AbjJSFvF (ORCPT ); Thu, 19 Oct 2023 01:51:05 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E63C113 for ; Wed, 18 Oct 2023 22:51:03 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3226cc3e324so6686325f8f.3 for ; Wed, 18 Oct 2023 22:51:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697694662; x=1698299462; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=q4KPSAVtKqgOLeDR7mdK9Is2A/SYRmO80toMUaOj5BI=; b=EONVw+xEoTrNNKBLLf10lTvfQJbMc1Nq9dnKiKvXMxdeWmCfwoevVy9oQQX/0PZCsz A1W2UUURLUECwpoMDuNN9dsSpZLHv/QzCCzlTEzDUyD7PJcXs9PXBVxajHlu0dJNkiCi 2KYHD4I9y6W2S2fgVlMuKH1nttxKHX0hAfJ43j6PZbBiGQEz8et68QLbqDXehzWSfsMY 1b1DfBln1uCWrfl2W5c0erOCZwEu1dTzMI2S/wFYyHLhX2TlvVlElqJh3gMsHRZ18Jih oFsBRYoktxiGPYCq70e13J+m6b0c3ftn85SWkoevlij1QOpxv48mORAzUUIWYBIwKgBC QShw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697694662; x=1698299462; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=q4KPSAVtKqgOLeDR7mdK9Is2A/SYRmO80toMUaOj5BI=; b=IPsEr61l9ZnfdEatPNY4Bdq8Hx8UedZvHQEev6qYjDDzDu6qf+VrRlmO8DIpfvCUrG tQP4AAq0QXT/VIIdtkatC6Q5txaQ0INfuncNCxStskD6I1lFjQ3x3XjM/8JVO0yZIkBh iYu5urdCeIpJ/6C/IGr6RpImG9wzDOvh75OBAmhHqcNYuKrjHFGB1mdpGoer0pA/QY5C oqrGpKJDRjYY5s5FbkTPwXVNcdhMvjhsuG0RotPGDW6MjqQSV7ycHV+sJQZhL4E7Iogk XUvLtly0KP5VhjqT8i4/d4pS0OdV/MaFlQa9xs9NllbQ0jp5Afi9Y9KghHB2NgiylPiW gk7w== X-Gm-Message-State: AOJu0YwDI6J/XtrA6kbTyYNpQxleMJ65hbCQ0WgYZIRwg6It6G6dSBEF i8tqzSsYyWoU5EJBOEeXA5gHznpe8BjH0DKKn8c= X-Received: by 2002:a05:6000:18c:b0:32d:9daf:3f94 with SMTP id p12-20020a056000018c00b0032d9daf3f94mr659746wrx.53.1697694662034; Wed, 18 Oct 2023 22:51:02 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id m5-20020a056000180500b0031c6581d55esm3634725wrh.91.2023.10.18.22.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 22:51:01 -0700 (PDT) Date: Thu, 19 Oct 2023 08:50:58 +0300 From: Dan Carpenter To: Calvince Otieno Cc: gustavo@embeddedor.com, outreachy@lists.linux.dev, Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martyn Welch , Manohar Vanga Subject: Re: [PATCH v3] staging: vme_user: replace strcpy with strscpy Message-ID: <7baab878-ab15-4e8f-a1bd-6c028a6dbf2d@kadam.mountain> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 morse.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 (morse.vger.email [0.0.0.0]); Wed, 18 Oct 2023 22:51:26 -0700 (PDT) On Thu, Oct 19, 2023 at 08:47:24AM +0300, Calvince Otieno wrote: > Checkpatch suggests using strscpy() instead of strcpy(). > > The advantages of strscpy() are that it always adds a NUL terminator > and prevents read/write overflows if the source string is not properly > terminated. > > strcpy() lacks built-in bounds checking for the destination buffer, > making it susceptible to buffer overflows. These overflows can lead > to various unpredictable behaviors. > > In this specific context, both strscpy and strcpy performs the same > operation without any functional difference. > > The reason for this equivalence is that the driver_name string "vme_fake" > is shorter than the size of the fake_bridge->name array which is defined > as 16 characters (struct vme_bridge {char name[VMENAMSIZ];...}). Thus, > there is no risk of buffer overflow in either case. VMENAMSIZ variable > holds a constant value of 16 (#define VMENAMSIZ 16) > > The null-terminated "vme_fake" string > (static const char driver_name[] = "vme_fake";) can be safely copied into > fake_bridge->name using either strscpy or strcpy. > > While using strscpy() does not address any bugs, it is considered a better > practice and aligns with checkpatch recommendations. > > Signed-off-by: Calvince Otieno > --- Thanks! Reviewed-by: Dan Carpenter regards, dan carpenter