OpenCoverage

a_utctm.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/a_utctm.c
Source codeSwitch to Preprocessed file
LineSourceCount
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#include <stdio.h>-
11#include <time.h>-
12#include "internal/cryptlib.h"-
13#include <openssl/asn1.h>-
14#include "asn1_locl.h"-
15-
16/* This is the primary function used to parse ASN1_UTCTIME */-
17int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d)-
18{-
19 /* wrapper around ans1_time_to_tm */-
20 if (d->type != V_ASN1_UTCTIME)
d->type != 23Description
TRUEnever evaluated
FALSEevaluated 144 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-144
21 return 0;
never executed: return 0;
0
22 return asn1_time_to_tm(tm, d);
executed 144 times by 1 test: return asn1_time_to_tm(tm, d);
Executed by:
  • libcrypto.so.1.1
144
23}-
24-
25int ASN1_UTCTIME_check(const ASN1_UTCTIME *d)-
26{-
27 return asn1_utctime_to_tm(NULL, d);
executed 144 times by 1 test: return asn1_utctime_to_tm( ((void *)0) , d);
Executed by:
  • libcrypto.so.1.1
144
28}-
29-
30/* Sets the string via simple copy without cleaning it up */-
31int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str)-
32{-
33 ASN1_UTCTIME t;-
34-
35 t.type = V_ASN1_UTCTIME;-
36 t.length = strlen(str);-
37 t.data = (unsigned char *)str;-
38 t.flags = 0;-
39-
40 if (!ASN1_UTCTIME_check(&t))
!ASN1_UTCTIME_check(&t)Description
TRUEevaluated 83 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 25 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
25-83
41 return 0;
executed 83 times by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
83
42-
43 if (s != NULL && !ASN1_STRING_copy(s, &t))
s != ((void *)0)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ASN1_STRING_copy(s, &t)Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-24
44 return 0;
never executed: return 0;
0
45-
46 return 1;
executed 25 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
25
47}-
48-
49ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t)-
50{-
51 return ASN1_UTCTIME_adj(s, t, 0, 0);
never executed: return ASN1_UTCTIME_adj(s, t, 0, 0);
0
52}-
53-
54ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,-
55 int offset_day, long offset_sec)-
56{-
57 struct tm *ts;-
58 struct tm data;-
59-
60 ts = OPENSSL_gmtime(&t, &data);-
61 if (ts == NULL)
ts == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
62 return NULL;
never executed: return ((void *)0) ;
0
63-
64 if (offset_day || offset_sec) {
offset_dayDescription
TRUEnever evaluated
FALSEnever evaluated
offset_secDescription
TRUEnever evaluated
FALSEnever evaluated
0
65 if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
!OPENSSL_gmtim...y, offset_sec)Description
TRUEnever evaluated
FALSEnever evaluated
0
66 return NULL;
never executed: return ((void *)0) ;
0
67 }
never executed: end of block
0
68-
69 return asn1_time_from_tm(s, ts, V_ASN1_UTCTIME);
never executed: return asn1_time_from_tm(s, ts, 23);
0
70}-
71-
72int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t)-
73{-
74 struct tm stm, ttm;-
75 int day, sec;-
76-
77 if (!asn1_utctime_to_tm(&stm, s))
!asn1_utctime_to_tm(&stm, s)Description
TRUEnever evaluated
FALSEnever evaluated
0
78 return -2;
never executed: return -2;
0
79-
80 if (OPENSSL_gmtime(&t, &ttm) == NULL)
OPENSSL_gmtime...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
81 return -2;
never executed: return -2;
0
82-
83 if (!OPENSSL_gmtime_diff(&day, &sec, &ttm, &stm))
!OPENSSL_gmtim...c, &ttm, &stm)Description
TRUEnever evaluated
FALSEnever evaluated
0
84 return -2;
never executed: return -2;
0
85-
86 if (day > 0 || sec > 0)
day > 0Description
TRUEnever evaluated
FALSEnever evaluated
sec > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
87 return 1;
never executed: return 1;
0
88 if (day < 0 || sec < 0)
day < 0Description
TRUEnever evaluated
FALSEnever evaluated
sec < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
89 return -1;
never executed: return -1;
0
90 return 0;
never executed: return 0;
0
91}-
92-
93int ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm)-
94{-
95 if (tm->type != V_ASN1_UTCTIME)
tm->type != 23Description
TRUEnever evaluated
FALSEevaluated 1949 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1949
96 return 0;
never executed: return 0;
0
97 return ASN1_TIME_print(bp, tm);
executed 1949 times by 1 test: return ASN1_TIME_print(bp, tm);
Executed by:
  • libcrypto.so.1.1
1949
98}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2