Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp707774ybe; Wed, 11 Sep 2019 03:30:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqydpSayj+OFypqv3nRRK8NK4KaYgihBpNHQUwX/UDr4guUihFthnciiWhJzqd903VFk8afF X-Received: by 2002:aa7:d755:: with SMTP id a21mr35273243eds.18.1568197823935; Wed, 11 Sep 2019 03:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568197823; cv=none; d=google.com; s=arc-20160816; b=rrhP43AE52C5zYqdRTLBTBPlntG1P2VGkLndZll+DzrXdaKT9DMas1WCfpFS9XJVqL +iu6nTtnfb/q+hE72/2TEgUW2P+abqecmzeiS519qGF01HO4zNJHOJNnjpI6r62jR3Ff 9f+MBtUit2I4hA7vDb7Ra+7yODbcL2nCchlEpj6dWUwe/fXjL6l4tnDEmvsgpiEt9ohC 5UKhf4Yb4h3tGA5RdMYAFV4IER0NCeQBY21Qxa99NuSjA+kD5eanKLjZx3D79V+wmuFI HohTrvnh44Jkqtxf9PS2+DOi7A8RLuMfpvWERs3y8kqvO1VzU2EEpUJA0ymU3HZyHJw4 Cglw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:in-reply-to:cc:references:message-id :date:subject:mime-version:from:content-transfer-encoding; bh=DOMvOFkj41RR7kqq9zPvLyBpnt5CWrEFb3WCGnwnXeo=; b=wxG2dV9oJp6qev/PUqiZtyXhb4ILQBUrHvaCm9e3eN7G0y7mrz1U7+4YKvXx1W3FNf nhR7LTRGMvSb1WomliMzHZikV3vHcApFjshKH7ogae7TR0pxTg4YldBWgTGQlnX99Afs EVP4qlPNU3x6iggVIFQh35HcJdu2gjPc1DAlhexjfr/pNOk+8txpNsPkAfRX5cn7xW+0 RQj9AuI9oNsLjwdbXYQjACl6qfGakuJmu12/7u9eN6nES6ZnUfhv4sVywM9AF4UXN4+J z13HukgNnrYZ5DaL5S4+JbVs1qVeX3N/TaUO4VBkfT6///S/V7mAjQCNz0Nxa6mbo9Ot 4OcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c4si2281873ejb.183.2019.09.11.03.29.59; Wed, 11 Sep 2019 03:30:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727626AbfIKKY3 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 11 Sep 2019 06:24:29 -0400 Received: from mxout012.mail.hostpoint.ch ([217.26.49.172]:41319 "EHLO mxout012.mail.hostpoint.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726696AbfIKKY2 (ORCPT ); Wed, 11 Sep 2019 06:24:28 -0400 Received: from [10.0.2.46] (helo=asmtp013.mail.hostpoint.ch) by mxout012.mail.hostpoint.ch with esmtp (Exim 4.92.2 (FreeBSD)) (envelope-from ) id 1i7znV-000BZB-4E; Wed, 11 Sep 2019 12:24:25 +0200 Received: from [213.55.220.251] (helo=[100.66.103.90]) by asmtp013.mail.hostpoint.ch with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2 (FreeBSD)) (envelope-from ) id 1i7znU-000PHX-V7; Wed, 11 Sep 2019 12:24:25 +0200 X-Authenticated-Sender-Id: sandro@volery.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT From: Sandro Volery Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v2] Staging: exfat: Avoid use of strcpy Date: Wed, 11 Sep 2019 12:24:23 +0200 Message-Id: References: <20190911100616.GH20699@kadam> Cc: valdis.kletnieks@vt.edu, gregkh@linuxfoundation.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk In-Reply-To: <20190911100616.GH20699@kadam> To: Dan Carpenter X-Mailer: iPhone Mail (17A5831c) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On 11 Sep 2019, at 12:06, Dan Carpenter wrote: > > On Wed, Sep 11, 2019 at 11:42:19AM +0200, Sandro Volery wrote: >> Use strscpy instead of strcpy in exfat_core.c, and add a check >> for length that will return already known FFS_INVALIDPATH. >> >> Suggested-by: Rasmus Villemoes >> Signed-off-by: Sandro Volery >> --- >> v2: Implement length check and return in one >> v1: Original Patch >> drivers/staging/exfat/exfat_core.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c >> index da8c58149c35..4c40f1352848 100644 >> --- a/drivers/staging/exfat/exfat_core.c >> +++ b/drivers/staging/exfat/exfat_core.c >> @@ -2964,7 +2964,8 @@ s32 resolve_path(struct inode *inode, char *path, struct chain_t *p_dir, >> if (strlen(path) >= (MAX_NAME_LENGTH * MAX_CHARSET_SIZE)) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Delete this as it is no longer required. > Yep, saw it from Rasmus response too just now.. Dumb mistake. Will fix this this afternoon. Sandro V >> return FFS_INVALIDPATH; >> >> - strcpy(name_buf, path); >> + if (strscpy(name_buf, path, sizeof(name_buf)) < 0) >> + return FFS_INVALIDPATH; >