aboutsummaryrefslogtreecommitdiffstats
path: root/main/zabbix/zabbix-dn_skipname.patch
blob: 5d206397138fe411d3804de3ebed0f8998690a33 (plain)
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
diff --git a/src/libs/zbxsysinfo/common/net.c b/src/libs/zbxsysinfo/common/net.c
index c8956a6..645fd8c 100644
--- a/src/libs/zbxsysinfo/common/net.c
+++ b/src/libs/zbxsysinfo/common/net.c
@@ -26,6 +26,39 @@
 
 #include "net.h"
 
+#if defined(__UCLIBC__)
+/*
+ * Skip over a compressed domain name. Return the size or -1.
+ */
+int
+dn_skipname(const u_char *comp_dn, const u_char *eom)
+{
+       const u_char *cp;
+       int n;
+
+       cp = comp_dn;
+       while (cp < eom && (n = *cp++)) {
+               /*
+                * check for indirection
+                */
+               switch (n & INDIR_MASK) {
+               case 0:                 /* normal case, n == len */
+                       cp += n;
+                       continue;
+               case INDIR_MASK:        /* indirection */
+                       cp++;
+                       break;
+               default:                /* illegal type */
+                       return (-1);
+               }
+               break;
+       }
+       if (cp > eom)
+               return (-1);
+       return (cp - comp_dn);
+}
+#endif
+
 /*
  * 0 - NOT OK
  * 1 - OK