well, the

+ if (bp == old_bp || errno == ERANGE ||
+    ((long) t) != n) return NULL;

bit is the "most active ingredient" here, deliberately failing (rather than
wrapping) if out of 32-bit range.

it's quite possible that this could use _conv_num64(), but it wasn't
obvious to me that that function's correct? (i haven't thought too hard
about the overflow logic, but just the fact that result is an `int` seems
odd?)

actually, though, checking Android's git history, it seems like the
strtol() came from FreeBSD along with the localtime_r() :-)

(we only support ILP32 and LP64, so strtol() is fine, i think? on a 64-bit
system it's 64-bit which is plenty, and on a 32-bit system, we'll get
ERANGE for stuff that won't fit into 32 bits, which is also the desired
behavior.)

On Thu, Jan 26, 2023 at 6:49 AM Todd C. Miller <todd.mil...@millert.dev>
wrote:

> Is there a reason you didn't just change the gmtime_r() in the 's'
> case to localtime_r()?  That seems like the simplest fix.  Using
> strtol() for what may be a 64-bit value on an 32-bit system looks
> wrong.
>
>  - todd
>

Reply via email to