From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web12.6466.1575535574341023847 for ; Thu, 05 Dec 2019 00:46:14 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: shenglei.zhang@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Dec 2019 00:46:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,280,1571727600"; d="scan'208";a="214066211" Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by orsmga006.jf.intel.com with ESMTP; 05 Dec 2019 00:46:12 -0800 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: Jian J Wang , Xiaoyu Lu Subject: [PATCH] CryptoPkg/SysCall: Cast variables from 4 to 8-byte size Date: Thu, 5 Dec 2019 16:46:07 +0800 Message-Id: <20191205084607.34208-1-shenglei.zhang@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 tp, pch, digits and xdigits are both 4-byte-size, but not cast to 8-byte-size when operated with 8-byte-size variables. This is a issue reported by my local static tool. Cc: Jian J Wang Cc: Xiaoyu Lu Signed-off-by: Shenglei Zhang --- CryptoPkg/Library/BaseCryptLib/SysCall/inet_pton.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/inet_pton.c b/CryptoPkg/Library/BaseCryptLib/SysCall/inet_pton.c index 32e1ab8690e6..ad392b18ca66 100644 --- a/CryptoPkg/Library/BaseCryptLib/SysCall/inet_pton.c +++ b/CryptoPkg/Library/BaseCryptLib/SysCall/inet_pton.c @@ -132,7 +132,7 @@ inet_pton4( const char *pch; if ((pch = strchr(digits, ch)) != NULL) { - u_int new = *tp * 10 + (u_int)(pch - digits); u_int new = (u_int)(*tp) * 10 + (u_int)pch - (u_int)digits; if (new > 255) return (0); @@ -200,7 +200,7 @@ inet_pton6( pch = strchr((xdigits = xdigits_u), ch); if (pch != NULL) { val <<= 4; - val |= (pch - xdigits); val |= (u_int)pch - (u_int)xdigits; if (val > 0xffff) return (0); saw_xdigit = 1; -- 2.18.0.windows.1