Commit e4a1625a authored by Lev Walkin's avatar Lev Walkin

compare literal values if times are not well-formed for semantic comparison

parent 2d824a69
...@@ -766,8 +766,28 @@ GeneralizedTime_compare(const asn_TYPE_descriptor_t *td, const void *aptr, ...@@ -766,8 +766,28 @@ GeneralizedTime_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
if(a && b) { if(a && b) {
int afrac_value, afrac_digits; int afrac_value, afrac_digits;
int bfrac_value, bfrac_digits; int bfrac_value, bfrac_digits;
time_t at = asn_GT2time_frac(a, &afrac_value, &afrac_digits, 0, 0); int aerr, berr;
time_t bt = asn_GT2time_frac(b, &bfrac_value, &bfrac_digits, 0, 0); time_t at, bt;
errno = EPERM;
at = asn_GT2time_frac(a, &afrac_value, &afrac_digits, 0, 0);
aerr = errno;
errno = EPERM;
bt = asn_GT2time_frac(b, &bfrac_value, &bfrac_digits, 0, 0);
berr = errno;
if(at == -1 && aerr != EPERM) {
if(bt == -1 && berr != EPERM) {
return OCTET_STRING_compare(td, aptr, bptr);
} else {
return -1;
}
} else if(bt == -1 && berr != EPERM) {
return 1;
} else {
/* Both values are valid. */
}
if(at < bt) { if(at < bt) {
return -1; return -1;
} else if(at > bt) { } else if(at > bt) {
......
...@@ -235,8 +235,28 @@ UTCTime_compare(const asn_TYPE_descriptor_t *td, const void *aptr, ...@@ -235,8 +235,28 @@ UTCTime_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
(void)td; (void)td;
if(a && b) { if(a && b) {
time_t at = asn_UT2time(a, 0, 0); time_t at, bt;
time_t bt = asn_UT2time(b, 0, 0); int aerr, berr;
errno = EPERM;
at = asn_UT2time(a, 0, 0);
aerr = errno;
errno = EPERM;
bt = asn_UT2time(b, 0, 0);
berr = errno;
if(at == -1 && aerr != EPERM) {
if(bt == -1 && berr != EPERM) {
return OCTET_STRING_compare(td, aptr, bptr);
} else {
return -1;
}
} else if(bt == -1 && berr != EPERM) {
return 1;
} else {
/* Both values are valid. */
}
if(at < bt) { if(at < bt) {
return -1; return -1;
} else if(at > bt) { } else if(at > bt) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment