public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zhang, Shenglei" <shenglei.zhang@intel.com>
To: devel@edk2.groups.io
Cc: Jian J Wang <jian.j.wang@intel.com>, Xiaoyu Lu <xiaoyux.lu@intel.com>
Subject: [PATCH] CryptoPkg/SysCall: Cast variables from 4 to 8-byte size
Date: Thu,  5 Dec 2019 16:46:07 +0800	[thread overview]
Message-ID: <20191205084607.34208-1-shenglei.zhang@intel.com> (raw)

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 <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
 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


             reply	other threads:[~2019-12-05  8:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-05  8:46 Zhang, Shenglei [this message]
2019-12-07 14:11 ` [edk2-devel] [PATCH] CryptoPkg/SysCall: Cast variables from 4 to 8-byte size Laszlo Ersek
2019-12-13  6:11   ` Zhang, Shenglei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191205084607.34208-1-shenglei.zhang@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox