| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/x_long.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | static int long_new(ASN1_VALUE **pval, const ASN1_ITEM *it); | - | ||||||||||||||||||
| 2 | static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it); | - | ||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, | - | ||||||||||||||||||
| 5 | const ASN1_ITEM *it); | - | ||||||||||||||||||
| 6 | static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, | - | ||||||||||||||||||
| 7 | int utype, char *free_cont, const ASN1_ITEM *it); | - | ||||||||||||||||||
| 8 | static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, | - | ||||||||||||||||||
| 9 | int indent, const ASN1_PCTX *pctx); | - | ||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | static ASN1_PRIMITIVE_FUNCS long_pf = { | - | ||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | ((void *)0) | - | ||||||||||||||||||
| 14 | , 0, | - | ||||||||||||||||||
| 15 | long_new, | - | ||||||||||||||||||
| 16 | long_free, | - | ||||||||||||||||||
| 17 | long_free, | - | ||||||||||||||||||
| 18 | long_c2i, | - | ||||||||||||||||||
| 19 | long_i2c, | - | ||||||||||||||||||
| 20 | long_print | - | ||||||||||||||||||
| 21 | }; | - | ||||||||||||||||||
| 22 | - | |||||||||||||||||||
| 23 | const ASN1_ITEM LONG_it = { | - | ||||||||||||||||||
| 24 | 0x0, 2, | - | ||||||||||||||||||
| 25 | ((void *)0) | - | ||||||||||||||||||
| 26 | , 0, &long_pf, 0x7fffffffL, "LONG" | - | ||||||||||||||||||
| 27 | }; | - | ||||||||||||||||||
| 28 | - | |||||||||||||||||||
| 29 | const ASN1_ITEM ZLONG_it = { | - | ||||||||||||||||||
| 30 | 0x0, 2, | - | ||||||||||||||||||
| 31 | ((void *)0) | - | ||||||||||||||||||
| 32 | , 0, &long_pf, 0, "ZLONG" | - | ||||||||||||||||||
| 33 | }; | - | ||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | static int long_new(ASN1_VALUE **pval, const ASN1_ITEM *it) | - | ||||||||||||||||||
| 36 | { | - | ||||||||||||||||||
| 37 | memcpy(pval, &it->size, (sizeof(*pval) < sizeof(it->size) ? sizeof(*pval) : sizeof(it->size))); | - | ||||||||||||||||||
| 38 | return executed 46 times by 1 test: 1;return 1;Executed by:
executed 46 times by 1 test: return 1;Executed by:
| 46 | ||||||||||||||||||
| 39 | } | - | ||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | static void long_free(ASN1_VALUE **pval, const ASN1_ITEM *it) | - | ||||||||||||||||||
| 42 | { | - | ||||||||||||||||||
| 43 | memcpy(pval, &it->size, (sizeof(*pval) < sizeof(it->size) ? sizeof(*pval) : sizeof(it->size))); | - | ||||||||||||||||||
| 44 | } executed 6784 times by 1 test: end of blockExecuted by:
| 6784 | ||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | - | |||||||||||||||||||
| 48 | - | |||||||||||||||||||
| 49 | - | |||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | static int num_bits_ulong(unsigned long value) | - | ||||||||||||||||||
| 53 | { | - | ||||||||||||||||||
| 54 | size_t i; | - | ||||||||||||||||||
| 55 | unsigned long ret = 0; | - | ||||||||||||||||||
| 56 | - | |||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | - | |||||||||||||||||||
| 59 | - | |||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | - | |||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | for (i = 0; i < sizeof(value) * 8
| 398-25472 | ||||||||||||||||||
| 64 | ret += (value != 0); | - | ||||||||||||||||||
| 65 | value >>= 1; | - | ||||||||||||||||||
| 66 | } executed 25472 times by 1 test: end of blockExecuted by:
| 25472 | ||||||||||||||||||
| 67 | - | |||||||||||||||||||
| 68 | return executed 398 times by 1 test: (int)ret;return (int)ret;Executed by:
executed 398 times by 1 test: return (int)ret;Executed by:
| 398 | ||||||||||||||||||
| 69 | } | - | ||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, | - | ||||||||||||||||||
| 72 | const ASN1_ITEM *it) | - | ||||||||||||||||||
| 73 | { | - | ||||||||||||||||||
| 74 | long ltmp; | - | ||||||||||||||||||
| 75 | unsigned long utmp, sign; | - | ||||||||||||||||||
| 76 | int clen, pad, i; | - | ||||||||||||||||||
| 77 | - | |||||||||||||||||||
| 78 | memcpy(<mp, pval, (sizeof(*pval) < sizeof(ltmp) ? sizeof(*pval) : sizeof(ltmp))); | - | ||||||||||||||||||
| 79 | if (ltmp == it->size
| 48-398 | ||||||||||||||||||
| 80 | return executed 48 times by 1 test: -1;return -1;Executed by:
executed 48 times by 1 test: return -1;Executed by:
| 48 | ||||||||||||||||||
| 81 | - | |||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | - | |||||||||||||||||||
| 86 | if (ltmp < 0
| 90-308 | ||||||||||||||||||
| 87 | sign = 0xff; | - | ||||||||||||||||||
| 88 | utmp = 0 - (unsigned long)ltmp - 1; | - | ||||||||||||||||||
| 89 | } executed 90 times by 1 test: else {end of blockExecuted by:
| 90 | ||||||||||||||||||
| 90 | sign = 0; | - | ||||||||||||||||||
| 91 | utmp = ltmp; | - | ||||||||||||||||||
| 92 | } executed 308 times by 1 test: end of blockExecuted by:
| 308 | ||||||||||||||||||
| 93 | clen = num_bits_ulong(utmp); | - | ||||||||||||||||||
| 94 | - | |||||||||||||||||||
| 95 | if (!(clen & 0x7)
| 118-280 | ||||||||||||||||||
| 96 | pad = 1; executed 118 times by 1 test: pad = 1;Executed by:
| 118 | ||||||||||||||||||
| 97 | else | - | ||||||||||||||||||
| 98 | pad = 0; executed 280 times by 1 test: pad = 0;Executed by:
| 280 | ||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | - | |||||||||||||||||||
| 101 | clen = (clen + 7) >> 3; | - | ||||||||||||||||||
| 102 | - | |||||||||||||||||||
| 103 | if (cont !=
| 97-301 | ||||||||||||||||||
| 104 | ((void *)0)
| 97-301 | ||||||||||||||||||
| 105 | ) { | - | ||||||||||||||||||
| 106 | if (pad
| 30-67 | ||||||||||||||||||
| 107 | * executed 30 times by 1 test: cont++ = (unsigned char)sign;*cont++ = (unsigned char)sign;Executed by:
executed 30 times by 1 test: *cont++ = (unsigned char)sign;Executed by:
| 30 | ||||||||||||||||||
| 108 | for (i = clen - 1; i >= 0
| 97-220 | ||||||||||||||||||
| 109 | cont[i] = (unsigned char)(utmp ^ sign); | - | ||||||||||||||||||
| 110 | utmp >>= 8; | - | ||||||||||||||||||
| 111 | } executed 220 times by 1 test: end of blockExecuted by:
| 220 | ||||||||||||||||||
| 112 | } executed 97 times by 1 test: end of blockExecuted by:
| 97 | ||||||||||||||||||
| 113 | return executed 398 times by 1 test: clen + pad;return clen + pad;Executed by:
executed 398 times by 1 test: return clen + pad;Executed by:
| 398 | ||||||||||||||||||
| 114 | } | - | ||||||||||||||||||
| 115 | - | |||||||||||||||||||
| 116 | static int long_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, | - | ||||||||||||||||||
| 117 | int utype, char *free_cont, const ASN1_ITEM *it) | - | ||||||||||||||||||
| 118 | { | - | ||||||||||||||||||
| 119 | int i; | - | ||||||||||||||||||
| 120 | long ltmp; | - | ||||||||||||||||||
| 121 | unsigned long utmp = 0, sign = 0x100; | - | ||||||||||||||||||
| 122 | - | |||||||||||||||||||
| 123 | if (len > 1
| 57-77 | ||||||||||||||||||
| 124 | - | |||||||||||||||||||
| 125 | - | |||||||||||||||||||
| 126 | - | |||||||||||||||||||
| 127 | - | |||||||||||||||||||
| 128 | - | |||||||||||||||||||
| 129 | switch (cont[0]) { | - | ||||||||||||||||||
| 130 | case executed 18 times by 1 test: 0xff:case 0xff:Executed by:
executed 18 times by 1 test: case 0xff:Executed by:
| 18 | ||||||||||||||||||
| 131 | cont++; | - | ||||||||||||||||||
| 132 | len--; | - | ||||||||||||||||||
| 133 | sign = 0xff; | - | ||||||||||||||||||
| 134 | break; executed 18 times by 1 test: break;Executed by:
| 18 | ||||||||||||||||||
| 135 | case executed 16 times by 1 test: 0:case 0:Executed by:
executed 16 times by 1 test: case 0:Executed by:
| 16 | ||||||||||||||||||
| 136 | cont++; | - | ||||||||||||||||||
| 137 | len--; | - | ||||||||||||||||||
| 138 | sign = 0; | - | ||||||||||||||||||
| 139 | break; executed 16 times by 1 test: break;Executed by:
| 16 | ||||||||||||||||||
| 140 | } | - | ||||||||||||||||||
| 141 | } executed 77 times by 1 test: end of blockExecuted by:
| 77 | ||||||||||||||||||
| 142 | if (len > (int)sizeof(long)
| 24-110 | ||||||||||||||||||
| 143 | ERR_put_error(13,(166),(128),__FILE__,159); | - | ||||||||||||||||||
| 144 | return executed 24 times by 1 test: 0;return 0;Executed by:
executed 24 times by 1 test: return 0;Executed by:
| 24 | ||||||||||||||||||
| 145 | } | - | ||||||||||||||||||
| 146 | - | |||||||||||||||||||
| 147 | if (sign == 0x100
| 22-88 | ||||||||||||||||||
| 148 | - | |||||||||||||||||||
| 149 | if (len
| 3-85 | ||||||||||||||||||
| 150 | sign = 0xff; executed 20 times by 1 test: sign = 0xff;Executed by:
| 20 | ||||||||||||||||||
| 151 | else | - | ||||||||||||||||||
| 152 | sign = 0; executed 68 times by 1 test: sign = 0;Executed by:
| 68 | ||||||||||||||||||
| 153 | } else if (((
| 10-12 | ||||||||||||||||||
| 154 | ERR_put_error(13,(166),(221),__FILE__,170); | - | ||||||||||||||||||
| 155 | return executed 10 times by 1 test: 0;return 0;Executed by:
executed 10 times by 1 test: return 0;Executed by:
| 10 | ||||||||||||||||||
| 156 | } | - | ||||||||||||||||||
| 157 | utmp = 0; | - | ||||||||||||||||||
| 158 | for (i = 0; i < len
| 100-276 | ||||||||||||||||||
| 159 | utmp <<= 8; | - | ||||||||||||||||||
| 160 | utmp |= cont[i] ^ sign; | - | ||||||||||||||||||
| 161 | } executed 276 times by 1 test: end of blockExecuted by:
| 276 | ||||||||||||||||||
| 162 | ltmp = (long)utmp; | - | ||||||||||||||||||
| 163 | if (ltmp < 0
| 4-96 | ||||||||||||||||||
| 164 | ERR_put_error(13,(166),(128),__FILE__,180); | - | ||||||||||||||||||
| 165 | return executed 4 times by 1 test: 0;return 0;Executed by:
executed 4 times by 1 test: return 0;Executed by:
| 4 | ||||||||||||||||||
| 166 | } | - | ||||||||||||||||||
| 167 | if (sign
| 24-72 | ||||||||||||||||||
| 168 | ltmp = -ltmp - 1; executed 24 times by 1 test: ltmp = -ltmp - 1;Executed by:
| 24 | ||||||||||||||||||
| 169 | if (ltmp == it->size
| 5-91 | ||||||||||||||||||
| 170 | ERR_put_error(13,(166),(128),__FILE__,186); | - | ||||||||||||||||||
| 171 | return executed 5 times by 1 test: 0;return 0;Executed by:
executed 5 times by 1 test: return 0;Executed by:
| 5 | ||||||||||||||||||
| 172 | } | - | ||||||||||||||||||
| 173 | memcpy(pval, <mp, (sizeof(*pval) < sizeof(ltmp) ? sizeof(*pval) : sizeof(ltmp))); | - | ||||||||||||||||||
| 174 | return executed 91 times by 1 test: 1;return 1;Executed by:
executed 91 times by 1 test: return 1;Executed by:
| 91 | ||||||||||||||||||
| 175 | } | - | ||||||||||||||||||
| 176 | - | |||||||||||||||||||
| 177 | static int long_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it, | - | ||||||||||||||||||
| 178 | int indent, const ASN1_PCTX *pctx) | - | ||||||||||||||||||
| 179 | { | - | ||||||||||||||||||
| 180 | long l; | - | ||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | memcpy(&l, pval, (sizeof(*pval) < sizeof(l) ? sizeof(*pval) : sizeof(l))); | - | ||||||||||||||||||
| 183 | return executed 23 times by 1 test: BIO_printf(out, "%ld\n", l);return BIO_printf(out, "%ld\n", l);Executed by:
executed 23 times by 1 test: return BIO_printf(out, "%ld\n", l);Executed by:
| 23 | ||||||||||||||||||
| 184 | } | - | ||||||||||||||||||
| Switch to Source code | Preprocessed file |