<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>
GitLab
</title>



<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<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/611ce34988a2c9eabaa84ff0af7d240a6b44a9dc">611ce349</a></strong>
<div>
<span>by Eric S. Raymond</span>
<i>at 2019-01-16T07:03:22Z</i>
</div>
<pre class="commit-message" style="white-space: pre-wrap; margin: 0;">Fix a bug in handling of the rate-limiting KOD.

The Classic code did the equivalent of this - not identical because
some structures gave been refactored:

        if (rbufp->pkt.ppoll > peer->cfg.minpoll)
                peer->cfg.minpoll = peer->ppoll;
        poll_update(peer, rbufp->pkt.ppoll);

During the Great Refactoring of the protocol machine, Daniel changed
it to this:

        if (peer->cfg.minpoll < 10) { peer->cfg.minpoll = 10; }
        poll_update(peer, 10);

Thw second line prevented the polling rate from being set arbitrarily
high by a malicious KOD from the server.  But the first line
introduced a bug - on receipt of any rate-limiter KOD the client would
get stuck at poll interval 10 and never recover.

This change reverts to allowing the KOD to both adjust the poll
interval and the minimum poll interval, but shortstops malicious
attempts to set them to unhelpfully high values.
</pre>
</li>
</ul>
<h4>1 changed file:</h4>
<ul>
<li class="file-stats">
<a href="#a9eeb2d7f139fd99254bacd1e507b63de174c843">
ntpd/ntp_proto.c
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id="a9eeb2d7f139fd99254bacd1e507b63de174c843">
<a href="https://gitlab.com/NTPsec/ntpsec/commit/611ce34988a2c9eabaa84ff0af7d240a6b44a9dc#a9eeb2d7f139fd99254bacd1e507b63de174c843"><strong>ntpd/ntp_proto.c</strong></a>
<hr>
<table class="code white" style="font-family: monospace; font-size: 90%;" bgcolor="#fff" width="100%" cellpadding="0" cellspacing="0">
<tr class="line_holder match" id="" style="line-height: 1.6;">
<td class="diff-line-num unfold js-unfold old_line" data-linenumber="519" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">...</td>
<td class="diff-line-num unfold js-unfold new_line" data-linenumber="519" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">...</td>
<td class="line_content match " style="padding-left: 0.5em; padding-right: 0.5em; color: rgba(0,0,0,0.3);" bgcolor="#fafafa">@@ -519,10 +519,11 @@ handle_procpkt(</td>
</tr>
<tr class="line_holder" id="" style="line-height: 1.6;">
<td class="diff-line-num old_line" data-linenumber="519" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
519
</td>
<td class="diff-line-num new_line" data-linenumber="519" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
519
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC519" class="line" lang="c">            <span class="k" style="font-weight: 600;">if</span><span class="p">(</span><span class="o" style="font-weight: 600;">!</span><span class="n" style="color: #333;">memcmp</span><span class="p">(</span><span class="n" style="color: #333;">rbufp</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">pkt</span><span class="p">.</span><span class="n" style="color: #333;">refid</span><span class="p">,</span> <span class="s" style="color: #d14;">"RATE"</span><span class="p">,</span> <span class="n" style="color: #333;">REFIDLEN</span><span class="p">))</span> <span class="p">{</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="" style="line-height: 1.6;">
<td class="diff-line-num old_line" data-linenumber="520" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
520
</td>
<td class="diff-line-num new_line" data-linenumber="520" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
520
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC520" class="line" lang="c">                    <span class="n" style="color: #333;">peer</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">selbroken</span><span class="o" style="font-weight: 600;">++</span><span class="p">;</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="" style="line-height: 1.6;">
<td class="diff-line-num old_line" data-linenumber="521" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
521
</td>
<td class="diff-line-num new_line" data-linenumber="521" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
521
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC521" class="line" lang="c">                    <span class="n" style="color: #333;">report_event</span><span class="p">(</span><span class="n" style="color: #333;">PEVNT_RATE</span><span class="p">,</span> <span class="n" style="color: #333;">peer</span><span class="p">,</span> <span class="nb" style="color: #0086b3;">NULL</span><span class="p">);</span></span>
</pre>
</td>
</tr>
<tr class="line_holder old" id="" style="line-height: 1.6;">
<td class="diff-line-num old old_line" data-linenumber="522" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
522
</td>
<td class="diff-line-num new_line old" data-linenumber="522" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
 
</td>
<td class="line_content noteable_line old" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#fbe9eb">
<pre style="margin: 0;">-<span id="LC522" class="line" lang="c">                    <span class="k" style="font-weight: 600;">if</span> <span class="p">(</span><span class="n" style="color: #333;">peer</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">cfg</span><span class="p">.</span><span class="n" style="color: #333;">minpoll</span> <span class="o" style="font-weight: 600;"><</span> <span class="mi" style="color: #099;">10</span><span class="p">)</span> <span class="p">{</span> <span class="n" style="color: #333;">peer</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">cfg</span><span class="p">.</span><span class="n" style="color: #333;">minpoll</span> <span class="o" style="font-weight: 600;">=</span> <span class="mi" style="color: #099;">10</span><span class="p">;</span> <span class="p">}</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="" style="line-height: 1.6;">
<td class="diff-line-num old_line" data-linenumber="523" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
523
</td>
<td class="diff-line-num new_line" data-linenumber="522" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
522
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC522" class="line" lang="c">                    <span class="n" style="color: #333;">peer</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">burst</span> <span class="o" style="font-weight: 600;">=</span> <span class="n" style="color: #333;">peer</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">retry</span> <span class="o" style="font-weight: 600;">=</span> <span class="mi" style="color: #099;">0</span><span class="p">;</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="" style="line-height: 1.6;">
<td class="diff-line-num old_line" data-linenumber="524" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
524
</td>
<td class="diff-line-num new_line" data-linenumber="523" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
523
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC523" class="line" lang="c">                    <span class="n" style="color: #333;">peer</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">throttle</span> <span class="o" style="font-weight: 600;">=</span> <span class="p">(</span><span class="n" style="color: #333;">NTP_SHIFT</span> <span class="o" style="font-weight: 600;">+</span> <span class="mi" style="color: #099;">1</span><span class="p">)</span> <span class="o" style="font-weight: 600;">*</span> <span class="p">(</span><span class="mi" style="color: #099;">1</span> <span class="o" style="font-weight: 600;"><<</span> <span class="n" style="color: #333;">peer</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">cfg</span><span class="p">.</span><span class="n" style="color: #333;">minpoll</span><span class="p">);</span></span>
</pre>
</td>
</tr>
<tr class="line_holder old" id="" style="line-height: 1.6;">
<td class="diff-line-num old old_line" data-linenumber="525" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
525
</td>
<td class="diff-line-num new_line old" data-linenumber="524" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
 
</td>
<td class="line_content noteable_line old" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#fbe9eb">
<pre style="margin: 0;">-<span id="LC525" class="line" lang="c">                    <span class="n" style="color: #333;">poll_update</span><span class="p">(</span><span class="n" style="color: #333;">peer</span><span class="p">,</span> <span class="mi" style="color: #099;">10</span><span class="p">);</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="" style="line-height: 1.6;">
<td class="diff-line-num new old_line" data-linenumber="526" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="diff-line-num new new_line" data-linenumber="524" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
524
</td>
<td class="line_content new noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC524" class="line" lang="c">                    <span class="k" style="font-weight: 600;">if</span> <span class="p">(</span><span class="n" style="color: #333;">rbufp</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">pkt</span><span class="p">.</span><span class="n" style="color: #333;">ppoll</span> <span class="o" style="font-weight: 600;">></span> <span class="n" style="color: #333;">peer</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">cfg</span><span class="p">.</span><span class="n" style="color: #333;">minpoll</span><span class="p">)</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="" style="line-height: 1.6;">
<td class="diff-line-num new old_line" data-linenumber="526" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="diff-line-num new new_line" data-linenumber="525" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
525
</td>
<td class="line_content new noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC525" class="line" lang="c">                        <span class="n" style="color: #333;">peer</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">cfg</span><span class="p">.</span><span class="n" style="color: #333;">minpoll</span> <span class="o" style="font-weight: 600;">=</span> <span class="n" style="color: #333;">min</span><span class="p">(</span><span class="n" style="color: #333;">peer</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">ppoll</span><span class="p">,</span> <span class="mi" style="color: #099;">10</span><span class="p">);</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="" style="line-height: 1.6;">
<td class="diff-line-num new old_line" data-linenumber="526" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="diff-line-num new new_line" data-linenumber="526" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
526
</td>
<td class="line_content new noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC526" class="line" lang="c">                    <span class="n" style="color: #333;">poll_update</span><span class="p">(</span><span class="n" style="color: #333;">peer</span><span class="p">,</span> <span class="n" style="color: #333;">min</span><span class="p">(</span><span class="n" style="color: #333;">rbufp</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">pkt</span><span class="p">.</span><span class="n" style="color: #333;">ppoll</span><span class="p">,</span> <span class="mi" style="color: #099;">10</span><span class="p">));</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="" style="line-height: 1.6;">
<td class="diff-line-num old_line" data-linenumber="526" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
526
</td>
<td class="diff-line-num new_line" data-linenumber="527" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
527
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC527" class="line" lang="c">            <span class="p">}</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="" style="line-height: 1.6;">
<td class="diff-line-num old_line" data-linenumber="527" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
527
</td>
<td class="diff-line-num new_line" data-linenumber="528" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
528
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC528" class="line" lang="c">            <span class="k" style="font-weight: 600;">return</span><span class="p">;</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="" style="line-height: 1.6;">
<td class="diff-line-num old_line" data-linenumber="528" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
528
</td>
<td class="diff-line-num new_line" data-linenumber="529" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
529
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC529" class="line" lang="c">    <span class="p">}</span></span>
</pre>
</td>
</tr>

</table>
<br>
</li>

</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #777777;">

<br>
<a href="https://gitlab.com/NTPsec/ntpsec/commit/611ce34988a2c9eabaa84ff0af7d240a6b44a9dc">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/611ce34988a2c9eabaa84ff0af7d240a6b44a9dc"}}</script>
</p>
</div>
</body>
</html>