Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ossl_asn1_string_to_time_t fails on NonStop in 3.3.0 #24176

Open
rsbeckerca opened this issue Apr 18, 2024 · 6 comments
Open

ossl_asn1_string_to_time_t fails on NonStop in 3.3.0 #24176

rsbeckerca opened this issue Apr 18, 2024 · 6 comments
Labels
branch: master Merge to master branch branch: 3.3 Merge to openssl-3.3 triaged: bug The issue/pr is/fixes a bug

Comments

@rsbeckerca
Copy link
Contributor

I have encountered an issue with ossl_asn1_string_to_time_t having issues in a big-endian x86_64 situation. What I am seeing is below:

90-test_asn1_time.t .....................
        # ERROR: (time_t) 'testdateutc == asn1_to_utc[idx].expected' failed @ /home/ituglib/randall/openssl-3.3.0/test/asn1_time_test.c:439
        # [210327235959Z] compared to [210328005959Z]
        # INFO:  @ /home/ituglib/randall/openssl-3.3.0/test/asn1_time_test.c:443
        # ossl_asn1_string_to_time_t (210328005959Z) failed: expected 1616893199, got 1616889599
        #
        # OPENSSL_TEST_RAND_SEED=1713349126
        not ok 74 - iteration 1
# ------------------------------------------------------------------------------
        # ERROR: (time_t) 'testdateutc == asn1_to_utc[idx].expected' failed @ /home/ituglib/randall/openssl-3.3.0/test/asn1_time_test.c:439
        # [210328000000Z] compared to [210328010000Z]
        # INFO:  @ /home/ituglib/randall/openssl-3.3.0/test/asn1_time_test.c:443
        # ossl_asn1_string_to_time_t (210328010000Z) failed: expected 1616893200, got 1616889600
        #
        # OPENSSL_TEST_RAND_SEED=1713349126
        not ok 75 - iteration 2
# ------------------------------------------------------------------------------
        # ERROR: (time_t) 'testdateutc == asn1_to_utc[idx].expected' failed @ /home/ituglib/randall/openssl-3.3.0/test/asn1_time_test.c:439
        # [210327235959Z] compared to [210328005959Z]
        # INFO:  @ /home/ituglib/randall/openssl-3.3.0/test/asn1_time_test.c:443
        # ossl_asn1_string_to_time_t (20210328015959+0100) failed: expected 1616893199, got 1616889599
        #
        # OPENSSL_TEST_RAND_SEED=1713349126
        not ok 76 - iteration 3
# ------------------------------------------------------------------------------
        # ERROR: (time_t) 'testdateutc == asn1_to_utc[idx].expected' failed @ /home/ituglib/randall/openssl-3.3.0/test/asn1_time_test.c:439
        # [210328000000Z] compared to [210328010000Z]
        # INFO:  @ /home/ituglib/randall/openssl-3.3.0/test/asn1_time_test.c:443
        # ossl_asn1_string_to_time_t (20210328030000+0200) failed: expected 1616893200, got 1616889600
        #
        # OPENSSL_TEST_RAND_SEED=1713349126
        not ok 77 - iteration 4
# ------------------------------------------------------------------------------
    # OPENSSL_TEST_RAND_SEED=1713349126
    not ok 7 - convert_asn1_to_time_t
# ------------------------------------------------------------------------------
../../util/wrap.pl ../../test/asn1_time_test => 255
not ok 1 - running asn1_time_test
@rsbeckerca rsbeckerca added the issue: bug report The issue was opened to report a bug label Apr 18, 2024
@paulidale paulidale added triaged: bug The issue/pr is/fixes a bug branch: 3.3 Merge to openssl-3.3 and removed issue: bug report The issue was opened to report a bug labels Apr 18, 2024
@t8m t8m added the branch: master Merge to master branch label Apr 18, 2024
@t8m
Copy link
Member

t8m commented Apr 18, 2024

AFAIK we do not see the issue on linux big endian cross-compiled targets so this is most probably something NonStop specific.

@rsbeckerca
Copy link
Contributor Author

AFAIK we do not see the issue on linux big endian cross-compiled targets so this is most probably something NonStop specific.

The difference is exactly 1 hour. This looks like a timezone problem. I am checking whether this is a system setup problem or exists across multiple boxes in different timezones.

@rsbeckerca
Copy link
Contributor Author

rsbeckerca commented Apr 19, 2024

This is not a valid assumption (although unrelated to the case):

#if ((ULONG_MAX >> 31) >> 31) >= 1

time_t can be 32 bits on some platforms. We have a specific need to support 32-bit builds. Has OpenSSL specifically stated no 32-bit time_t support?

@rsbeckerca
Copy link
Contributor Author

If I set export TZ=MDT the test passes. I suspect the time configuration on the test box I am using may be wrong.

@levitte
Copy link
Member

levitte commented Apr 19, 2024

This is not a valid assumption (although unrelated to the case):

#if ((ULONG_MAX >> 31) >> 31) >= 1

time_t can be 32 bits on some platforms. We have a specific need to support 32-bit builds. Has OpenSSL specifically stated no 32-bit time_t support?

That's in this section of code, in a different test than the one failing:

/*
* this test is here to exercise ossl_asn1_time_from_tm
* with an integer year close to INT_MAX.
*/
static int convert_tm_to_asn1_time(void)
{
/* we need 64 bit time_t */
#if ((ULONG_MAX >> 31) >> 31) >= 1
time_t t;
ASN1_TIME *at;
if (sizeof(time_t) * CHAR_BIT >= 64) {
t = 67768011791126057ULL;
at = ASN1_TIME_set(NULL, t);
/*
* If ASN1_TIME_set returns NULL, it means it could not handle the input
* which is fine for this edge case.
*/
ASN1_STRING_free(at);
}
#endif
return 1;
}

The failing test is this function, which doesn't have the 64-bit requirement as far as I can see:

static int convert_asn1_to_time_t(int idx)
{
time_t testdateutc;
testdateutc = ossl_asn1_string_to_time_t(asn1_to_utc[idx].input);
if (!TEST_time_t_eq(testdateutc, asn1_to_utc[idx].expected)) {
TEST_info("ossl_asn1_string_to_time_t (%s) failed: expected %lli, got %lli\n",
asn1_to_utc[idx].input,
(long long int)asn1_to_utc[idx].expected,
(long long int)testdateutc);
return 0;
}
return 1;
}

If I set export TZ=MDT the test passes. I suspect the time configuration on the test box I am using may be wrong.

That starts to seem likely. Does the command date (if you have that command) give you a clue?

@rsbeckerca
Copy link
Contributor Author

I am waiting on the person who configured the system to get back to me with DST table information. The system is only 2 days old, so there are likely issues. Will report back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch: master Merge to master branch branch: 3.3 Merge to openssl-3.3 triaged: bug The issue/pr is/fixes a bug
Projects
None yet
Development

No branches or pull requests

4 participants