<div dir="ltr">that passes my test and GCC&#39;s -Wstrict-overflow=5 no longer complains about those two lines (though it does still have several other complaints about localtime.c). committed to Android&#39;s C library as 713fe6463e6ff8cb9689aa8ead88c885d25d03aa (<a href="https://android-review.googlesource.com/#/c/64140/">https://android-review.googlesource.com/#/c/64140/</a>).<div>

<br></div><div>thanks!</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 22, 2013 at 12:53 PM, Paul Eggert <span dir="ltr">&lt;<a href="mailto:eggert@cs.ucla.edu" target="_blank">eggert@cs.ucla.edu</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 08/22/13 11:35, enh wrote:<br>
<br>
&gt; looking at the Android AOSP git history, it looks like we found and<br>
&gt; fixed this bug years ago but never talked to upstream about it:<br>
<br>
</div>Thanks for the heads-up.  If I understand all those patches aright,<br>
the following patch (which I&#39;ve pushed to the experimental github<br>
repository) should fix things.  I&#39;ve fixed some other integer-overflow<br>
issues in the past few months, but I missed this one (and there are<br>
probably others I&#39;ve missed).<br>
<br>
>From 943a6621866e9d6e654f5cfe1494378c1fb8957a Mon Sep 17 00:00:00 2001<br>
From: Paul Eggert &lt;<a href="mailto:eggert@cs.ucla.edu">eggert@cs.ucla.edu</a>&gt;<br>
Date: Thu, 22 Aug 2013 12:47:51 -0700<br>
Subject: [PATCH] * localtime.c: Fix another integer overflow bug in mktime.<br>
<br>
(time2sub): Avoid undefined behavior on time_t overflow.<br>
Reported by Elliott Hughes in<br>
&lt;<a href="http://mm.icann.org/pipermail/tz/2013-August/019580.html" target="_blank">http://mm.icann.org/pipermail/tz/2013-August/019580.html</a>&gt;.<br>
---<br>
 localtime.c | 8 ++++----<br>
 1 file changed, 4 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/localtime.c b/localtime.c<br>
index f58b20a..a0a4e5e 100644<br>
--- a/localtime.c<br>
+++ b/localtime.c<br>
@@ -1789,14 +1789,14 @@ time2sub(struct tm *const tmp,<br>
<div class="im">                } else  dir = tmcomp(&amp;mytm, &amp;yourtm);<br>
                if (dir != 0) {<br>
                        if (t == lo) {<br>
-                               ++t;<br>
-                               if (t &lt;= lo)<br>
</div>+                               if (t == time_t_max)<br>
<div class="im">                                        return WRONG;<br>
+                               ++t;<br>
                                ++lo;<br>
                        } else if (t == hi) {<br>
-                               --t;<br>
-                               if (t &gt;= hi)<br>
</div>+                               if (t == time_t_min)<br>
<div class="HOEnZb"><div class="h5">                                        return WRONG;<br>
+                               --t;<br>
                                --hi;<br>
                        }<br>
                        if (lo &gt; hi)<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
1.7.11.7<br>
<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Elliott Hughes - <a href="http://who/enh" target="_blank">http://who/enh</a> - <a href="http://jessies.org/~enh/" target="_blank">http://jessies.org/~enh/</a><br>

Java i18n/JNI/NIO, or bionic questions? Mail me/drop by/add me as a reviewer.</div>
</div>