Skip to content
This repository has been archived by the owner on Oct 16, 2021. It is now read-only.

Commit

Permalink
Fix x509_cmp_time digits check for z/OS
Browse files Browse the repository at this point in the history
x509_cmp_time uses the isDigit function from ctypes to validate
the time.  On zOS, this does an EBCDIC test, while the strings
when compiled in Node are treated as ASCII.  Convert the conditional
to an explicit test for the ASCII digit range.

Fix encoding format for generalizedtime_length as well.

Signed-off-by: Joran Siu <joransiu@ca.ibm.com>
  • Loading branch information
joransiu committed Oct 3, 2018
1 parent cafb2ba commit 10bb1e4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions deps/openssl/openssl/crypto/x509/x509_vfy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,7 @@ int X509_cmp_current_time(const ASN1_TIME *ctm)
int X509_cmp_time(const ASN1_TIME *ctm, time_t *cmp_time)
{
static const size_t utctime_length = sizeof("\x59\x59\x4d\x4d\x44\x44\x48\x48\x4d\x4d\x53\x53\x5a") - 1;
static const size_t generalizedtime_length = sizeof("\x59\x59\x4d\x4d\x44\x44\x48\x48\x4d\x4d\x53\x53\x5a") - 1;
static const size_t generalizedtime_length = sizeof("\x59\x59\x59\x59\x4d\x4d\x44\x44\x48\x48\x4d\x4d\x53\x53\x5a") - 1;
ASN1_TIME *asn1_cmp_time = NULL;
int i, day, sec, ret = 0;

Expand Down Expand Up @@ -1973,7 +1973,11 @@ int X509_cmp_time(const ASN1_TIME *ctm, time_t *cmp_time)
* Digit and date ranges will be verified in the conversion methods.
*/
for (i = 0; i < ctm->length - 1; i++) {
if (!isdigit(ctm->data[i]))
// Customize the following conditional with explicit ASCII test
// for valid digits 0-9 (0x30-0x39 in ASCII) for z/OS
// Originally:
// if (!isdigit(ctm->data[i]))
if (ctm->data[i] < 0x30 || ctm->data[i] > 0x39)
return 0;
}
if (ctm->data[ctm->length - 1] != '\x5a')
Expand Down

0 comments on commit 10bb1e4

Please sign in to comment.