<!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;
}
</style>
</head>
<body>
<div class="content">

<p style="color: #777777;">
<a href="https://gitlab.com/nmav">Nikos Mavrogiannopoulos</a>
commented on a discussion
on <a href="https://gitlab.com/gnutls/gnutls/merge_requests/994#note_168475016">src/certtool.c</a>:
</p>
<table>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="439" 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">
439
</td>
<td class="diff-line-num new_line" data-linenumber="439" 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">
439
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC439" class="line" lang="c"></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="440" 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">
440
</td>
<td class="diff-line-num new_line" data-linenumber="440" 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">
440
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC440" class="line" lang="c">            <span class="k" style="font-weight: 600;">if</span> <span class="p">(</span><span class="n" style="color: #333;">ca_crt</span> <span class="o" style="font-weight: 600;">&&</span> <span class="p">(</span><span class="n" style="color: #333;">secs</span> <span class="o" style="font-weight: 600;">></span> <span class="n" style="color: #333;">gnutls_x509_crt_get_expiration_time</span><span class="p">(</span><span class="n" style="color: #333;">ca_crt</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="441" 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">
441
</td>
<td class="diff-line-num new_line" data-linenumber="441" 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">
441
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC441" class="line" lang="c">                    <span class="kt" style="color: #458; font-weight: 600;">time_t</span> <span class="n" style="color: #333;">exp</span> <span class="o" style="font-weight: 600;">=</span> <span class="n" style="color: #333;">gnutls_x509_crt_get_expiration_time</span><span class="p">(</span><span class="n" style="color: #333;">ca_crt</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="442" 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">
442
</td>
<td class="diff-line-num new_line old" data-linenumber="442" 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 old" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#fbe9eb">
<pre style="margin: 0;">-<span id="LC442" class="line" lang="c">                    <span class="n" style="color: #333;">fprintf</span><span class="p">(</span><span class="n" style="color: #333;">stderr</span><span class="p">,</span> <span class="s" style="color: #d14;">"</span><span class="se" style="color: #d14;">\n</span><span class="s" style="color: #d14;">Expiration time: %s"</span><span class="p">,</span> <span class="n" style="color: #333;">ctime</span><span class="p">(</span><span class="o" style="font-weight: 600;">&</span><span class="n" style="color: #333;">secs</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="443" 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">
443
</td>
<td class="diff-line-num new_line old" data-linenumber="442" 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 old" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#fbe9eb">
<pre style="margin: 0;">-<span id="LC443" class="line" lang="c">                    <span class="n" style="color: #333;">fprintf</span><span class="p">(</span><span class="n" style="color: #333;">stderr</span><span class="p">,</span> <span class="s" style="color: #d14;">"CA expiration time: %s"</span><span class="p">,</span> <span class="n" style="color: #333;">ctime</span><span class="p">(</span><span class="o" style="font-weight: 600;">&</span><span class="n" style="color: #333;">exp</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="444" 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="442" 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">
442
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC442" class="line" lang="c">                    <span class="n" style="color: #333;">fprintf</span><span class="p">(</span><span class="n" style="color: #333;">stderr</span><span class="p">,</span> <span class="s" style="color: #d14;">"</span><span class="se" style="color: #d14;">\n</span><span class="s" style="color: #d14;">Expiration time: %s"</span><span class="p">,</span> <span class="n" style="color: #333;">ctime</span><span class="p">(</span><span class="o" style="font-weight: 600;">&</span><span class="n" style="color: #333;">secs</span><span class="p">));</span><span class="idiff left"> </span><span class="c1" style="color: #998; font-style: italic;"><span class="idiff right">//lgtm [cpp/potentially-dangerous-function]</span></span></span>
</pre>
</td>
</tr>

</table>
<div style="">
<blockquote dir="auto" style="color: #7f8fa4; border-left-width: 3px; border-left-color: #eaeaea; border-left-style: solid; margin: 0; padding: 0 0 0 15px;">
<p>In this case I would even throw in that ctime() indeed should be avoided. Just think of copy&pasting code into a multi-threaded application or library. After an RCE, someone will ask "where did this code come from ? Oh from GnuTLS - what a crap !".</p>
</blockquote>
<p dir="auto"><code>ctime()</code> is perfectly fine the way it is used in this application. I understand someone else can misuse it but I do not see much value in writing code for other applications than the one intended for. Anyway, I was convinced to make that warning go in general, so I've pushed for another version which uses strftime with '%c'.</p>
</div>


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

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/merge_requests/994#note_168475016">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/9bc1c4f804e4e9bb765844600fa4a16a/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/994#note_168475016"}}</script>

</p>
</div>
</body>
</html>