-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKasperskyOS-CE-adaptation.patch
More file actions
147 lines (140 loc) · 5.1 KB
/
KasperskyOS-CE-adaptation.patch
File metadata and controls
147 lines (140 loc) · 5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
© 2026 AO Kaspersky Lab
This script is licensed under the MIT License
---
CMakeLists.txt | 12 +++++++++++-
include/ares.h | 2 +-
src/lib/ares__read_line.c | 8 ++++++++
src/lib/ares__readaddrinfo.c | 3 +++
src/lib/ares_getaddrinfo.c | 4 ++++
src/lib/ares_getnameinfo.c | 4 ++++
src/lib/ares_strsplit.c | 2 +-
7 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e2290af..029db1b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,9 @@
-CMAKE_MINIMUM_REQUIRED (VERSION 3.1.0)
+CMAKE_MINIMUM_REQUIRED (VERSION 3.29)
+
+# Enable CMP0077 to make option() honor normal variables
+IF (POLICY CMP0077)
+ CMAKE_POLICY(SET CMP0077 NEW)
+ENDIF (POLICY CMP0077)
INCLUDE (CheckIncludeFiles)
INCLUDE (CheckTypeSize)
@@ -219,6 +224,9 @@ IF (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
LIST (APPEND SYSFLAGS -D_DARWIN_C_SOURCE)
ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "Linux")
LIST (APPEND SYSFLAGS -D_GNU_SOURCE -D_POSIX_C_SOURCE=199309L -D_XOPEN_SOURCE=600)
+ELSEIF (CMAKE_SYSTEM_NAME MATCHES "KOS-GNU.*")
+ CMAKE_POLICY (VERSION 3.29)
+ LIST (APPEND SYSFLAGS -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700)
ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
LIST (APPEND SYSFLAGS -D__EXTENSIONS__ -D_REENTRANT -D_XOPEN_SOURCE=600)
ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "AIX")
@@ -536,6 +544,7 @@ IF (HAVE_GETSERVBYPORT_R)
SET (GETSERVBYPORT_R_ARGS 5)
ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "AIX" OR
CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR
+ CMAKE_SYSTEM_NAME MATCHES "KOS-GNU.*" OR
HAIKU)
SET (GETSERVBYPORT_R_ARGS 4)
ELSE ()
@@ -550,6 +559,7 @@ IF (HAVE_GETSERVBYNAME_R)
SET (GETSERVBYNAME_R_ARGS 5)
ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "AIX" OR
CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR
+ CMAKE_SYSTEM_NAME MATCHES "KOS-GNU.*" OR
HAIKU)
SET (GETSERVBYNAME_R_ARGS 4)
ELSE ()
diff --git a/include/ares.h b/include/ares.h
index 8c7520e..e9ddd1c 100644
--- a/include/ares.h
+++ b/include/ares.h
@@ -39,7 +39,7 @@
#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \
defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \
defined(ANDROID) || defined(__ANDROID__) || defined(__OpenBSD__) || \
- defined(__QNXNTO__) || defined(__MVS__) || defined(__HAIKU__)
+ defined(__QNXNTO__) || defined(__MVS__) || defined(__HAIKU__) || defined(__KOS__)
#include <sys/select.h>
#endif
#if (defined(NETWARE) && !defined(__NOVELL_LIBC__))
diff --git a/src/lib/ares__read_line.c b/src/lib/ares__read_line.c
index c62ad2a..d6625a3 100644
--- a/src/lib/ares__read_line.c
+++ b/src/lib/ares__read_line.c
@@ -49,6 +49,14 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize)
if (!fgets(*buf + offset, bytestoread, fp))
return (offset != 0) ? 0 : (ferror(fp)) ? ARES_EFILE : ARES_EOF;
len = offset + strlen(*buf + offset);
+
+ /* Probably means there was an embedded NULL as the first character in
+ * the line, throw away line */
+ if (len == 0) {
+ offset = 0;
+ continue;
+ }
+
if ((*buf)[len - 1] == '\n')
{
(*buf)[len - 1] = 0;
diff --git a/src/lib/ares__readaddrinfo.c b/src/lib/ares__readaddrinfo.c
index 2315df9..ee636ae 100644
--- a/src/lib/ares__readaddrinfo.c
+++ b/src/lib/ares__readaddrinfo.c
@@ -29,6 +29,9 @@
#include "ares_inet_net_pton.h"
#include "ares_nowarn.h"
#include "ares_private.h"
+#ifdef __KOS__
+# include <strings.h>
+#endif
#define MAX_ALIASES 40
diff --git a/src/lib/ares_getaddrinfo.c b/src/lib/ares_getaddrinfo.c
index cb49424..1cd24ea 100644
--- a/src/lib/ares_getaddrinfo.c
+++ b/src/lib/ares_getaddrinfo.c
@@ -253,8 +253,12 @@ static unsigned short lookup_service(const char *service, int flags)
sep =
getservbyname_r(service, proto, &se, (void *)tmpbuf, sizeof(tmpbuf));
#elif GETSERVBYNAME_R_ARGS == 4
+#ifdef __KOS__
+ sep = getservbyname_r(service, proto, &se, (void *)tmpbuf);
+#else
if (getservbyname_r(service, proto, &se, (void *)tmpbuf) != 0)
sep = NULL;
+#endif
#else
/* Lets just hope the OS uses TLS! */
sep = getservbyname(service, proto);
diff --git a/src/lib/ares_getnameinfo.c b/src/lib/ares_getnameinfo.c
index 966919a..6324e5e 100644
--- a/src/lib/ares_getnameinfo.c
+++ b/src/lib/ares_getnameinfo.c
@@ -304,8 +304,12 @@ static char *lookup_service(unsigned short port, int flags,
sep = getservbyport_r(port, proto, &se, (void *)tmpbuf,
sizeof(tmpbuf));
#elif GETSERVBYPORT_R_ARGS == 4
+#ifdef __KOS__
+ sep = getservbyport_r(port, proto, &se, (void *)tmpbuf);
+#else
if (getservbyport_r(port, proto, &se, (void *)tmpbuf) != 0)
sep = NULL;
+#endif
#else
/* Lets just hope the OS uses TLS! */
sep = getservbyport(port, proto);
diff --git a/src/lib/ares_strsplit.c b/src/lib/ares_strsplit.c
index d3e90c4..c024936 100644
--- a/src/lib/ares_strsplit.c
+++ b/src/lib/ares_strsplit.c
@@ -13,7 +13,7 @@
* without express or implied warranty.
*/
-#if defined(__MVS__)
+#if defined(__MVS__) || defined(__KOS__)
#include <strings.h>
#endif