| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/a_gentm.c |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /* | - | ||||||||||||
| 2 | * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. | - | ||||||||||||
| 3 | * | - | ||||||||||||
| 4 | * Licensed under the OpenSSL license (the "License"). You may not use | - | ||||||||||||
| 5 | * this file except in compliance with the License. You can obtain a copy | - | ||||||||||||
| 6 | * in the file LICENSE in the source distribution or at | - | ||||||||||||
| 7 | * https://www.openssl.org/source/license.html | - | ||||||||||||
| 8 | */ | - | ||||||||||||
| 9 | - | |||||||||||||
| 10 | /* | - | ||||||||||||
| 11 | * GENERALIZEDTIME implementation. Based on UTCTIME | - | ||||||||||||
| 12 | */ | - | ||||||||||||
| 13 | - | |||||||||||||
| 14 | #include <stdio.h> | - | ||||||||||||
| 15 | #include <time.h> | - | ||||||||||||
| 16 | #include "internal/cryptlib.h" | - | ||||||||||||
| 17 | #include <openssl/asn1.h> | - | ||||||||||||
| 18 | #include "asn1_locl.h" | - | ||||||||||||
| 19 | - | |||||||||||||
| 20 | /* This is the primary function used to parse ASN1_GENERALIZEDTIME */ | - | ||||||||||||
| 21 | int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d) | - | ||||||||||||
| 22 | { | - | ||||||||||||
| 23 | /* wrapper around asn1_time_to_tm */ | - | ||||||||||||
| 24 | if (d->type != V_ASN1_GENERALIZEDTIME)
| 0-2477 | ||||||||||||
| 25 | return 0; never executed: return 0; | 0 | ||||||||||||
| 26 | return asn1_time_to_tm(tm, d); executed 2477 times by 1 test: return asn1_time_to_tm(tm, d);Executed by:
| 2477 | ||||||||||||
| 27 | } | - | ||||||||||||
| 28 | - | |||||||||||||
| 29 | int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *d) | - | ||||||||||||
| 30 | { | - | ||||||||||||
| 31 | return asn1_generalizedtime_to_tm(NULL, d); executed 2477 times by 1 test: return asn1_generalizedtime_to_tm( ((void *)0) , d);Executed by:
| 2477 | ||||||||||||
| 32 | } | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str) | - | ||||||||||||
| 35 | { | - | ||||||||||||
| 36 | ASN1_GENERALIZEDTIME t; | - | ||||||||||||
| 37 | - | |||||||||||||
| 38 | t.type = V_ASN1_GENERALIZEDTIME; | - | ||||||||||||
| 39 | t.length = strlen(str); | - | ||||||||||||
| 40 | t.data = (unsigned char *)str; | - | ||||||||||||
| 41 | t.flags = 0; | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | if (!ASN1_GENERALIZEDTIME_check(&t))
| 534-1887 | ||||||||||||
| 44 | return 0; executed 534 times by 1 test: return 0;Executed by:
| 534 | ||||||||||||
| 45 | - | |||||||||||||
| 46 | if (s != NULL && !ASN1_STRING_copy(s, &t))
| 0-1887 | ||||||||||||
| 47 | return 0; never executed: return 0; | 0 | ||||||||||||
| 48 | - | |||||||||||||
| 49 | return 1; executed 1887 times by 1 test: return 1;Executed by:
| 1887 | ||||||||||||
| 50 | } | - | ||||||||||||
| 51 | - | |||||||||||||
| 52 | ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, | - | ||||||||||||
| 53 | time_t t) | - | ||||||||||||
| 54 | { | - | ||||||||||||
| 55 | return ASN1_GENERALIZEDTIME_adj(s, t, 0, 0); never executed: return ASN1_GENERALIZEDTIME_adj(s, t, 0, 0); | 0 | ||||||||||||
| 56 | } | - | ||||||||||||
| 57 | - | |||||||||||||
| 58 | ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, | - | ||||||||||||
| 59 | time_t t, int offset_day, | - | ||||||||||||
| 60 | long offset_sec) | - | ||||||||||||
| 61 | { | - | ||||||||||||
| 62 | struct tm *ts; | - | ||||||||||||
| 63 | struct tm data; | - | ||||||||||||
| 64 | - | |||||||||||||
| 65 | ts = OPENSSL_gmtime(&t, &data); | - | ||||||||||||
| 66 | if (ts == NULL)
| 0-2340 | ||||||||||||
| 67 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 68 | - | |||||||||||||
| 69 | if (offset_day || offset_sec) {
| 257-1541 | ||||||||||||
| 70 | if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
| 534-1549 | ||||||||||||
| 71 | return NULL; executed 534 times by 1 test: return ((void *)0) ;Executed by:
| 534 | ||||||||||||
| 72 | } executed 1549 times by 1 test: end of blockExecuted by:
| 1549 | ||||||||||||
| 73 | - | |||||||||||||
| 74 | return asn1_time_from_tm(s, ts, V_ASN1_GENERALIZEDTIME); executed 1806 times by 1 test: return asn1_time_from_tm(s, ts, 24);Executed by:
| 1806 | ||||||||||||
| 75 | } | - | ||||||||||||
| 76 | - | |||||||||||||
| 77 | int ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm) | - | ||||||||||||
| 78 | { | - | ||||||||||||
| 79 | if (tm->type != V_ASN1_GENERALIZEDTIME)
| 0-9486 | ||||||||||||
| 80 | return 0; never executed: return 0; | 0 | ||||||||||||
| 81 | return ASN1_TIME_print(bp, tm); executed 9486 times by 1 test: return ASN1_TIME_print(bp, tm);Executed by:
| 9486 | ||||||||||||
| 82 | } | - | ||||||||||||
| Source code | Switch to Preprocessed file |