From 554f95d343c231cdf97d96c876c3e8f6079ccc31 Mon Sep 17 00:00:00 2001
From: houmingyong <houmingyong@huawei.com>
Date: Mon, 27 Jun 2022 11:28:20 +0800
Subject: [PATCH] sgxssl_fgets adapt glibc-2.35

---
 openssl_source/bypass_to_sgxssl.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/openssl_source/bypass_to_sgxssl.h b/openssl_source/bypass_to_sgxssl.h
index 9676726..c833bd2 100644
--- a/openssl_source/bypass_to_sgxssl.h
+++ b/openssl_source/bypass_to_sgxssl.h
@@ -175,6 +175,8 @@
 
 #else //_WIN32
 
+#include <features.h>
+
 #define mmap sgxssl_mmap
 #define munmap sgxssl_munmap
 #define mprotect sgxssl_mprotect
@@ -194,7 +196,14 @@
 #define __fprintf_chk sgxssl_fprintf
 #define __vfprintf_chk sgxssl_vfprintf
 #define __fread_alias sgxssl_fread
-#define __fgets_alias sgxssl_fgets
+
+# if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
+#  if __GLIBC_PREREQ(2, 35)
+#      define __fgets_chk sgxssl_fgets
+#  else
+#      define __fgets_alias sgxssl_fgets
+#  endif
+#endif
 
 #if defined(SGXSDK_INT_VERSION) && (SGXSDK_INT_VERSION > 18)
 	#define _longjmp longjmp
-- 
2.23.0

