|
| 1 | +--- a/lib/x509asn1.c |
| 2 | ++++ b/lib/x509asn1.c |
| 3 | +@@ -493,12 +493,13 @@ static const char *GTime2str(const char |
| 4 | + fracl = 0; /* no fractional seconds detected so far */ |
| 5 | + if(fracp < end && (*fracp == '.' || *fracp == ',')) { |
| 6 | + /* Have fractional seconds, e.g. "[.,]\d+". How many? */ |
| 7 | +- tzp = fracp++; /* should be a digit char or BAD ARGUMENT */ |
| 8 | ++ fracp++; /* should be a digit char or BAD ARGUMENT */ |
| 9 | ++ tzp = fracp; |
| 10 | + while(tzp < end && ISDIGIT(*tzp)) |
| 11 | + tzp++; |
| 12 | + if(tzp == fracp) /* never looped, no digit after [.,] */ |
| 13 | + return CURLE_BAD_FUNCTION_ARGUMENT; |
| 14 | +- fracl = tzp - fracp - 1; /* number of fractional sec digits */ |
| 15 | ++ fracl = tzp - fracp; /* number of fractional sec digits */ |
| 16 | + DEBUGASSERT(fracl > 0); |
| 17 | + /* Strip trailing zeroes in fractional seconds. |
| 18 | + * May reduce fracl to 0 if only '0's are present. */ |
| 19 | +@@ -507,18 +508,24 @@ static const char *GTime2str(const char |
| 20 | + } |
| 21 | + |
| 22 | + /* Process timezone. */ |
| 23 | +- if(tzp >= end) |
| 24 | +- ; /* Nothing to do. */ |
| 25 | ++ if(tzp >= end) { |
| 26 | ++ tzp = ""; |
| 27 | ++ tzl = 0; |
| 28 | ++ } |
| 29 | + else if(*tzp == 'Z') { |
| 30 | +- tzp = " GMT"; |
| 31 | +- end = tzp + 4; |
| 32 | ++ sep = " "; |
| 33 | ++ tzp = "GMT"; |
| 34 | ++ tzl = 3; |
| 35 | ++ } |
| 36 | ++ else if((*tzp == '+') || (*tzp == '-')) { |
| 37 | ++ sep = " UTC"; |
| 38 | ++ tzl = end - tzp; |
| 39 | + } |
| 40 | + else { |
| 41 | + sep = " "; |
| 42 | +- tzp++; |
| 43 | ++ tzl = end - tzp; |
| 44 | + } |
| 45 | + |
| 46 | +- tzl = end - tzp; |
| 47 | + return curl_maprintf("%.4s-%.2s-%.2s %.2s:%.2s:%c%c%s%.*s%s%.*s", |
| 48 | + beg, beg + 4, beg + 6, |
| 49 | + beg + 8, beg + 10, sec1, sec2, |
| 50 | +@@ -526,6 +533,15 @@ static const char *GTime2str(const char |
| 51 | + sep, tzl, tzp); |
| 52 | + } |
| 53 | + |
| 54 | ++#ifdef UNITTESTS |
| 55 | ++/* used by unit1656.c */ |
| 56 | ++CURLcode Curl_x509_GTime2str(struct dynbuf *store, |
| 57 | ++ const char *beg, const char *end) |
| 58 | ++{ |
| 59 | ++ return GTime2str(store, beg, end); |
| 60 | ++} |
| 61 | ++#endif |
| 62 | ++ |
| 63 | + /* |
| 64 | + * Convert an ASN.1 UTC time to a printable string. |
| 65 | + * Return the dynamically allocated string, or NULL if an error occurs. |
| 66 | +--- a/lib/x509asn1.h |
| 67 | ++++ b/lib/x509asn1.h |
| 68 | +@@ -130,5 +130,16 @@ CURLcode Curl_extract_certinfo(struct co |
| 69 | + const char *beg, const char *end); |
| 70 | + CURLcode Curl_verifyhost(struct connectdata *conn, |
| 71 | + const char *beg, const char *end); |
| 72 | ++ |
| 73 | ++#ifdef UNITTESTS |
| 74 | ++#if defined(USE_GNUTLS) || defined(USE_SCHANNEL) || defined(USE_SECTRANSP) || \ |
| 75 | ++ defined(USE_MBEDTLS) |
| 76 | ++ |
| 77 | ++/* used by unit1656.c */ |
| 78 | ++CURLcode Curl_x509_GTime2str(struct dynbuf *store, |
| 79 | ++ const char *beg, const char *end); |
| 80 | ++#endif |
| 81 | ++#endif |
| 82 | ++ |
| 83 | + #endif /* USE_GSKIT or USE_NSS or USE_GNUTLS or USE_WOLFSSL or USE_SCHANNEL */ |
| 84 | + #endif /* HEADER_CURL_X509ASN1_H */ |
0 commit comments