<p>osmith has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-hlr/+/14364">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">db_hlr: zero-initialize "struct tm"<br><br>The last LU time gets read from the database as string, parsed with<br>strptime to "struct tm", and then gets converted to time_t with mktime.<br><br>A recent behavior change in glibc's mktime implementation unconvered,<br>that we don't have tm.tm_isdst (daylight saving time) set properly. As<br>"struct tm" was not initialized, and strptime did not write to tm_isdst,<br>it was set to a random value. When it was not 0, db_test failed on UTC<br>systems with a more recent glibc (e.g. Ubuntu 19.04).<br><br>Fix this by zero-initializing "struct tm" and remove the previous<br>workaround that made db_test pass on UTC systems.<br><br>Related: OS#4026<br>Change-Id: Iebbbe42fc5cd43324206d9433ede67b39251389c<br>---<br>M src/db_hlr.c<br>M tests/testsuite.at<br>2 files changed, 2 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/64/14364/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/db_hlr.c b/src/db_hlr.c</span><br><span>index 362dcf2..694ac53 100644</span><br><span>--- a/src/db_hlr.c</span><br><span>+++ b/src/db_hlr.c</span><br><span>@@ -445,7 +445,7 @@</span><br><span>    int rc;</span><br><span>      int ret = 0;</span><br><span>         const char *last_lu_seen_str;</span><br><span style="color: hsl(0, 100%, 40%);">-   struct tm tm;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct tm tm = {0};</span><br><span> </span><br><span>      /* execute the statement */</span><br><span>  rc = sqlite3_step(stmt);</span><br><span>diff --git a/tests/testsuite.at b/tests/testsuite.at</span><br><span>index 7d268d1..70ae7ae 100644</span><br><span>--- a/tests/testsuite.at</span><br><span>+++ b/tests/testsuite.at</span><br><span>@@ -29,12 +29,10 @@</span><br><span> AT_CHECK([$abs_top_builddir/tests/gsup_server/gsup_server_test], [], [expout], [experr])</span><br><span> AT_CLEANUP</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-# TZ=CET: workaround for glibc bug in mktime() (https://osmocom.org/issues/4026):</span><br><span style="color: hsl(0, 100%, 40%);">-# "Cannot convert LU timestamp '2019-05-26 03:05:03' to time_t: Value too large for defined data type"</span><br><span> AT_SETUP([db])</span><br><span> AT_KEYWORDS([db])</span><br><span> cat $abs_srcdir/db/db_test.ok > expout</span><br><span> cat $abs_srcdir/db/db_test.err > experr</span><br><span> sqlite3 db_test.db < $abs_top_srcdir/sql/hlr.sql</span><br><span style="color: hsl(0, 100%, 40%);">-AT_CHECK([TZ=CET $abs_top_builddir/tests/db/db_test], [], [expout], [experr])</span><br><span style="color: hsl(120, 100%, 40%);">+AT_CHECK([$abs_top_builddir/tests/db/db_test], [], [expout], [experr])</span><br><span> AT_CLEANUP</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-hlr/+/14364">change 14364</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-hlr/+/14364"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-hlr </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Iebbbe42fc5cd43324206d9433ede67b39251389c </div>
<div style="display:none"> Gerrit-Change-Number: 14364 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: osmith <osmith@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>