Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp661743ybe; Wed, 11 Sep 2019 02:44:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMhu4i0wYlti2/ct0ojp7Fud7t8WOmKZgN5488usg8VSpUFwuTkew++uCzTF6HSORzds9e X-Received: by 2002:aa7:d755:: with SMTP id a21mr35076141eds.18.1568195087745; Wed, 11 Sep 2019 02:44:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568195087; cv=none; d=google.com; s=arc-20160816; b=EsiMgDY6T6HYoScMxZsJwD2sdjvdUwpmaFUbWuCjB8HvJDZ+a7m6pCB+VLwo8A+07c UirhKJSUCw/4IOllGEkYikTVyAYPspyxWJBkohY5BXywNY0k8wQs0DcABHEA1dMYv+sZ z/B9K5u3x0nl9obLxDMOr5ZXq80NsAOBEsdpgBV7EKHZgxw46bKNDyhczTkAf0s6457u CCQ5FkjtD3nMpVwpFwPw1T+rQtOkYH2B+l23oT7UM0QWwOr/MO+QkakKydJ55GKd5dUZ wjwq3uWuaKvJcBFp0MmHlX0yb/VIMh/vDLgDy7ZgTZew8Q4uwqieeX/by9f06VsLeAg/ 1tsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date; bh=gDpH6uoW8xPkwa97WkFrF2fGcfEZTaYTbsp9s9fFITU=; b=rOf0b6qoLisQYpTDALQdxzGJKMh6nkyOYPRrmhime8VbZlOYNcQFERhWyb/djsqIJv JoM6QaUo6hBdNTHuf7EhtoWBl97aZxDp0X/FqoAv/doX6wPjV5fiiD8O4K9BGd7jPwUy 2oBPlMMb2m6gWDsJycssnygBA5lkltLgdfMVZUqp41r+9vPIhO1X5RPiMYX0uYwHvs8a ViXgJRxsiTpK4luLjHWFWdv7dpGb31y2ndg5H/MjGD5iRoO9JEXmYy6m26OlRVXbtioN QWMp7nfRkNqVSFhsJJc+OiZA9wRUXpQOV3xXxh0VLOfvIE0VyKeocNyRxyMGRHS9j29V zvtg== 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 o14si12132310edv.50.2019.09.11.02.44.23; Wed, 11 Sep 2019 02:44:47 -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 S1727427AbfIKJm0 (ORCPT + 99 others); Wed, 11 Sep 2019 05:42:26 -0400 Received: from mxout017.mail.hostpoint.ch ([217.26.49.177]:18639 "EHLO mxout017.mail.hostpoint.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726793AbfIKJm0 (ORCPT ); Wed, 11 Sep 2019 05:42:26 -0400 Received: from [10.0.2.46] (helo=asmtp013.mail.hostpoint.ch) by mxout017.mail.hostpoint.ch with esmtp (Exim 4.92.2 (FreeBSD)) (envelope-from ) id 1i7z8n-0004OK-BK; Wed, 11 Sep 2019 11:42:21 +0200 Received: from [83.150.61.156] (helo=volery) by asmtp013.mail.hostpoint.ch with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2 (FreeBSD)) (envelope-from ) id 1i7z8n-0009dG-86; Wed, 11 Sep 2019 11:42:21 +0200 X-Authenticated-Sender-Id: sandro@volery.com Date: Wed, 11 Sep 2019 11:42:19 +0200 From: Sandro Volery To: valdis.kletnieks@vt.edu, gregkh@linuxfoundation.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: linux@rasmusvillemoes.dk, dan.carpenter@oracle.com Subject: [PATCH v2] Staging: exfat: Avoid use of strcpy Message-ID: <20190911094219.GA22438@volery> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)) return FFS_INVALIDPATH; - strcpy(name_buf, path); + if (strscpy(name_buf, path, sizeof(name_buf)) < 0) + return FFS_INVALIDPATH; nls_cstring_to_uniname(sb, p_uniname, name_buf, &lossy); if (lossy) -- 2.23.0