Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/asn_pack.c |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /* | - | ||||||||||||
2 | * Copyright 1999-2016 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/asn1.h> | - | ||||||||||||
13 | - | |||||||||||||
14 | /* ASN1 packing and unpacking functions */ | - | ||||||||||||
15 | - | |||||||||||||
16 | ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct) | - | ||||||||||||
17 | { | - | ||||||||||||
18 | ASN1_STRING *octmp; | - | ||||||||||||
19 | - | |||||||||||||
20 | if (oct == NULL || *oct == NULL) {
| 0-7 | ||||||||||||
21 | if ((octmp = ASN1_STRING_new()) == NULL) {
| 0-13 | ||||||||||||
22 | ASN1err(ASN1_F_ASN1_ITEM_PACK, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
23 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
24 | } | - | ||||||||||||
25 | } else { executed 13 times by 1 test: end of block Executed by:
| 13 | ||||||||||||
26 | octmp = *oct; | - | ||||||||||||
27 | } never executed: end of block | 0 | ||||||||||||
28 | - | |||||||||||||
29 | OPENSSL_free(octmp->data); | - | ||||||||||||
30 | octmp->data = NULL; | - | ||||||||||||
31 | - | |||||||||||||
32 | if ((octmp->length = ASN1_item_i2d(obj, &octmp->data, it)) == 0) {
| 0-13 | ||||||||||||
33 | ASN1err(ASN1_F_ASN1_ITEM_PACK, ASN1_R_ENCODE_ERROR); | - | ||||||||||||
34 | goto err; never executed: goto err; | 0 | ||||||||||||
35 | } | - | ||||||||||||
36 | if (octmp->data == NULL) {
| 0-13 | ||||||||||||
37 | ASN1err(ASN1_F_ASN1_ITEM_PACK, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
38 | goto err; never executed: goto err; | 0 | ||||||||||||
39 | } | - | ||||||||||||
40 | - | |||||||||||||
41 | if (oct != NULL && *oct == NULL)
| 0-7 | ||||||||||||
42 | *oct = octmp; executed 7 times by 1 test: *oct = octmp; Executed by:
| 7 | ||||||||||||
43 | - | |||||||||||||
44 | return octmp; executed 13 times by 1 test: return octmp; Executed by:
| 13 | ||||||||||||
45 | err: | - | ||||||||||||
46 | if (oct == NULL || *oct == NULL)
| 0 | ||||||||||||
47 | ASN1_STRING_free(octmp); never executed: ASN1_STRING_free(octmp); | 0 | ||||||||||||
48 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
49 | } | - | ||||||||||||
50 | - | |||||||||||||
51 | /* Extract an ASN1 object from an ASN1_STRING */ | - | ||||||||||||
52 | - | |||||||||||||
53 | void *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it) | - | ||||||||||||
54 | { | - | ||||||||||||
55 | const unsigned char *p; | - | ||||||||||||
56 | void *ret; | - | ||||||||||||
57 | - | |||||||||||||
58 | p = oct->data; | - | ||||||||||||
59 | if ((ret = ASN1_item_d2i(NULL, &p, oct->length, it)) == NULL)
| 124-192 | ||||||||||||
60 | ASN1err(ASN1_F_ASN1_ITEM_UNPACK, ASN1_R_DECODE_ERROR); executed 124 times by 1 test: ERR_put_error(13,(199),(110),__FILE__,60); Executed by:
| 124 | ||||||||||||
61 | return ret; executed 316 times by 1 test: return ret; Executed by:
| 316 | ||||||||||||
62 | } | - | ||||||||||||
Source code | Switch to Preprocessed file |