]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
client: drop unnecessary parsing of IPv4 address
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 17 Aug 2020 15:06:28 +0000 (17:06 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 18 Aug 2020 12:22:55 +0000 (14:22 +0200)
client.c

index cf40ebfd71b85c8ebafb57af4af2d807c1885113..c5d20101ce56bd198e3a9bb0bc16bcb0b071cf96 100644 (file)
--- a/client.c
+++ b/client.c
@@ -960,39 +960,12 @@ process_cmd_cmddenyall(CMD_Request *msg, char *line)
 
 /* ================================================== */
 
-static int
-accheck_getaddr(char *line, IPAddr *addr)
-{
-  unsigned long a, b, c, d;
-  IPAddr ip;
-  char *p;
-  p = line;
-  if (!*p) {
-    return 0;
-  } else {
-    if (sscanf(p, "%lu.%lu.%lu.%lu", &a, &b, &c, &d) == 4) {
-      addr->family = IPADDR_INET4;
-      addr->addr.in4 = (a<<24) | (b<<16) | (c<<8) | d;
-      return 1;
-    } else {
-      if (DNS_Name2IPAddress(p, &ip, 1) != DNS_Success) {
-        return 0;
-      } else {
-        *addr = ip;
-        return 1;
-      }
-    }
-  }
-}
-
-/* ================================================== */
-
 static int
 process_cmd_accheck(CMD_Request *msg, char *line)
 {
   IPAddr ip;
   msg->command = htons(REQ_ACCHECK);
-  if (accheck_getaddr(line, &ip)) {
+  if (DNS_Name2IPAddress(line, &ip, 1) == DNS_Success) {
     UTI_IPHostToNetwork(&ip, &msg->data.ac_check.ip);
     return 1;
   } else {    
@@ -1008,7 +981,7 @@ process_cmd_cmdaccheck(CMD_Request *msg, char *line)
 {
   IPAddr ip;
   msg->command = htons(REQ_CMDACCHECK);
-  if (accheck_getaddr(line, &ip)) {
+  if (DNS_Name2IPAddress(line, &ip, 1) == DNS_Success) {
     UTI_IPHostToNetwork(&ip, &msg->data.ac_check.ip);
     return 1;
   } else {