[edk2-devel] [PATCH] CryptoPkg/SysCall: Cast variables from 4 to 8-byte size
Zhang, Shenglei
shenglei.zhang at intel.com
Thu Dec 5 08:46:07 UTC 2019
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 at intel.com>
Cc: Xiaoyu Lu <xiaoyux.lu at intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang at 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
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#51775): https://edk2.groups.io/g/devel/message/51775
Mute This Topic: https://groups.io/mt/66944007/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list