[edk2] [PATCH] CrptoPkg/BaseCryptLib: Fix type mismatch when calling OpenSSL function

Zhang, Chao B posted 1 patch 6 years, 11 months ago
Failed in applying to current master (apply log)
CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[edk2] [PATCH] CrptoPkg/BaseCryptLib: Fix type mismatch when calling OpenSSL function
Posted by Zhang, Chao B 6 years, 11 months ago
Type definition in UEFI & OpeenSSL is different. Sometime it could cause
write overflow. Should use same data type when accessing the same region

Cc: Long Qin <qin.long@intel.com>
Cc: Chen Chen <chen.a.chen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
---
 CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
index bf7c4cc..a3c9d12 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
@@ -644,9 +644,9 @@ X509GetTBSCert (
   )
 {
   CONST UINT8  *Temp;
-  INTN         Asn1Tag;
-  INTN         ObjClass;
-  UINTN        Length;
+  int          Asn1Tag;
+  int          ObjClass;
+  long         Length;
 
   //
   // Check input parameters.
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] CrptoPkg/BaseCryptLib: Fix type mismatch when calling OpenSSL function
Posted by Long, Qin 6 years, 11 months ago
Chao,

Could you leverage the EFI type instead of C type here for consistence? 
We can use "INT32" type for Asn1Tag and ObjClass, and one "UINTN" Length should be OK with one extra zeroing here.


Best Regards & Thanks,
LONG, Qin

-----Original Message-----
From: Zhang, Chao B 
Sent: Monday, January 15, 2018 10:00 AM
To: edk2-devel@lists.01.org
Cc: Long, Qin <qin.long@intel.com>; Chen, Chen A <chen.a.chen@intel.com>; Zhang, Chao B <chao.b.zhang@intel.com>
Subject: [PATCH] CrptoPkg/BaseCryptLib: Fix type mismatch when calling OpenSSL function

Type definition in UEFI & OpeenSSL is different. Sometime it could cause write overflow. Should use same data type when accessing the same region

Cc: Long Qin <qin.long@intel.com>
Cc: Chen Chen <chen.a.chen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
---
 CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
index bf7c4cc..a3c9d12 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
@@ -644,9 +644,9 @@ X509GetTBSCert (
   )
 {
   CONST UINT8  *Temp;
-  INTN         Asn1Tag;
-  INTN         ObjClass;
-  UINTN        Length;
+  int          Asn1Tag;
+  int          ObjClass;
+  long         Length;
 
   //
   // Check input parameters.
--
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH] CrptoPkg/BaseCryptLib: Fix type mismatch when calling OpenSSL function
Posted by Zhang, Chao B 6 years, 11 months ago
Qin:
   That makes sense to me. Thanks for the comment.

-----Original Message-----
From: Long, Qin 
Sent: Monday, January 15, 2018 2:04 PM
To: Zhang, Chao B <chao.b.zhang@intel.com>; edk2-devel@lists.01.org
Cc: Chen, Chen A <chen.a.chen@intel.com>
Subject: RE: [PATCH] CrptoPkg/BaseCryptLib: Fix type mismatch when calling OpenSSL function

Chao,

Could you leverage the EFI type instead of C type here for consistence? 
We can use "INT32" type for Asn1Tag and ObjClass, and one "UINTN" Length should be OK with one extra zeroing here.


Best Regards & Thanks,
LONG, Qin

-----Original Message-----
From: Zhang, Chao B 
Sent: Monday, January 15, 2018 10:00 AM
To: edk2-devel@lists.01.org
Cc: Long, Qin <qin.long@intel.com>; Chen, Chen A <chen.a.chen@intel.com>; Zhang, Chao B <chao.b.zhang@intel.com>
Subject: [PATCH] CrptoPkg/BaseCryptLib: Fix type mismatch when calling OpenSSL function

Type definition in UEFI & OpeenSSL is different. Sometime it could cause write overflow. Should use same data type when accessing the same region

Cc: Long Qin <qin.long@intel.com>
Cc: Chen Chen <chen.a.chen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
---
 CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
index bf7c4cc..a3c9d12 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
@@ -644,9 +644,9 @@ X509GetTBSCert (
   )
 {
   CONST UINT8  *Temp;
-  INTN         Asn1Tag;
-  INTN         ObjClass;
-  UINTN        Length;
+  int          Asn1Tag;
+  int          ObjClass;
+  long         Length;
 
   //
   // Check input parameters.
--
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel