summaryrefslogtreecommitdiff
path: root/security/gvm-libs/files/patch-base_hosts.c
blob: 45a12c4a803df55d7394911ebca8f5be27237fa7 (plain) (blame)
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
--- base/hosts.c	2022-07-18 03:40:56.000000000 -0500
+++ base/hosts.c	2022-07-31 17:50:48.439636000 -0500
@@ -34,7 +34,11 @@
 #include <arpa/inet.h> /* for inet_pton, inet_ntop */
 #include <assert.h>    /* for assert */
 #include <ctype.h>     /* for isdigit */
+#if defined(__FreeBSD__)
+#include <malloc_np.h>
+#else
 #include <malloc.h>
+#endif
 #include <netdb.h>      /* for getnameinfo, NI_NAMEREQD */
 #include <stdint.h>     /* for uint8_t, uint32_t */
 #include <stdio.h>      /* for sscanf, perror */
@@ -1472,8 +1476,13 @@
           gvm_vhost_t *vhost;
 
           new = gvm_host_new ();
+#if defined(__FreeBSD__)
+	  if (ip6->s6_addr[0] != 0 || ip6->s6_addr[1] != 0
+              || ip6->s6_addr[2] != 0xff)
+#else
           if (ip6->s6_addr32[0] != 0 || ip6->s6_addr32[1] != 0
               || ip6->s6_addr32[2] != htonl (0xffff))
+#endif
             {
               new->type = HOST_TYPE_IPV6;
               memcpy (&new->addr6, ip6, sizeof (new->addr6));
@@ -1481,7 +1490,11 @@
           else
             {
               new->type = HOST_TYPE_IPV4;
+#if defined(__FreeBSD__)
+              memcpy (&new->addr6, &ip6->s6_addr[12], sizeof (new->addr));
+#else
               memcpy (&new->addr6, &ip6->s6_addr32[3], sizeof (new->addr));
+#endif
             }
           vhost =
             gvm_vhost_new (g_strdup (host->name), g_strdup ("Forward-DNS"));
@@ -2040,7 +2053,11 @@
       ret->addr.s_addr = host->addr.s_addr;
       break;
     case HOST_TYPE_IPV6:
+#if defined(__FreeBSD__)
+      ret->addr6.__u6_addr = host->addr6.__u6_addr;
+#else
       ret->addr6.__in6_u = host->addr6.__in6_u;
+#endif
       break;
     default:
       g_free (ret);