Commit ae32742e authored by Todd Short's avatar Todd Short Committed by Richard Levitte
Browse files

Fix time offset calculation.



ASN1_GENERALIZEDTIME and ASN1_UTCTIME may be specified using offsets,
even though that's not supported within certificates.

To convert the offset time back to GMT, the offsets are supposed to be
subtracted, not added. e.g. 1759-0500 == 2359+0100 == 2259Z.

Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
Reviewed-by: default avatarMatt Caswell <matt@openssl.org>
Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3335)
parent d3d51adc
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -101,7 +101,7 @@ int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d)
    if (a[o] == 'Z')
    if (a[o] == 'Z')
        o++;
        o++;
    else if ((a[o] == '+') || (a[o] == '-')) {
    else if ((a[o] == '+') || (a[o] == '-')) {
        int offsign = a[o] == '-' ? -1 : 1, offset = 0;
        int offsign = a[o] == '-' ? 1 : -1, offset = 0;
        o++;
        o++;
        if (o + 4 > l)
        if (o + 4 > l)
            goto err;
            goto err;
+1 −1
Original line number Original line Diff line number Diff line
@@ -75,7 +75,7 @@ int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d)
    if (a[o] == 'Z')
    if (a[o] == 'Z')
        o++;
        o++;
    else if ((a[o] == '+') || (a[o] == '-')) {
    else if ((a[o] == '+') || (a[o] == '-')) {
        int offsign = a[o] == '-' ? -1 : 1, offset = 0;
        int offsign = a[o] == '-' ? 1 : -1, offset = 0;
        o++;
        o++;
        if (o + 4 > l)
        if (o + 4 > l)
            goto err;
            goto err;