libressl / portable

LibreSSL Portable itself. This includes the build scaffold and compatibility layer that builds portable LibreSSL from the OpenBSD source code. Pull requests or patches sent to tech@openbsd.org are welcome.
https://www.libressl.org
1.35k stars 269 forks source link

Remove timegm() compat #1056

Closed botovq closed 4 months ago

botovq commented 4 months ago

Now that all uses of gmtime_r() and timegm() have been converted to OPENSSL_gmtime() and OPENSSL_timegm(), this is no longer needed.

joshuasing commented 4 months ago

I think you may have already seen, however the asn1time test appears to be failing on linux/arm32. Could this log output be related?

 asn1time.c: In function ‘asn1_gentime_test’:
asn1time.c:311:27: warning: passing argument 2 of ‘OPENSSL_timegm’ from incompatible pointer type [-Wincompatible-pointer-types]
  311 |  if (!OPENSSL_timegm(&tm, &a)) {
      |                           ^~
      |                           |
      |                           int64_t * {aka long long int *}
In file included from asn1time.c:20:
../include/openssl/posix_time.h:48:49: note: expected ‘time_t *’ {aka ‘long int *’} but argument is of type ‘int64_t *’ {aka ‘long long int *’}
   48 | int OPENSSL_timegm(const struct tm *tm, time_t *out);
      |                                         ~~~~~~~~^~~
botovq commented 4 months ago

Thanks. Yes, it's part of what's wrong here, I reverted that change I made.

But there's more. The check I tried to adapt also can't fail, as all the times in asn1_gentime_tests are long before the epoch wraps, so it makes no sense in the first place...

joshuasing commented 4 months ago

Ah, okay. That's interesting. I reran the failed CI, which seems to have pulled the "Revert previous" commit from libressl/openbsd, and it has passed.

botovq commented 4 months ago

It's not ready yet, the asn1time test now again has timegm() apparently none of our CI systems are needing the compat implementation though.

botovq commented 4 months ago

@joshuasing As you can see, arm32 is completely busted once you add a test case that tickles it.

FAIL: test 3 - times don't match, expected -2147483648 got -1
UTCTIME tests...
TIME tests...
ASN1_TIME_compare tests...
20161208193400Z vs. 20380119031408Z: want 1, got -1
20161208193400Z vs. -2147483648: want -1, got 1
20161208193400Z vs. -2147483648: want -1, got 1
19700101000000Z vs. 20380119031408Z: want 1, got -1
19700101000000Z vs. -2147483648: want -1, got 1
19700101000000Z vs. -2147483648: want -1, got 1
20150923032700Z vs. 20380119031408Z: want 1, got -1
20150923032700Z vs. -2147483648: want -1, got 1
20150923032700Z vs. -2147483648: want -1, got 1
20380119031408Z vs. 20161208193400Z: want -1, got 1
...