Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/objects/obj_lib.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 | #include <stdio.h> | - | ||||||||||||
11 | #include "internal/cryptlib.h" | - | ||||||||||||
12 | #include <openssl/objects.h> | - | ||||||||||||
13 | #include <openssl/buffer.h> | - | ||||||||||||
14 | #include "internal/asn1_int.h" | - | ||||||||||||
15 | - | |||||||||||||
16 | ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o) | - | ||||||||||||
17 | { | - | ||||||||||||
18 | ASN1_OBJECT *r; | - | ||||||||||||
19 | - | |||||||||||||
20 | if (o == NULL)
| 0-121542 | ||||||||||||
21 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
22 | /* If object isn't dynamic it's an internal OID which is never freed */ | - | ||||||||||||
23 | if (!(o->flags & ASN1_OBJECT_FLAG_DYNAMIC))
| 52857-68685 | ||||||||||||
24 | return (ASN1_OBJECT *)o; executed 68685 times by 1 test: return (ASN1_OBJECT *)o; Executed by:
| 68685 | ||||||||||||
25 | - | |||||||||||||
26 | r = ASN1_OBJECT_new(); | - | ||||||||||||
27 | if (r == NULL) {
| 0-52857 | ||||||||||||
28 | OBJerr(OBJ_F_OBJ_DUP, ERR_R_ASN1_LIB); | - | ||||||||||||
29 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
30 | } | - | ||||||||||||
31 | - | |||||||||||||
32 | /* Set dynamic flags so everything gets freed up on error */ | - | ||||||||||||
33 | - | |||||||||||||
34 | r->flags = o->flags | (ASN1_OBJECT_FLAG_DYNAMIC | | - | ||||||||||||
35 | ASN1_OBJECT_FLAG_DYNAMIC_STRINGS | | - | ||||||||||||
36 | ASN1_OBJECT_FLAG_DYNAMIC_DATA); | - | ||||||||||||
37 | - | |||||||||||||
38 | if (o->length > 0 && (r->data = OPENSSL_memdup(o->data, o->length)) == NULL)
| 0-52857 | ||||||||||||
39 | goto err; never executed: goto err; | 0 | ||||||||||||
40 | - | |||||||||||||
41 | r->length = o->length; | - | ||||||||||||
42 | r->nid = o->nid; | - | ||||||||||||
43 | - | |||||||||||||
44 | if (o->ln != NULL && (r->ln = OPENSSL_strdup(o->ln)) == NULL)
| 0-52762 | ||||||||||||
45 | goto err; never executed: goto err; | 0 | ||||||||||||
46 | - | |||||||||||||
47 | if (o->sn != NULL && (r->sn = OPENSSL_strdup(o->sn)) == NULL)
| 0-52762 | ||||||||||||
48 | goto err; never executed: goto err; | 0 | ||||||||||||
49 | - | |||||||||||||
50 | return r; executed 52857 times by 1 test: return r; Executed by:
| 52857 | ||||||||||||
51 | err: | - | ||||||||||||
52 | ASN1_OBJECT_free(r); | - | ||||||||||||
53 | OBJerr(OBJ_F_OBJ_DUP, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
54 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
55 | } | - | ||||||||||||
56 | - | |||||||||||||
57 | int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b) | - | ||||||||||||
58 | { | - | ||||||||||||
59 | int ret; | - | ||||||||||||
60 | - | |||||||||||||
61 | ret = (a->length - b->length); | - | ||||||||||||
62 | if (ret)
| 54687-56802 | ||||||||||||
63 | return ret; executed 54687 times by 1 test: return ret; Executed by:
| 54687 | ||||||||||||
64 | return memcmp(a->data, b->data, a->length); executed 56802 times by 1 test: return memcmp(a->data, b->data, a->length); Executed by:
| 56802 | ||||||||||||
65 | } | - | ||||||||||||
Source code | Switch to Preprocessed file |