In a later patch in this series, we're going to resurrect "inet_pton.c"
(originally from the StdLib package). That source file has a number of
standard C and BSD socket dependencies. Provide those dependencies here:
- The header files below will simply #include <CrtLibSupport.h>:
- arpa/inet.h
- arpa/nameser.h
- netinet/in.h
- sys/param.h
- sys/socket.h
- EAFNOSUPPORT comes from "StdLib/Include/errno.h", at commit
e2d3a25f1a31; which is the commit immediately preceding the removal of
StdLib from edk2 (
964f432b9b0a).
Note that the other error macro, which we alread #define, namely EINVAL,
has a value (22) that also matches "StdLib/Include/errno.h".
- The AF_INET and AF_INET6 address family macros come from
"StdLib/Include/sys/socket.h".
- The NS_INT16SZ, NS_INADDRSZ and NS_IN6ADDRSZ macros come from
"StdLib/Include/arpa/nameser.h".
- The "u_int" and "u_char" types come from "StdLib/Include/sys/types.h".
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Sivaraman Nainar <sivaramann@amiindia.co.in>
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=960
CVE: CVE-2019-14553
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
// Definitions for global constants used by CRT library routines\r
//\r
#define EINVAL 22 /* Invalid argument */\r
+#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */\r
#define INT_MAX 0x7FFFFFFF /* Maximum (signed) int value */\r
#define LONG_MAX 0X7FFFFFFFL /* max value for a long */\r
#define LONG_MIN (-LONG_MAX-1) /* min value for a long */\r
#define ULONG_MAX 0xFFFFFFFF /* Maximum unsigned long value */\r
#define CHAR_BIT 8 /* Number of bits in a char */\r
\r
+//\r
+// Address families.\r
+//\r
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */\r
+#define AF_INET6 24 /* IP version 6 */\r
+\r
+//\r
+// Define constants based on RFC0883, RFC1034, RFC 1035\r
+//\r
+#define NS_INT16SZ 2 /*%< #/bytes of data in a u_int16_t */\r
+#define NS_INADDRSZ 4 /*%< IPv4 T_A */\r
+#define NS_IN6ADDRSZ 16 /*%< IPv6 T_AAAA */\r
+\r
//\r
// Basic types mapping\r
//\r
typedef UINTN size_t;\r
+typedef UINTN u_int;\r
typedef INTN ssize_t;\r
typedef INT32 time_t;\r
typedef UINT8 __uint8_t;\r
typedef UINT8 sa_family_t;\r
+typedef UINT8 u_char;\r
typedef UINT32 uid_t;\r
typedef UINT32 gid_t;\r
\r
--- /dev/null
+/** @file\r
+ Include file to support building third-party standard C / BSD sockets code.\r
+\r
+ Copyright (C) 2019, Red Hat, Inc.\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#include <CrtLibSupport.h>\r
--- /dev/null
+/** @file\r
+ Include file to support building third-party standard C / BSD sockets code.\r
+\r
+ Copyright (C) 2019, Red Hat, Inc.\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#include <CrtLibSupport.h>\r
--- /dev/null
+/** @file\r
+ Include file to support building third-party standard C / BSD sockets code.\r
+\r
+ Copyright (C) 2019, Red Hat, Inc.\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#include <CrtLibSupport.h>\r
--- /dev/null
+/** @file\r
+ Include file to support building third-party standard C / BSD sockets code.\r
+\r
+ Copyright (C) 2019, Red Hat, Inc.\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#include <CrtLibSupport.h>\r
--- /dev/null
+/** @file\r
+ Include file to support building third-party standard C / BSD sockets code.\r
+\r
+ Copyright (C) 2019, Red Hat, Inc.\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#include <CrtLibSupport.h>\r