| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/a_d2i_fp.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||||||||
| 6 | void *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x) | - | ||||||||||||||||||||||||||||||
| 7 | { | - | ||||||||||||||||||||||||||||||
| 8 | BIO *b; | - | ||||||||||||||||||||||||||||||
| 9 | void *ret; | - | ||||||||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||||||||
| 11 | if ((
| 0 | ||||||||||||||||||||||||||||||
| 12 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||
| 13 | ) { | - | ||||||||||||||||||||||||||||||
| 14 | ERR_put_error(13,(109),(7),__FILE__,27); | - | ||||||||||||||||||||||||||||||
| 15 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||
| 16 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||
| 17 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||
| 18 | } | - | ||||||||||||||||||||||||||||||
| 19 | BIO_ctrl(b,106,0x00,(char *)(in)); | - | ||||||||||||||||||||||||||||||
| 20 | ret = ASN1_d2i_bio(xnew, d2i, b, x); | - | ||||||||||||||||||||||||||||||
| 21 | BIO_free(b); | - | ||||||||||||||||||||||||||||||
| 22 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||||||||
| 23 | } | - | ||||||||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||||||||
| 26 | void *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x) | - | ||||||||||||||||||||||||||||||
| 27 | { | - | ||||||||||||||||||||||||||||||
| 28 | BUF_MEM *b = | - | ||||||||||||||||||||||||||||||
| 29 | ((void *)0) | - | ||||||||||||||||||||||||||||||
| 30 | ; | - | ||||||||||||||||||||||||||||||
| 31 | const unsigned char *p; | - | ||||||||||||||||||||||||||||||
| 32 | void *ret = | - | ||||||||||||||||||||||||||||||
| 33 | ((void *)0) | - | ||||||||||||||||||||||||||||||
| 34 | ; | - | ||||||||||||||||||||||||||||||
| 35 | int len; | - | ||||||||||||||||||||||||||||||
| 36 | - | |||||||||||||||||||||||||||||||
| 37 | len = asn1_d2i_read_bio(in, &b); | - | ||||||||||||||||||||||||||||||
| 38 | if (len < 0
| 0-83 | ||||||||||||||||||||||||||||||
| 39 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||
| 40 | - | |||||||||||||||||||||||||||||||
| 41 | p = (unsigned char *)b->data; | - | ||||||||||||||||||||||||||||||
| 42 | ret = d2i(x, &p, len); | - | ||||||||||||||||||||||||||||||
| 43 | err: code before this statement executed 83 times by 1 test: err:Executed by:
| 83 | ||||||||||||||||||||||||||||||
| 44 | BUF_MEM_free(b); | - | ||||||||||||||||||||||||||||||
| 45 | return executed 83 times by 1 test: ret;return ret;Executed by:
executed 83 times by 1 test: return ret;Executed by:
| 83 | ||||||||||||||||||||||||||||||
| 46 | } | - | ||||||||||||||||||||||||||||||
| 47 | - | |||||||||||||||||||||||||||||||
| 48 | - | |||||||||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||||||||
| 50 | void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x) | - | ||||||||||||||||||||||||||||||
| 51 | { | - | ||||||||||||||||||||||||||||||
| 52 | BUF_MEM *b = | - | ||||||||||||||||||||||||||||||
| 53 | ((void *)0) | - | ||||||||||||||||||||||||||||||
| 54 | ; | - | ||||||||||||||||||||||||||||||
| 55 | const unsigned char *p; | - | ||||||||||||||||||||||||||||||
| 56 | void *ret = | - | ||||||||||||||||||||||||||||||
| 57 | ((void *)0) | - | ||||||||||||||||||||||||||||||
| 58 | ; | - | ||||||||||||||||||||||||||||||
| 59 | int len; | - | ||||||||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||||||||
| 61 | len = asn1_d2i_read_bio(in, &b); | - | ||||||||||||||||||||||||||||||
| 62 | if (len < 0
| 14-1457 | ||||||||||||||||||||||||||||||
| 63 | goto executed 14 times by 1 test: err;goto err;Executed by:
executed 14 times by 1 test: goto err;Executed by:
| 14 | ||||||||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||||||||
| 65 | p = (const unsigned char *)b->data; | - | ||||||||||||||||||||||||||||||
| 66 | ret = ASN1_item_d2i(x, &p, len, it); | - | ||||||||||||||||||||||||||||||
| 67 | err: code before this statement executed 1457 times by 1 test: err:Executed by:
| 1457 | ||||||||||||||||||||||||||||||
| 68 | BUF_MEM_free(b); | - | ||||||||||||||||||||||||||||||
| 69 | return executed 1471 times by 1 test: ret;return ret;Executed by:
executed 1471 times by 1 test: return ret;Executed by:
| 1471 | ||||||||||||||||||||||||||||||
| 70 | } | - | ||||||||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||||||||
| 73 | void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x) | - | ||||||||||||||||||||||||||||||
| 74 | { | - | ||||||||||||||||||||||||||||||
| 75 | BIO *b; | - | ||||||||||||||||||||||||||||||
| 76 | char *ret; | - | ||||||||||||||||||||||||||||||
| 77 | - | |||||||||||||||||||||||||||||||
| 78 | if ((
| 0 | ||||||||||||||||||||||||||||||
| 79 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||
| 80 | ) { | - | ||||||||||||||||||||||||||||||
| 81 | ERR_put_error(13,(206),(7),__FILE__,82); | - | ||||||||||||||||||||||||||||||
| 82 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||
| 83 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||
| 84 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||
| 85 | } | - | ||||||||||||||||||||||||||||||
| 86 | BIO_ctrl(b,106,0x00,(char *)(in)); | - | ||||||||||||||||||||||||||||||
| 87 | ret = ASN1_item_d2i_bio(it, b, x); | - | ||||||||||||||||||||||||||||||
| 88 | BIO_free(b); | - | ||||||||||||||||||||||||||||||
| 89 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||||||||
| 90 | } | - | ||||||||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||||||||
| 92 | - | |||||||||||||||||||||||||||||||
| 93 | - | |||||||||||||||||||||||||||||||
| 94 | - | |||||||||||||||||||||||||||||||
| 95 | int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb) | - | ||||||||||||||||||||||||||||||
| 96 | { | - | ||||||||||||||||||||||||||||||
| 97 | BUF_MEM *b; | - | ||||||||||||||||||||||||||||||
| 98 | unsigned char *p; | - | ||||||||||||||||||||||||||||||
| 99 | int i; | - | ||||||||||||||||||||||||||||||
| 100 | size_t want = 8; | - | ||||||||||||||||||||||||||||||
| 101 | uint32_t eos = 0; | - | ||||||||||||||||||||||||||||||
| 102 | size_t off = 0; | - | ||||||||||||||||||||||||||||||
| 103 | size_t len = 0; | - | ||||||||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||||||||
| 105 | const unsigned char *q; | - | ||||||||||||||||||||||||||||||
| 106 | long slen; | - | ||||||||||||||||||||||||||||||
| 107 | int inf, tag, xclass; | - | ||||||||||||||||||||||||||||||
| 108 | - | |||||||||||||||||||||||||||||||
| 109 | b = BUF_MEM_new(); | - | ||||||||||||||||||||||||||||||
| 110 | if (b ==
| 0-1554 | ||||||||||||||||||||||||||||||
| 111 | ((void *)0)
| 0-1554 | ||||||||||||||||||||||||||||||
| 112 | ) { | - | ||||||||||||||||||||||||||||||
| 113 | ERR_put_error(13,(107),((1|64)),__FILE__,110); | - | ||||||||||||||||||||||||||||||
| 114 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 115 | } | - | ||||||||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||||||||
| 117 | ERR_clear_error(); | - | ||||||||||||||||||||||||||||||
| 118 | for (;;) { | - | ||||||||||||||||||||||||||||||
| 119 | if (want >= (len - off)
| 0-543238 | ||||||||||||||||||||||||||||||
| 120 | want -= (len - off); | - | ||||||||||||||||||||||||||||||
| 121 | - | |||||||||||||||||||||||||||||||
| 122 | if (len + want < len
| 0-543238 | ||||||||||||||||||||||||||||||
| 123 | ERR_put_error(13,(107),((1|64)),__FILE__,120); | - | ||||||||||||||||||||||||||||||
| 124 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||
| 125 | } | - | ||||||||||||||||||||||||||||||
| 126 | i = BIO_read(in, &(b->data[len]), want); | - | ||||||||||||||||||||||||||||||
| 127 | if ((
| 2-540683 | ||||||||||||||||||||||||||||||
| 128 | ERR_put_error(13,(107),(142),__FILE__,125); | - | ||||||||||||||||||||||||||||||
| 129 | goto executed 2 times by 1 test: err;goto err;Executed by:
executed 2 times by 1 test: goto err;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 130 | } | - | ||||||||||||||||||||||||||||||
| 131 | if (i > 0
| 2648-540588 | ||||||||||||||||||||||||||||||
| 132 | if (len + i < len
| 0-540588 | ||||||||||||||||||||||||||||||
| 133 | ERR_put_error(13,(107),(155),__FILE__,130); | - | ||||||||||||||||||||||||||||||
| 134 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||
| 135 | } | - | ||||||||||||||||||||||||||||||
| 136 | len += i; | - | ||||||||||||||||||||||||||||||
| 137 | } executed 540588 times by 1 test: end of blockExecuted by:
| 540588 | ||||||||||||||||||||||||||||||
| 138 | } executed 543236 times by 1 test: end of blockExecuted by:
| 543236 | ||||||||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||||||||
| 140 | - | |||||||||||||||||||||||||||||||
| 141 | p = (unsigned char *)&(b->data[off]); | - | ||||||||||||||||||||||||||||||
| 142 | q = p; | - | ||||||||||||||||||||||||||||||
| 143 | inf = ASN1_get_object(&q, &slen, &tag, &xclass, len - off); | - | ||||||||||||||||||||||||||||||
| 144 | if (inf & 0x80
| 34285-508951 | ||||||||||||||||||||||||||||||
| 145 | unsigned long e; | - | ||||||||||||||||||||||||||||||
| 146 | - | |||||||||||||||||||||||||||||||
| 147 | e = (int)( (ERR_peek_error()) & 0xFFFL); | - | ||||||||||||||||||||||||||||||
| 148 | if (e != 155
| 1-34284 | ||||||||||||||||||||||||||||||
| 149 | goto executed 1 time by 1 test: err;goto err;Executed by:
executed 1 time by 1 test: goto err;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 150 | else | - | ||||||||||||||||||||||||||||||
| 151 | ERR_clear_error(); executed 34284 times by 1 test: ERR_clear_error();Executed by:
| 34284 | ||||||||||||||||||||||||||||||
| 152 | } | - | ||||||||||||||||||||||||||||||
| 153 | i = q - p; | - | ||||||||||||||||||||||||||||||
| 154 | off += i; | - | ||||||||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||||||||
| 156 | if (inf & 1
| 159127-384108 | ||||||||||||||||||||||||||||||
| 157 | - | |||||||||||||||||||||||||||||||
| 158 | if (eos ==
| 0-159127 | ||||||||||||||||||||||||||||||
| 159 | (4294967295U)
| 0-159127 | ||||||||||||||||||||||||||||||
| 160 | ) { | - | ||||||||||||||||||||||||||||||
| 161 | ERR_put_error(13,(107),(123),__FILE__,156); | - | ||||||||||||||||||||||||||||||
| 162 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||
| 163 | } | - | ||||||||||||||||||||||||||||||
| 164 | eos++; | - | ||||||||||||||||||||||||||||||
| 165 | want = 8; | - | ||||||||||||||||||||||||||||||
| 166 | } executed 159127 times by 1 test: else if (eosend of blockExecuted by:
| 360-383748 | ||||||||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||||||||
| 168 | eos--; | - | ||||||||||||||||||||||||||||||
| 169 | if (eos == 0
| 1186-157924 | ||||||||||||||||||||||||||||||
| 170 | break; executed 1186 times by 1 test: break;Executed by:
| 1186 | ||||||||||||||||||||||||||||||
| 171 | else | - | ||||||||||||||||||||||||||||||
| 172 | want = 8; executed 157924 times by 1 test: want = 8;Executed by:
| 157924 | ||||||||||||||||||||||||||||||
| 173 | } else { | - | ||||||||||||||||||||||||||||||
| 174 | - | |||||||||||||||||||||||||||||||
| 175 | want = slen; | - | ||||||||||||||||||||||||||||||
| 176 | if (want > (len - off)
| 34284-190714 | ||||||||||||||||||||||||||||||
| 177 | size_t chunk_max = (16 * 1024); | - | ||||||||||||||||||||||||||||||
| 178 | - | |||||||||||||||||||||||||||||||
| 179 | want -= (len - off); | - | ||||||||||||||||||||||||||||||
| 180 | if (want > 0x7fffffff
| 1-34283 | ||||||||||||||||||||||||||||||
| 181 | len + want < len
| 0-34283 | ||||||||||||||||||||||||||||||
| 182 | ERR_put_error(13,(107),(155),__FILE__,177); | - | ||||||||||||||||||||||||||||||
| 183 | goto executed 1 time by 1 test: err;goto err;Executed by:
executed 1 time by 1 test: goto err;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 184 | } | - | ||||||||||||||||||||||||||||||
| 185 | while (want > 0
| 34273-34289 | ||||||||||||||||||||||||||||||
| 186 | - | |||||||||||||||||||||||||||||||
| 187 | - | |||||||||||||||||||||||||||||||
| 188 | - | |||||||||||||||||||||||||||||||
| 189 | - | |||||||||||||||||||||||||||||||
| 190 | - | |||||||||||||||||||||||||||||||
| 191 | - | |||||||||||||||||||||||||||||||
| 192 | size_t chunk = want > chunk_max
| 11-34278 | ||||||||||||||||||||||||||||||
| 193 | - | |||||||||||||||||||||||||||||||
| 194 | if (!BUF_MEM_grow_clean(b, len + chunk)
| 0-34289 | ||||||||||||||||||||||||||||||
| 195 | ERR_put_error(13,(107),((1|64)),__FILE__,190); | - | ||||||||||||||||||||||||||||||
| 196 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||
| 197 | } | - | ||||||||||||||||||||||||||||||
| 198 | want -= chunk; | - | ||||||||||||||||||||||||||||||
| 199 | while (chunk > 0
| 34279-34290 | ||||||||||||||||||||||||||||||
| 200 | i = BIO_read(in, &(b->data[len]), chunk); | - | ||||||||||||||||||||||||||||||
| 201 | if (i <= 0
| 10-34280 | ||||||||||||||||||||||||||||||
| 202 | ERR_put_error(13,(107),(142),__FILE__,198) | - | ||||||||||||||||||||||||||||||
| 203 | ; | - | ||||||||||||||||||||||||||||||
| 204 | goto executed 10 times by 1 test: err;goto err;Executed by:
executed 10 times by 1 test: goto err;Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 205 | } | - | ||||||||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||||||||
| 207 | - | |||||||||||||||||||||||||||||||
| 208 | - | |||||||||||||||||||||||||||||||
| 209 | - | |||||||||||||||||||||||||||||||
| 210 | len += i; | - | ||||||||||||||||||||||||||||||
| 211 | chunk -= i; | - | ||||||||||||||||||||||||||||||
| 212 | } executed 34280 times by 1 test: end of blockExecuted by:
| 34280 | ||||||||||||||||||||||||||||||
| 213 | if (chunk_max < 0x7fffffff/2
| 0-34279 | ||||||||||||||||||||||||||||||
| 214 | chunk_max *= 2; executed 34279 times by 1 test: chunk_max *= 2;Executed by:
| 34279 | ||||||||||||||||||||||||||||||
| 215 | } executed 34279 times by 1 test: end of blockExecuted by:
| 34279 | ||||||||||||||||||||||||||||||
| 216 | } executed 34273 times by 1 test: end of blockExecuted by:
| 34273 | ||||||||||||||||||||||||||||||
| 217 | if (off + slen < off
| 0-224987 | ||||||||||||||||||||||||||||||
| 218 | ERR_put_error(13,(107),(155),__FILE__,213); | - | ||||||||||||||||||||||||||||||
| 219 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||
| 220 | } | - | ||||||||||||||||||||||||||||||
| 221 | off += slen; | - | ||||||||||||||||||||||||||||||
| 222 | if (eos == 0
| 354-224633 | ||||||||||||||||||||||||||||||
| 223 | break; executed 354 times by 1 test: break;Executed by:
| 354 | ||||||||||||||||||||||||||||||
| 224 | } else | - | ||||||||||||||||||||||||||||||
| 225 | want = 8; executed 224633 times by 1 test: want = 8;Executed by:
| 224633 | ||||||||||||||||||||||||||||||
| 226 | } | - | ||||||||||||||||||||||||||||||
| 227 | } | - | ||||||||||||||||||||||||||||||
| 228 | - | |||||||||||||||||||||||||||||||
| 229 | if (off > 0x7fffffff
| 0-1540 | ||||||||||||||||||||||||||||||
| 230 | ERR_put_error(13,(107),(155),__FILE__,225); | - | ||||||||||||||||||||||||||||||
| 231 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||
| 232 | } | - | ||||||||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||||||||
| 234 | *pb = b; | - | ||||||||||||||||||||||||||||||
| 235 | return executed 1540 times by 1 test: off;return off;Executed by:
executed 1540 times by 1 test: return off;Executed by:
| 1540 | ||||||||||||||||||||||||||||||
| 236 | err: | - | ||||||||||||||||||||||||||||||
| 237 | BUF_MEM_free(b); | - | ||||||||||||||||||||||||||||||
| 238 | return executed 14 times by 1 test: -1;return -1;Executed by:
executed 14 times by 1 test: return -1;Executed by:
| 14 | ||||||||||||||||||||||||||||||
| 239 | } | - | ||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |