<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
  img {
    max-width: 100%;
    height: auto;
  }
  p.details {
    font-style:italic;
    color:#777
  }
  .footer p {
    font-size:small;
    color:#777
  }
  pre.commit-message {
    white-space: pre-wrap;
  }
  .file-stats a {
    text-decoration: none;
  }
  .file-stats .new-file {
    color: #090;
  }
  .file-stats .deleted-file {
    color: #B00;
  }
</style>
<body>
<div class='content'>
<h3>
Eric S. Raymond pushed to branch master
at <a href="https://gitlab.com/NTPsec/ntpsec">NTPsec / ntpsec</a>
</h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.com/NTPsec/ntpsec/commit/fe0fd0d2ca5aaee566d1ee544d42d5054a254a0c">fe0fd0d2</a></strong>
<div>
<span>by Eric S. Raymond</span>
<i>at 2015-12-31T01:00:39Z</i>
</div>
<pre class='commit-message'>Replay - full interception of getaddrinfo calls.</pre>
</li>
</ul>
<h4>1 changed file:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
ntpd/ntp_intercept.c
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://gitlab.com/NTPsec/ntpsec/commit/fe0fd0d2ca5aaee566d1ee544d42d5054a254a0c#diff-0'>
<strong>
ntpd/ntp_intercept.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/ntpd/ntp_intercept.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/ntpd/ntp_intercept.c
</span><span style="color: #aaaaaa">@@ -8,7 +8,7 @@ following kinds:
</span> 
 1. Startup, capuring command-line switches.
 
<span style="color: #000000;background-color: #ffdddd">-2. Configuration read.
</span><span style="color: #000000;background-color: #ddffdd">+2. Configuration read (and synchronous DNS call/returns).
</span> 
 3. Time reports from reference clocks.
 
<span style="color: #aaaaaa">@@ -240,6 +240,31 @@ static void file_replay(const char *configfile, char *delimiter, char *tempfile)
</span> 
 bool intercept_getaddrinfo(char *hname, sockaddr_u *peeraddrp)
 {
<span style="color: #000000;background-color: #ddffdd">+    if (mode == replay) {
+       char addr[BUFSIZ], ip[BUFSIZ];
+       int retval;
+
+       get_operation("getaddrinfo");
+       if (sscanf(linebuf, "getaddrinfo %s %s %d", addr, ip, &retval) != 3) {
+           fprintf(stderr, "ntpd: garbled getaddrinfo format, line %d\n", lineno);
+           exit(1);
+       }
+       if (strcmp(hname, addr) != 0) {
+           fprintf(stderr, "ntpd: saw hostname %s, when expecting %s\n",
+                   addr, hname);
+           exit(1);
+       }
+       if (retval == 0) {
+           fprintf(stderr, "ntpd: hostname %s lookup failed\n",
+                   addr);
+           exit(1);
+       }
+       if (!is_ip_address(ip, AF_UNSPEC, peeraddrp)) {
+           fprintf(stderr, "ntpd: invalid IP address in getaddrinfo at line %d\n", lineno);
+           exit(1);
+       }
+       return true;
+    } else {
</span>   int a_info;
        size_t octets;
        struct addrinfo         hints, *res;
<span style="color: #aaaaaa">@@ -253,23 +278,29 @@ bool intercept_getaddrinfo(char *hname, sockaddr_u *peeraddrp)
</span> #ifdef EAI_NODATA
            || a_info == EAI_NODATA
 #endif
<span style="color: #000000;background-color: #ffdddd">-           ) {
-               hints.ai_flags = AI_CANONNAME;
-               hints.ai_flags |= AI_ADDRCONFIG;
-               a_info = getaddrinfo(hname, "ntp", &hints, &res);
</span><span style="color: #000000;background-color: #ddffdd">+       ) {
+           hints.ai_flags = AI_CANONNAME;
+           hints.ai_flags |= AI_ADDRCONFIG;
+           a_info = getaddrinfo(hname, "ntp", &hints, &res);
</span>   }
<span style="color: #000000;background-color: #ddffdd">+        if (mode == capture)
+           printf("getaddrinfo %s %s %d\n",
+                  hname,
+                  socktoa((sockaddr_u *)res->ai_addr),
+                  a_info == 0);
</span>   if (a_info != 0) {
<span style="color: #000000;background-color: #ffdddd">-                msyslog(LOG_ERR,
-                       "hostname %s can not be used (%s), please use IP address.",
-                       hname, gai_strerror(a_info));
-               return false;
</span><span style="color: #000000;background-color: #ddffdd">+       msyslog(LOG_ERR,
+                   "hostname %s can not be used (%s), please use IP address.",
+                   hname, gai_strerror(a_info));
+           return false;
</span>   } else {
<span style="color: #000000;background-color: #ffdddd">-                INSIST(res != NULL);
-               memset(peeraddrp, '\0', sizeof(*peeraddrp));
-               octets = min(sizeof(*peeraddrp), res->ai_addrlen);
-               memcpy(peeraddrp, res->ai_addr, octets);
-               return true;
</span><span style="color: #000000;background-color: #ddffdd">+       INSIST(res != NULL);
+           memset(peeraddrp, '\0', sizeof(*peeraddrp));
+           octets = min(sizeof(*peeraddrp), res->ai_addrlen);
+           memcpy(peeraddrp, res->ai_addr, octets);
+           return true;
</span>   }
<span style="color: #000000;background-color: #ddffdd">+    }
</span> }
 
 void intercept_getconfig(const char *configfile)
<span style="color: #aaaaaa">@@ -289,6 +320,7 @@ void intercept_getconfig(const char *configfile)
</span> 
        if (configfile != NULL && mode == capture)
            pump(configfile, "startconfig\n", "endconfig\n", stdout);
<span style="color: #000000;background-color: #ddffdd">+
</span>   /*
         * Has to be done here because intercept_drift_read() is called from
         * inside the config parser - otherwise, things get emitted in the
</code></pre>

<br>
</li>

</div>
<div class='footer' style='margin-top: 10px;'>
<p>

<br>
<a href="https://gitlab.com/NTPsec/ntpsec/commit/fe0fd0d2ca5aaee566d1ee544d42d5054a254a0c">View it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://gitlab.com/NTPsec/ntpsec/commit/fe0fd0d2ca5aaee566d1ee544d42d5054a254a0c"}}</script>
</p>
</div>
</body>
</html>