<!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">
<p class="details" style="font-style: italic; color: #777777;">
<a href="https://gitlab.com/Vrancken">Tom</a>
started a new discussion
on <a href="https://gitlab.com/gnutls/gnutls/merge_requests/789#note_113516677">lib/priority.c</a>:
</p>
<table>
<tr class="line_holder new" id="">
<td class="diff-line-num new old_line" data-linenumber="1797" 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="1800" 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">
1800
</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="LC1800" class="line" lang="c">                                                   <span class="n" style="color: #333;">cert_type_priority_all</span><span class="p">);</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="1797" 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">
1797
</td>
<td class="diff-line-num new_line" data-linenumber="1801" 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">
1801
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC1801" class="line" lang="c">                                   <span class="p">}</span> <span class="k" style="font-weight: 600;">else</span> <span class="k" style="font-weight: 600;">if</span> <span class="p">((</span><span class="n" style="color: #333;">algo</span> <span class="o" style="font-weight: 600;">=</span> <span class="n" style="color: #333;">gnutls_certificate_type_get_id</span></span>
</pre>
</td>
</tr>
<tr class="line_holder old" id="">
<td class="diff-line-num old old_line" data-linenumber="1798" 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">
1798
</td>
<td class="diff-line-num new_line old" data-linenumber="1802" 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="LC1798" class="line" lang="c">                                                   <span class="p">(</span><span class="o" style="font-weight: 600;">&</span><span class="n" style="color: #333;">broken_list</span><span class="p">[</span><span class="n" style="color: #333;">i</span><span class="p">][</span><span class="mi" style="color: #099;">11</span><span class="p">]))</span> <span class="o" style="font-weight: 600;">!=</span> <span class="n" style="color: #333;">GNUTLS_CRT_UNKNOWN</span><span class="p">)</span></span>
</pre>
</td>
</tr>
<tr class="line_holder old" id="">
<td class="diff-line-num old old_line" data-linenumber="1799" 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">
1799
</td>
<td class="diff-line-num new_line old" data-linenumber="1802" 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="LC1799" class="line" lang="c">                                   <span class="p"><span class="idiff left">{</span></span><span class="idiff right"> </span><span class="c1" style="color: #998; font-style: italic;">// Specific server cert type allowed</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="diff-line-num new old_line" data-linenumber="1800" 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="1802" 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">
1802
</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="LC1802" class="line" lang="c">                                                   <span class="p">(</span><span class="o" style="font-weight: 600;">&</span><span class="n" style="color: #333;">broken_list</span><span class="p">[</span><span class="n" style="color: #333;">i</span><span class="p">][</span><span class="mi" style="color: #099;">11</span><span class="p">]))</span> <span class="o" style="font-weight: 600;">!=</span> <span class="n" style="color: #333;">GNUTLS_CRT_UNKNOWN</span><span class="p">)</span><span class="idiff left"> </span><span class="p"><span class="idiff right">{</span></span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="diff-line-num new old_line" data-linenumber="1800" 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="1803" 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">
1803
</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="LC1803" class="line" lang="c">                                   <span class="idiff left right">         </span><span class="c1" style="color: #998; font-style: italic;">// Specific server cert type allowed</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="1800" 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">
1800
</td>
<td class="diff-line-num new_line" data-linenumber="1804" 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">
1804
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC1804" class="line" lang="c">                                           <span class="n" style="color: #333;">fn</span><span class="p">(</span><span class="o" style="font-weight: 600;">&</span><span class="p">(</span><span class="o" style="font-weight: 600;">*</span><span class="n" style="color: #333;">priority_cache</span><span class="p">)</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">server_ctype</span><span class="p">,</span> <span class="n" style="color: #333;">algo</span><span class="p">);</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="1801" 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">
1801
</td>
<td class="diff-line-num new_line" data-linenumber="1805" 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">
1805
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC1805" class="line" lang="c">                                   <span class="p">}</span> <span class="k" style="font-weight: 600;">else</span> <span class="k" style="font-weight: 600;">goto</span> <span class="n" style="color: #333;">error</span><span class="p">;</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="1802" 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">
1802
</td>
<td class="diff-line-num new_line" data-linenumber="1806" 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">
1806
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC1806" class="line" lang="c">                           <span class="p">}</span> <span class="k" style="font-weight: 600;">else</span> <span class="p">{</span> <span class="c1" style="color: #998; font-style: italic;">// Symmetric certificate type</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="1803" 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">
1803
</td>
<td class="diff-line-num new_line" data-linenumber="1807" 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">
1807
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC1807" class="line" lang="c">                                   <span class="k" style="font-weight: 600;">if</span> <span class="p">((</span><span class="n" style="color: #333;">algo</span> <span class="o" style="font-weight: 600;">=</span> <span class="n" style="color: #333;">gnutls_certificate_type_get_id</span></span>
</pre>
</td>
</tr>
<tr class="line_holder old" id="">
<td class="diff-line-num old old_line" data-linenumber="1804" 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">
1804
</td>
<td class="diff-line-num new_line old" data-linenumber="1808" 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="LC1804" class="line" lang="c">                                        <span class="p">(</span><span class="o" style="font-weight: 600;">&</span><span class="n" style="color: #333;">broken_list</span><span class="p">[</span><span class="n" style="color: #333;">i</span><span class="p">][</span><span class="mi" style="color: #099;">7</span><span class="p">]))</span> <span class="o" style="font-weight: 600;">!=</span> <span class="n" style="color: #333;">GNUTLS_CRT_UNKNOWN</span><span class="p">)</span></span>
</pre>
</td>
</tr>
<tr class="line_holder old" id="">
<td class="diff-line-num old old_line" data-linenumber="1805" 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">
1805
</td>
<td class="diff-line-num new_line old" data-linenumber="1808" 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="LC1805" class="line" lang="c">                                   <span class="p">{</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="diff-line-num new old_line" data-linenumber="1806" 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="1808" 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">
1808
</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="LC1808" class="line" lang="c">                                        <span class="p">(</span><span class="o" style="font-weight: 600;">&</span><span class="n" style="color: #333;">broken_list</span><span class="p">[</span><span class="n" style="color: #333;">i</span><span class="p">][</span><span class="mi" style="color: #099;">7</span><span class="p">]))</span> <span class="o" style="font-weight: 600;">!=</span> <span class="n" style="color: #333;">GNUTLS_CRT_UNKNOWN</span><span class="p">)</span> <span class="p">{</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="1806" 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">
1806
</td>
<td class="diff-line-num new_line" data-linenumber="1809" 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">
1809
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC1809" class="line" lang="c">                                           <span class="n" style="color: #333;">fn</span><span class="p">(</span><span class="o" style="font-weight: 600;">&</span><span class="p">(</span><span class="o" style="font-weight: 600;">*</span><span class="n" style="color: #333;">priority_cache</span><span class="p">)</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">client_ctype</span><span class="p">,</span> <span class="n" style="color: #333;">algo</span><span class="p">);</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="1807" 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">
1807
</td>
<td class="diff-line-num new_line" data-linenumber="1810" 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">
1810
</td>
<td class="line_content noteable_line" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC1810" class="line" lang="c">                                           <span class="n" style="color: #333;">fn</span><span class="p">(</span><span class="o" style="font-weight: 600;">&</span><span class="p">(</span><span class="o" style="font-weight: 600;">*</span><span class="n" style="color: #333;">priority_cache</span><span class="p">)</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">server_ctype</span><span class="p">,</span> <span class="n" style="color: #333;">algo</span><span class="p">);</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="diff-line-num new old_line" data-linenumber="1808" 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="1811" 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">
1811
</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="LC1811" class="line" lang="c">                                   <span class="p">}</span> <span class="k" style="font-weight: 600;">else</span> <span class="k" style="font-weight: 600;">if</span> <span class="p">(</span><span class="n" style="color: #333;">strncasecmp</span><span class="p">(</span><span class="o" style="font-weight: 600;">&</span><span class="n" style="color: #333;">broken_list</span><span class="p">[</span><span class="n" style="color: #333;">i</span><span class="p">][</span><span class="mi" style="color: #099;">1</span><span class="p">],</span> <span class="s" style="color: #d14;">"CTYPE-OPENPGP"</span><span class="p">,</span> <span class="mi" style="color: #099;">13</span><span class="p">)</span> <span class="o" style="font-weight: 600;">==</span> <span class="mi" style="color: #099;">0</span><span class="p">)</span> <span class="p">{</span></span>
</pre>
</td>
</tr>

</table>
<div>
<p dir="auto">I think this check should be done first, i.e. before the <code>&broken_list[i][7])) != GNUTLS_CRT_UNKNOWN</code> check. Otherwise we do not reach this second condition. <code>GNUTLS_CRT_OPENPGP</code> is not equal to <code>GNUTLS_CRT_UNKNOWN</code> and therefore we always end up in the first branch.</p>
<p dir="auto">I think this will do the trick:</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true" style="background-color: #fff; font-family: monospace; font-size: 90%; -premailer-cellpadding: 0; -premailer-cellspacing: 0; -premailer-width: 100%; margin: 0;"><code><span id="LC1" class="line" lang="plaintext">if ((algo = gnutls_certificate_type_get_id(&broken_list[i][7])) == GNUTLS_CRT_OPENPGP) {</span>
<span id="LC2" class="line" lang="plaintext">       continue;</span>
<span id="LC3" class="line" lang="plaintext">} else if (algo != GNUTLS_CRT_UNKNOWN) {</span>
<span id="LC4" class="line" lang="plaintext">       //original code</span>
<span id="LC5" class="line" lang="plaintext">}</span></code></pre>
<p dir="auto">or nested differently:</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true" style="background-color: #fff; font-family: monospace; font-size: 90%; -premailer-cellpadding: 0; -premailer-cellspacing: 0; -premailer-width: 100%; margin: 0;"><code><span id="LC1" class="line" lang="plaintext">if ((algo = gnutls_certificate_type_get_id(&broken_list[i][7])) != GNUTLS_CRT_UNKNOWN) {</span>
<span id="LC2" class="line" lang="plaintext">       if (algo == GNUTLS_CRT_OPENPGP) {</span>
<span id="LC3" class="line" lang="plaintext">               continue;</span>
<span id="LC4" class="line" lang="plaintext">       } else {</span>
<span id="LC5" class="line" lang="plaintext">               fn(&(*priority_cache)->client_ctype, algo);</span>
<span id="LC6" class="line" lang="plaintext">               fn(&(*priority_cache)->server_ctype, algo);</span>
<span id="LC7" class="line" lang="plaintext">       }</span>
<span id="LC8" class="line" lang="plaintext">}</span></code></pre>
<p dir="auto">BTW, untested code so please check syntax errors and stuff. It's just to give you an idea.</p>
</div>


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

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/merge_requests/789#note_113516677">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
<a href="https://gitlab.com/sent_notifications/48e3f582e89e696e90de59be21214be0/unsubscribe">unsubscribe</a>
from this thread or
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Merge request","url":"https://gitlab.com/gnutls/gnutls/merge_requests/789#note_113516677"}}</script>
</p>
</div>
</body>
</html>