• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From fb79ae7bede940f0fef538472ff8a726df780f8f Mon Sep 17 00:00:00 2001
2From: bradh352 <brad@brad-house.com>
3Date: Mon, 22 May 2023 07:09:40 -0400
4Subject: [PATCH] minor CI issues fixes for imported inet_net_pton
5
6---
7 src/lib/inet_net_pton.c | 53 ++---------------------------------------
8 1 file changed, 2 insertions(+), 51 deletions(-)
9
10diff --git a/src/lib/inet_net_pton.c b/src/lib/inet_net_pton.c
11index d94a5f4..7130f0f 100644
12--- a/src/lib/inet_net_pton.c
13+++ b/src/lib/inet_net_pton.c
14@@ -214,49 +214,6 @@ getbits(const char *src, int *bitsp)
15   return (1);
16 }
17
18-static int
19-getv4(const char *src, unsigned char *dst, int *bitsp)
20-{
21-  static const char digits[] = "0123456789";
22-  unsigned char *odst = dst;
23-  int n;
24-  unsigned int val;
25-  char ch;
26-
27-  val = 0;
28-  n = 0;
29-  while ((ch = *src++) != '\0') {
30-    const char *pch;
31-
32-    pch = strchr(digits, ch);
33-    if (pch != NULL) {
34-      if (n++ != 0 && val == 0)       /* no leading zeros */
35-        return (0);
36-      val *= 10;
37-      val += aresx_sztoui(pch - digits);
38-      if (val > 255)                  /* range */
39-        return (0);
40-      continue;
41-    }
42-    if (ch == '.' || ch == '/') {
43-      if (dst - odst > 3)             /* too many octets? */
44-        return (0);
45-      *dst++ = (unsigned char)val;
46-      if (ch == '/')
47-        return (getbits(src, bitsp));
48-      val = 0;
49-      n = 0;
50-      continue;
51-    }
52-    return (0);
53-  }
54-  if (n == 0)
55-    return (0);
56-  if (dst - odst > 3)             /* too many octets? */
57-    return (0);
58-  *dst = (unsigned char)val;
59-  return 1;
60-}
61
62 static int
63 ares_inet_pton6(const char *src, unsigned char *dst)
64@@ -287,7 +244,7 @@ ares_inet_pton6(const char *src, unsigned char *dst)
65       if (count_xdigit >= 4)
66         goto enoent;
67       val <<= 4;
68-      val |= (pch - xdigits);
69+      val |= (unsigned int)(pch - xdigits);
70       if (val > 0xffff)
71         goto enoent;
72       saw_xdigit = 1;
73@@ -317,7 +274,6 @@ ares_inet_pton6(const char *src, unsigned char *dst)
74         ares_inet_net_pton_ipv4(curtok, tp, NS_INADDRSZ) > 0) {
75       tp += NS_INADDRSZ;
76       saw_xdigit = 0;
77-      count_xdigit = 0;
78       break;  /* '\0' was seen by inet_pton4(). */
79     }
80     goto enoent;
81@@ -333,7 +289,7 @@ ares_inet_pton6(const char *src, unsigned char *dst)
82      * Since some memmove()'s erroneously fail to handle
83      * overlapping regions, we'll do the shift by hand.
84      */
85-    const int n = tp - colonp;
86+    const int n = (int)(tp - colonp);
87     int i;
88
89     if (tp == endp)
90@@ -353,10 +309,6 @@ ares_inet_pton6(const char *src, unsigned char *dst)
91 enoent:
92   SET_ERRNO(ENOENT);
93   return (-1);
94-
95-emsgsize:
96-  SET_ERRNO(EMSGSIZE);
97-  return (-1);
98 }
99
100 static int
101@@ -368,7 +320,6 @@ ares_inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size)
102   size_t               bytes;
103   char                 buf[INET6_ADDRSTRLEN + sizeof("/128")];
104   char                *sep;
105-  const char          *errstr;
106
107   if (strlen(src) >= sizeof buf) {
108     SET_ERRNO(EMSGSIZE);
109--
1102.27.0
111
112