<!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=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>
<style>img {
max-width: 100%; height: auto;
}
body.modal-open {
overflow: hidden;
}
body {
font-size: 0.875rem;
}
body {
-webkit-text-shadow: rgba(255,255,255,0.01) 0 0 1px;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, "Helvetica Neue", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style='font-size: inherit; -webkit-text-shadow: rgba(255,255,255,0.01) 0 0 1px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, "Helvetica Neue", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";'>
<div class="content">
<p style="color: #777777;">
<a href="https://gitlab.com/dueno" style="color: #1068bf; text-decoration: none;">Daiki Ueno</a>
<a href="https://gitlab.com/gnutls/gnutls/-/issues/1311#note_897860133" style="color: #1068bf; text-decoration: none;">commented</a>:
</p>
<div class="md" style="color: #303030; word-wrap: break-word;">
<p dir="auto" style="color: #303030; margin: 0 0 16px;" align="initial">Thanks Pedro for proposing the patch, and thanks Zoltan for picking it up :-)
While I suggested the approach that is to push a temporary context, after a second thought I am feeling that it might be simpler to add a couple of helper functions that don't touch the context at all, something like:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-c" lang="c" v-pre="true" style='display: block; font-size: 13px; color: #303030; text-shadow: none; line-height: 1.6em; overflow-x: auto; border-radius: 2px; position: relative; font-family: "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; word-break: break-all; word-wrap: break-word; background-color: #fafafa; margin: 0 0 16px; padding: 12px; border: 1px solid #dbdbdb;'><code style='font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: 4px; white-space: pre; margin-top: 0; font-family: "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; overflow-wrap: normal; padding: unset;'><span id="LC1" class="line" lang="c" style="margin-top: 0;"><span class="kt" style="margin-top: 0;">int</span></span>
<span id="LC2" class="line" lang="c"><span class="nf" style="margin-top: 0;">_gnutls_hkdf_expand</span><span class="p">(...)</span></span>
<span id="LC3" class="line" lang="c"><span class="p" style="margin-top: 0;">{</span></span>
<span id="LC4" class="line" lang="c"> <span class="cm" style="margin-top: 0;">/* this is a helper function, which does not change the context */</span></span>
<span id="LC5" class="line" lang="c"><span class="p" style="margin-top: 0;">}</span></span>
<span id="LC6" class="line" lang="c"></span>
<span id="LC7" class="line" lang="c"><span class="kt" style="margin-top: 0;">int</span></span>
<span id="LC8" class="line" lang="c"><span class="nf" style="margin-top: 0;">gnutls_hkdf_expand</span><span class="p">(...)</span></span>
<span id="LC9" class="line" lang="c"><span class="p" style="margin-top: 0;">{</span></span>
<span id="LC10" class="line" lang="c"> <span class="cm" style="margin-top: 0;">/* this is a public API function */</span></span>
<span id="LC11" class="line" lang="c"> <span class="n" style="margin-top: 0;">ret</span> <span class="o">=</span> <span class="n">_gnutls_hkdf_expand</span><span class="p">(...);</span></span>
<span id="LC12" class="line" lang="c"> <span class="cm" style="margin-top: 0;">/* switch the context to "not approved" or "error" */</span></span>
<span id="LC13" class="line" lang="c"> <span class="k" style="margin-top: 0;">return</span> <span class="n">ret</span><span class="p">;</span></span>
<span id="LC14" class="line" lang="c"><span class="p" style="margin-top: 0;">}</span></span>
<span id="LC15" class="line" lang="c"></span>
<span id="LC16" class="line" lang="c"><span class="kt" style="margin-top: 0;">int</span></span>
<span id="LC17" class="line" lang="c"><span class="nf" style="margin-top: 0;">_tls13_expand_secret2</span><span class="p">(...)</span></span>
<span id="LC18" class="line" lang="c"><span class="p" style="margin-top: 0;">{</span></span>
<span id="LC19" class="line" lang="c"> <span class="cm" style="margin-top: 0;">/* this is the TLS usage */</span></span>
<span id="LC20" class="line" lang="c"> <span class="n" style="margin-top: 0;">ret</span> <span class="o">=</span> <span class="n">_gnutls_hkdf_expand</span><span class="p">(...);</span></span>
<span id="LC21" class="line" lang="c"> <span class="cm" style="margin-top: 0;">/* switch the context to "approved" or "error" */</span></span>
<span id="LC22" class="line" lang="c"> <span class="k" style="margin-top: 0;">return</span> <span class="n">ret</span><span class="p">;</span></span>
<span id="LC23" class="line" lang="c"><span class="p" style="margin-top: 0;">}</span></span></code></pre>
<copy-code></copy-code>
</div>
<p dir="auto" style="color: #303030; margin: 0;" align="initial">That way, we don't need a temporary context and avoid polluting the log messages.</p>
</div>
</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #666;">
—
<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/-/issues/1311#note_897860133" style="color: #1068bf; text-decoration: none;">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/cb9e8dda5222692f72675619e81065c0/unsubscribe" style="color: #1068bf; text-decoration: none;">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 Issue","url":"https://gitlab.com/gnutls/gnutls/-/issues/1311#note_897860133"}}</script>
</p>
</div>
</body>
</html>