| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/asn1/bio_ndef.c | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | typedef struct ndef_aux_st { | - | ||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | ASN1_VALUE *val; | - | ||||||||||||||||||
| 5 | const ASN1_ITEM *it; | - | ||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | BIO *ndef_bio; | - | ||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | BIO *out; | - | ||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | unsigned char **boundary; | - | ||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | unsigned char *derbuf; | - | ||||||||||||||||||
| 14 | } NDEF_SUPPORT; | - | ||||||||||||||||||
| 15 | - | |||||||||||||||||||
| 16 | static int ndef_prefix(BIO *b, unsigned char **pbuf, int *plen, void *parg); | - | ||||||||||||||||||
| 17 | static int ndef_prefix_free(BIO *b, unsigned char **pbuf, int *plen, void *parg); | - | ||||||||||||||||||
| 18 | static int ndef_suffix(BIO *b, unsigned char **pbuf, int *plen, void *parg); | - | ||||||||||||||||||
| 19 | static int ndef_suffix_free(BIO *b, unsigned char **pbuf, int *plen, void *parg); | - | ||||||||||||||||||
| 20 | - | |||||||||||||||||||
| 21 | BIO * | - | ||||||||||||||||||
| 22 | BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it) | - | ||||||||||||||||||
| 23 | { | - | ||||||||||||||||||
| 24 | NDEF_SUPPORT *ndef_aux = | - | ||||||||||||||||||
| 25 | ((void *)0) | - | ||||||||||||||||||
| 26 | ; | - | ||||||||||||||||||
| 27 | BIO *asn_bio = | - | ||||||||||||||||||
| 28 | ((void *)0) | - | ||||||||||||||||||
| 29 | ; | - | ||||||||||||||||||
| 30 | const ASN1_AUX *aux = it->funcs; | - | ||||||||||||||||||
| 31 | ASN1_STREAM_ARG sarg; | - | ||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | if (!aux 
 
 | 0 | ||||||||||||||||||
| 34 | ERR_put_error(13,(0xfff),(202),__FILE__,109); | - | ||||||||||||||||||
| 35 | return never executed:  return ((void *)0) ;never executed:  return ((void *)0) ; | 0 | ||||||||||||||||||
| 36 | ((void *)0) never executed:  return ((void *)0) ; | 0 | ||||||||||||||||||
| 37 | ; never executed:  return ((void *)0) ; | 0 | ||||||||||||||||||
| 38 | } | - | ||||||||||||||||||
| 39 | ndef_aux = malloc(sizeof(NDEF_SUPPORT)); | - | ||||||||||||||||||
| 40 | asn_bio = BIO_new(BIO_f_asn1()); | - | ||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | - | |||||||||||||||||||
| 44 | out = BIO_push(asn_bio, out); | - | ||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | if (!ndef_aux 
 
 
 | 0 | ||||||||||||||||||
| 47 | goto never executed: err; goto err;never executed:  goto err; | 0 | ||||||||||||||||||
| 48 | - | |||||||||||||||||||
| 49 | BIO_asn1_set_prefix(asn_bio, ndef_prefix, ndef_prefix_free); | - | ||||||||||||||||||
| 50 | BIO_asn1_set_suffix(asn_bio, ndef_suffix, ndef_suffix_free); | - | ||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | sarg.out = out; | - | ||||||||||||||||||
| 57 | sarg.ndef_bio = | - | ||||||||||||||||||
| 58 | ((void *)0) | - | ||||||||||||||||||
| 59 | ; | - | ||||||||||||||||||
| 60 | sarg.boundary = | - | ||||||||||||||||||
| 61 | ((void *)0) | - | ||||||||||||||||||
| 62 | ; | - | ||||||||||||||||||
| 63 | - | |||||||||||||||||||
| 64 | if (aux->asn1_cb(10, &val, it, &sarg) <= 0 
 | 0 | ||||||||||||||||||
| 65 | goto never executed: err; goto err;never executed:  goto err; | 0 | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | ndef_aux->val = val; | - | ||||||||||||||||||
| 68 | ndef_aux->it = it; | - | ||||||||||||||||||
| 69 | ndef_aux->ndef_bio = sarg.ndef_bio; | - | ||||||||||||||||||
| 70 | ndef_aux->boundary = sarg.boundary; | - | ||||||||||||||||||
| 71 | ndef_aux->out = out; | - | ||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | BIO_ctrl(asn_bio, 153, 0, ndef_aux); | - | ||||||||||||||||||
| 74 | - | |||||||||||||||||||
| 75 | return never executed: sarg.ndef_bio; return sarg.ndef_bio;never executed:  return sarg.ndef_bio; | 0 | ||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | err: | - | ||||||||||||||||||
| 78 | BIO_free(asn_bio); | - | ||||||||||||||||||
| 79 | free(ndef_aux); | - | ||||||||||||||||||
| 80 | return never executed:  return ((void *)0) ;never executed:  return ((void *)0) ; | 0 | ||||||||||||||||||
| 81 | ((void *)0) never executed:  return ((void *)0) ; | 0 | ||||||||||||||||||
| 82 | ; never executed:  return ((void *)0) ; | 0 | ||||||||||||||||||
| 83 | } | - | ||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | static int | - | ||||||||||||||||||
| 86 | ndef_prefix(BIO *b, unsigned char **pbuf, int *plen, void *parg) | - | ||||||||||||||||||
| 87 | { | - | ||||||||||||||||||
| 88 | NDEF_SUPPORT *ndef_aux; | - | ||||||||||||||||||
| 89 | unsigned char *p; | - | ||||||||||||||||||
| 90 | int derlen; | - | ||||||||||||||||||
| 91 | - | |||||||||||||||||||
| 92 | if (!parg 
 | 0 | ||||||||||||||||||
| 93 | return never executed: 0; return 0;never executed:  return 0; | 0 | ||||||||||||||||||
| 94 | - | |||||||||||||||||||
| 95 | ndef_aux = *(NDEF_SUPPORT **)parg; | - | ||||||||||||||||||
| 96 | - | |||||||||||||||||||
| 97 | derlen = ASN1_item_ndef_i2d(ndef_aux->val, | - | ||||||||||||||||||
| 98 | ((void *)0) | - | ||||||||||||||||||
| 99 | , ndef_aux->it); | - | ||||||||||||||||||
| 100 | p = malloc(derlen); | - | ||||||||||||||||||
| 101 | ndef_aux->derbuf = p; | - | ||||||||||||||||||
| 102 | *pbuf = p; | - | ||||||||||||||||||
| 103 | derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it); | - | ||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | if (!*ndef_aux->boundary 
 | 0 | ||||||||||||||||||
| 106 | return never executed: 0; return 0;never executed:  return 0; | 0 | ||||||||||||||||||
| 107 | - | |||||||||||||||||||
| 108 | *plen = *ndef_aux->boundary - *pbuf; | - | ||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | return never executed: 1; return 1;never executed:  return 1; | 0 | ||||||||||||||||||
| 111 | } | - | ||||||||||||||||||
| 112 | - | |||||||||||||||||||
| 113 | static int | - | ||||||||||||||||||
| 114 | ndef_prefix_free(BIO *b, unsigned char **pbuf, int *plen, void *parg) | - | ||||||||||||||||||
| 115 | { | - | ||||||||||||||||||
| 116 | NDEF_SUPPORT *ndef_aux; | - | ||||||||||||||||||
| 117 | - | |||||||||||||||||||
| 118 | if (!parg 
 | 0 | ||||||||||||||||||
| 119 | return never executed: 0; return 0;never executed:  return 0; | 0 | ||||||||||||||||||
| 120 | - | |||||||||||||||||||
| 121 | ndef_aux = *(NDEF_SUPPORT **)parg; | - | ||||||||||||||||||
| 122 | - | |||||||||||||||||||
| 123 | free(ndef_aux->derbuf); | - | ||||||||||||||||||
| 124 | - | |||||||||||||||||||
| 125 | ndef_aux->derbuf = | - | ||||||||||||||||||
| 126 | ((void *)0) | - | ||||||||||||||||||
| 127 | ; | - | ||||||||||||||||||
| 128 | *pbuf = | - | ||||||||||||||||||
| 129 | ((void *)0) | - | ||||||||||||||||||
| 130 | ; | - | ||||||||||||||||||
| 131 | *plen = 0; | - | ||||||||||||||||||
| 132 | return never executed: 1; return 1;never executed:  return 1; | 0 | ||||||||||||||||||
| 133 | } | - | ||||||||||||||||||
| 134 | - | |||||||||||||||||||
| 135 | static int | - | ||||||||||||||||||
| 136 | ndef_suffix_free(BIO *b, unsigned char **pbuf, int *plen, void *parg) | - | ||||||||||||||||||
| 137 | { | - | ||||||||||||||||||
| 138 | NDEF_SUPPORT **pndef_aux = (NDEF_SUPPORT **)parg; | - | ||||||||||||||||||
| 139 | if (!ndef_prefix_free(b, pbuf, plen, parg) 
 | 0 | ||||||||||||||||||
| 140 | return never executed: 0; return 0;never executed:  return 0; | 0 | ||||||||||||||||||
| 141 | free(*pndef_aux); | - | ||||||||||||||||||
| 142 | *pndef_aux = | - | ||||||||||||||||||
| 143 | ((void *)0) | - | ||||||||||||||||||
| 144 | ; | - | ||||||||||||||||||
| 145 | return never executed: 1; return 1;never executed:  return 1; | 0 | ||||||||||||||||||
| 146 | } | - | ||||||||||||||||||
| 147 | - | |||||||||||||||||||
| 148 | static int | - | ||||||||||||||||||
| 149 | ndef_suffix(BIO *b, unsigned char **pbuf, int *plen, void *parg) | - | ||||||||||||||||||
| 150 | { | - | ||||||||||||||||||
| 151 | NDEF_SUPPORT *ndef_aux; | - | ||||||||||||||||||
| 152 | unsigned char *p; | - | ||||||||||||||||||
| 153 | int derlen; | - | ||||||||||||||||||
| 154 | const ASN1_AUX *aux; | - | ||||||||||||||||||
| 155 | ASN1_STREAM_ARG sarg; | - | ||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | if (!parg 
 | 0 | ||||||||||||||||||
| 158 | return never executed: 0; return 0;never executed:  return 0; | 0 | ||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | ndef_aux = *(NDEF_SUPPORT **)parg; | - | ||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | aux = ndef_aux->it->funcs; | - | ||||||||||||||||||
| 163 | - | |||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | sarg.ndef_bio = ndef_aux->ndef_bio; | - | ||||||||||||||||||
| 166 | sarg.out = ndef_aux->out; | - | ||||||||||||||||||
| 167 | sarg.boundary = ndef_aux->boundary; | - | ||||||||||||||||||
| 168 | if (aux->asn1_cb(11, 
 | 0 | ||||||||||||||||||
| 169 | &ndef_aux->val, ndef_aux->it, &sarg) <= 0 
 | 0 | ||||||||||||||||||
| 170 | return never executed: 0; return 0;never executed:  return 0; | 0 | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | derlen = ASN1_item_ndef_i2d(ndef_aux->val, | - | ||||||||||||||||||
| 173 | ((void *)0) | - | ||||||||||||||||||
| 174 | , ndef_aux->it); | - | ||||||||||||||||||
| 175 | p = malloc(derlen); | - | ||||||||||||||||||
| 176 | ndef_aux->derbuf = p; | - | ||||||||||||||||||
| 177 | *pbuf = p; | - | ||||||||||||||||||
| 178 | derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it); | - | ||||||||||||||||||
| 179 | - | |||||||||||||||||||
| 180 | if (!*ndef_aux->boundary 
 | 0 | ||||||||||||||||||
| 181 | return never executed: 0; return 0;never executed:  return 0; | 0 | ||||||||||||||||||
| 182 | *pbuf = *ndef_aux->boundary; | - | ||||||||||||||||||
| 183 | *plen = derlen - (*ndef_aux->boundary - ndef_aux->derbuf); | - | ||||||||||||||||||
| 184 | - | |||||||||||||||||||
| 185 | return never executed: 1; return 1;never executed:  return 1; | 0 | ||||||||||||||||||
| 186 | } | - | ||||||||||||||||||
| Switch to Source code | Preprocessed file |