public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] CryptoPkg/SysCall: Cast variables from 4 to 8-byte size
@ 2019-12-05  8:46 Zhang, Shenglei
  2019-12-07 14:11 ` [edk2-devel] " Laszlo Ersek
  0 siblings, 1 reply; 3+ messages in thread
From: Zhang, Shenglei @ 2019-12-05  8:46 UTC (permalink / raw)
  To: devel; +Cc: Jian J Wang, Xiaoyu Lu

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-13  6:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-05  8:46 [PATCH] CryptoPkg/SysCall: Cast variables from 4 to 8-byte size Zhang, Shenglei
2019-12-07 14:11 ` [edk2-devel] " Laszlo Ersek
2019-12-13  6:11   ` Zhang, Shenglei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox