From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: steven.shi@intel.com) Received: from mga09.intel.com (mga09.intel.com []) by groups.io with SMTP; Tue, 17 Sep 2019 20:21:31 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Sep 2019 20:21:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,519,1559545200"; d="scan'208";a="216797323" Received: from jshi19-mobl.ccr.corp.intel.com ([10.254.215.71]) by fmsmga002.fm.intel.com with ESMTP; 17 Sep 2019 20:21:30 -0700 From: "Steven Shi" To: devel@edk2.groups.io Cc: liming.gao@intel.com, bob.c.feng@intel.com Subject: [PATCH v2 1/1] BaseTools: Add more parameter checking for CopyFileOnChange() Date: Wed, 18 Sep 2019 11:21:09 +0800 Message-Id: <20190918032109.3844-2-steven.shi@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190918032109.3844-1-steven.shi@intel.com> References: <20190918032109.3844-1-steven.shi@intel.com> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2193 The current CopyFileOnChange() method in Misc.py does not accept the input SrcFile parameter as a dir, but the method does not check the SrcFile is dir or not. This patch is to add more input parameter type checking and error message output for method CopyFileOnChange. Cc: Liming Gao Cc: Bob Feng Signed-off-by: Steven Shi --- BaseTools/Source/Python/Common/Misc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 714eb840ea..a488536cb4 100755 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -536,7 +536,8 @@ def CopyFileOnChange(SrcFile, Dst, FileLock=None): SrcFile = LongFilePath(SrcFile) Dst = LongFilePath(Dst) - if not os.path.exists(SrcFile): + if os.path.isdir(SrcFile): + EdkLogger.error(None, FILE_COPY_FAILURE, ExtraData='CopyFileOnChange SrcFile is a dir, not a file: %s' % SrcFile) return False if os.path.isdir(Dst): -- 2.17.1.windows.2