| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/a_bitstr.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||||||||
| 2 | int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len) | - | ||||||||||||||||||||||||||||||
| 3 | { | - | ||||||||||||||||||||||||||||||
| 4 | return executed 21 times by 1 test: ASN1_STRING_set(x, d, len);return ASN1_STRING_set(x, d, len);Executed by:
executed 21 times by 1 test: return ASN1_STRING_set(x, d, len);Executed by:
| 21 | ||||||||||||||||||||||||||||||
| 5 | } | - | ||||||||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||||||||
| 7 | int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp) | - | ||||||||||||||||||||||||||||||
| 8 | { | - | ||||||||||||||||||||||||||||||
| 9 | int ret, j, bits, len; | - | ||||||||||||||||||||||||||||||
| 10 | unsigned char *p, *d; | - | ||||||||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||||||||
| 12 | if (a ==
| 0-309577 | ||||||||||||||||||||||||||||||
| 13 | ((void *)0)
| 0-309577 | ||||||||||||||||||||||||||||||
| 14 | ) | - | ||||||||||||||||||||||||||||||
| 15 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 16 | - | |||||||||||||||||||||||||||||||
| 17 | len = a->length; | - | ||||||||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||||||||
| 19 | if (len > 0
| 133081-176496 | ||||||||||||||||||||||||||||||
| 20 | if (a->flags & 0x08
| 30-176466 | ||||||||||||||||||||||||||||||
| 21 | bits = (int)a->flags & 0x07; | - | ||||||||||||||||||||||||||||||
| 22 | } executed 176466 times by 1 test: else {end of blockExecuted by:
| 176466 | ||||||||||||||||||||||||||||||
| 23 | for (; len > 0
| 0-30 | ||||||||||||||||||||||||||||||
| 24 | if (a->data[len - 1]
| 0-30 | ||||||||||||||||||||||||||||||
| 25 | break; executed 30 times by 1 test: break;Executed by:
| 30 | ||||||||||||||||||||||||||||||
| 26 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 27 | j = a->data[len - 1]; | - | ||||||||||||||||||||||||||||||
| 28 | if (j & 0x01
| 0-30 | ||||||||||||||||||||||||||||||
| 29 | bits = 0; never executed: bits = 0; | 0 | ||||||||||||||||||||||||||||||
| 30 | else if (j & 0x02
| 12-18 | ||||||||||||||||||||||||||||||
| 31 | bits = 1; executed 12 times by 1 test: bits = 1;Executed by:
| 12 | ||||||||||||||||||||||||||||||
| 32 | else if (j & 0x04
| 0-18 | ||||||||||||||||||||||||||||||
| 33 | bits = 2; never executed: bits = 2; | 0 | ||||||||||||||||||||||||||||||
| 34 | else if (j & 0x08
| 6-12 | ||||||||||||||||||||||||||||||
| 35 | bits = 3; executed 6 times by 1 test: bits = 3;Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 36 | else if (j & 0x10
| 0-12 | ||||||||||||||||||||||||||||||
| 37 | bits = 4; never executed: bits = 4; | 0 | ||||||||||||||||||||||||||||||
| 38 | else if (j & 0x20
| 6 | ||||||||||||||||||||||||||||||
| 39 | bits = 5; executed 6 times by 1 test: bits = 5;Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 40 | else if (j & 0x40
| 0-6 | ||||||||||||||||||||||||||||||
| 41 | bits = 6; executed 6 times by 1 test: bits = 6;Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 42 | else if (j & 0x80
| 0 | ||||||||||||||||||||||||||||||
| 43 | bits = 7; never executed: bits = 7; | 0 | ||||||||||||||||||||||||||||||
| 44 | else | - | ||||||||||||||||||||||||||||||
| 45 | bits = 0; never executed: bits = 0; | 0 | ||||||||||||||||||||||||||||||
| 46 | } | - | ||||||||||||||||||||||||||||||
| 47 | } else | - | ||||||||||||||||||||||||||||||
| 48 | bits = 0; executed 133081 times by 1 test: bits = 0;Executed by:
| 133081 | ||||||||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||||||||
| 50 | ret = 1 + len; | - | ||||||||||||||||||||||||||||||
| 51 | if (pp ==
| 74221-235356 | ||||||||||||||||||||||||||||||
| 52 | ((void *)0)
| 74221-235356 | ||||||||||||||||||||||||||||||
| 53 | ) | - | ||||||||||||||||||||||||||||||
| 54 | return executed 235356 times by 1 test: ret;return ret;Executed by:
executed 235356 times by 1 test: return ret;Executed by:
| 235356 | ||||||||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||||||||
| 56 | p = *pp; | - | ||||||||||||||||||||||||||||||
| 57 | - | |||||||||||||||||||||||||||||||
| 58 | *(p++) = (unsigned char)bits; | - | ||||||||||||||||||||||||||||||
| 59 | d = a->data; | - | ||||||||||||||||||||||||||||||
| 60 | if (len > 0
| 32215-42006 | ||||||||||||||||||||||||||||||
| 61 | memcpy(p, d, len); | - | ||||||||||||||||||||||||||||||
| 62 | p += len; | - | ||||||||||||||||||||||||||||||
| 63 | p[-1] &= (0xff << bits); | - | ||||||||||||||||||||||||||||||
| 64 | } executed 42006 times by 1 test: end of blockExecuted by:
| 42006 | ||||||||||||||||||||||||||||||
| 65 | *pp = p; | - | ||||||||||||||||||||||||||||||
| 66 | return executed 74221 times by 1 test: ret;return ret;Executed by:
executed 74221 times by 1 test: return ret;Executed by:
| 74221 | ||||||||||||||||||||||||||||||
| 67 | } | - | ||||||||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||||||||
| 69 | ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a, | - | ||||||||||||||||||||||||||||||
| 70 | const unsigned char **pp, long len) | - | ||||||||||||||||||||||||||||||
| 71 | { | - | ||||||||||||||||||||||||||||||
| 72 | ASN1_BIT_STRING *ret = | - | ||||||||||||||||||||||||||||||
| 73 | ((void *)0) | - | ||||||||||||||||||||||||||||||
| 74 | ; | - | ||||||||||||||||||||||||||||||
| 75 | const unsigned char *p; | - | ||||||||||||||||||||||||||||||
| 76 | unsigned char *s; | - | ||||||||||||||||||||||||||||||
| 77 | int i; | - | ||||||||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||||||||
| 79 | if (len < 1
| 1244-146638 | ||||||||||||||||||||||||||||||
| 80 | i = 152; | - | ||||||||||||||||||||||||||||||
| 81 | goto executed 1244 times by 1 test: err;goto err;Executed by:
executed 1244 times by 1 test: goto err;Executed by:
| 1244 | ||||||||||||||||||||||||||||||
| 82 | } | - | ||||||||||||||||||||||||||||||
| 83 | - | |||||||||||||||||||||||||||||||
| 84 | if (len > 0x7fffffff
| 0-146638 | ||||||||||||||||||||||||||||||
| 85 | i = 151; | - | ||||||||||||||||||||||||||||||
| 86 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||
| 87 | } | - | ||||||||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||||||||
| 89 | if ((
| 0-146638 | ||||||||||||||||||||||||||||||
| 90 | ((void *)0)
| 0-146638 | ||||||||||||||||||||||||||||||
| 91 | )
| 0-146638 | ||||||||||||||||||||||||||||||
| 92 | ((void *)0)
| 22982-123656 | ||||||||||||||||||||||||||||||
| 93 | )
| 22982-123656 | ||||||||||||||||||||||||||||||
| 94 | if ((
| 0-22982 | ||||||||||||||||||||||||||||||
| 95 | ((void *)0)
| 0-22982 | ||||||||||||||||||||||||||||||
| 96 | ) | - | ||||||||||||||||||||||||||||||
| 97 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||
| 98 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||
| 99 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||
| 100 | } executed 22982 times by 1 test: elseend of blockExecuted by:
| 22982 | ||||||||||||||||||||||||||||||
| 101 | ret = (*a); executed 123656 times by 1 test: ret = (*a);Executed by:
| 123656 | ||||||||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||||||||
| 103 | p = *pp; | - | ||||||||||||||||||||||||||||||
| 104 | i = *(p++); | - | ||||||||||||||||||||||||||||||
| 105 | if (i > 7
| 626-146012 | ||||||||||||||||||||||||||||||
| 106 | i = 220; | - | ||||||||||||||||||||||||||||||
| 107 | goto executed 626 times by 1 test: err;goto err;Executed by:
executed 626 times by 1 test: goto err;Executed by:
| 626 | ||||||||||||||||||||||||||||||
| 108 | } | - | ||||||||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||||||||
| 112 | - | |||||||||||||||||||||||||||||||
| 113 | ret->flags &= ~(0x08 | 0x07); | - | ||||||||||||||||||||||||||||||
| 114 | ret->flags |= (0x08 | i); | - | ||||||||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||||||||
| 116 | if (len-- > 1
| 53866-92146 | ||||||||||||||||||||||||||||||
| 117 | s = CRYPTO_malloc((int)len, __FILE__, 117); | - | ||||||||||||||||||||||||||||||
| 118 | if (s ==
| 0-92146 | ||||||||||||||||||||||||||||||
| 119 | ((void *)0)
| 0-92146 | ||||||||||||||||||||||||||||||
| 120 | ) { | - | ||||||||||||||||||||||||||||||
| 121 | i = (1|64); | - | ||||||||||||||||||||||||||||||
| 122 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||||||||
| 123 | } | - | ||||||||||||||||||||||||||||||
| 124 | memcpy(s, p, (int)len); | - | ||||||||||||||||||||||||||||||
| 125 | s[len - 1] &= (0xff << i); | - | ||||||||||||||||||||||||||||||
| 126 | p += len; | - | ||||||||||||||||||||||||||||||
| 127 | } executed 92146 times by 1 test: elseend of blockExecuted by:
| 92146 | ||||||||||||||||||||||||||||||
| 128 | s = executed 53866 times by 1 test: s = ((void *)0) ;Executed by:
| 53866 | ||||||||||||||||||||||||||||||
| 129 | ((void *)0) executed 53866 times by 1 test: s = ((void *)0) ;Executed by:
| 53866 | ||||||||||||||||||||||||||||||
| 130 | ; executed 53866 times by 1 test: s = ((void *)0) ;Executed by:
| 53866 | ||||||||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||||||||
| 132 | ret->length = (int)len; | - | ||||||||||||||||||||||||||||||
| 133 | CRYPTO_free(ret->data, __FILE__, 129); | - | ||||||||||||||||||||||||||||||
| 134 | ret->data = s; | - | ||||||||||||||||||||||||||||||
| 135 | ret->type = 3; | - | ||||||||||||||||||||||||||||||
| 136 | if (a !=
| 0-146012 | ||||||||||||||||||||||||||||||
| 137 | ((void *)0)
| 0-146012 | ||||||||||||||||||||||||||||||
| 138 | ) | - | ||||||||||||||||||||||||||||||
| 139 | (* executed 146012 times by 1 test: a) = ret;(*a) = ret;Executed by:
executed 146012 times by 1 test: (*a) = ret;Executed by:
| 146012 | ||||||||||||||||||||||||||||||
| 140 | *pp = p; | - | ||||||||||||||||||||||||||||||
| 141 | return executed 146012 times by 1 test: ret;return ret;Executed by:
executed 146012 times by 1 test: return ret;Executed by:
| 146012 | ||||||||||||||||||||||||||||||
| 142 | err: | - | ||||||||||||||||||||||||||||||
| 143 | ERR_put_error(13,(189),(i),__FILE__,137); | - | ||||||||||||||||||||||||||||||
| 144 | if ((
| 0-1870 | ||||||||||||||||||||||||||||||
| 145 | ((void *)0)
| 0-1870 | ||||||||||||||||||||||||||||||
| 146 | )
| 0-1870 | ||||||||||||||||||||||||||||||
| 147 | ASN1_BIT_STRING_free(ret); executed 807 times by 1 test: ASN1_BIT_STRING_free(ret);Executed by:
| 807 | ||||||||||||||||||||||||||||||
| 148 | return executed 1870 times by 1 test: return ((void *)0) ;Executed by:
executed 1870 times by 1 test: return ((void *)0) ;Executed by:
| 1870 | ||||||||||||||||||||||||||||||
| 149 | ((void *)0) executed 1870 times by 1 test: return ((void *)0) ;Executed by:
| 1870 | ||||||||||||||||||||||||||||||
| 150 | ; executed 1870 times by 1 test: return ((void *)0) ;Executed by:
| 1870 | ||||||||||||||||||||||||||||||
| 151 | } | - | ||||||||||||||||||||||||||||||
| 152 | - | |||||||||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||||||||
| 154 | - | |||||||||||||||||||||||||||||||
| 155 | - | |||||||||||||||||||||||||||||||
| 156 | int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) | - | ||||||||||||||||||||||||||||||
| 157 | { | - | ||||||||||||||||||||||||||||||
| 158 | int w, v, iv; | - | ||||||||||||||||||||||||||||||
| 159 | unsigned char *c; | - | ||||||||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||||||||
| 161 | w = n / 8; | - | ||||||||||||||||||||||||||||||
| 162 | v = 1 << (7 - (n & 0x07)); | - | ||||||||||||||||||||||||||||||
| 163 | iv = ~v; | - | ||||||||||||||||||||||||||||||
| 164 | if (!value
| 0-24 | ||||||||||||||||||||||||||||||
| 165 | v = 0; never executed: v = 0; | 0 | ||||||||||||||||||||||||||||||
| 166 | - | |||||||||||||||||||||||||||||||
| 167 | if (a ==
| 0-24 | ||||||||||||||||||||||||||||||
| 168 | ((void *)0)
| 0-24 | ||||||||||||||||||||||||||||||
| 169 | ) | - | ||||||||||||||||||||||||||||||
| 170 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 171 | - | |||||||||||||||||||||||||||||||
| 172 | a->flags &= ~(0x08 | 0x07); | - | ||||||||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||||||||
| 174 | if ((
| 0-14 | ||||||||||||||||||||||||||||||
| 175 | ((void *)0)
| 0-14 | ||||||||||||||||||||||||||||||
| 176 | )
| 0-14 | ||||||||||||||||||||||||||||||
| 177 | if (!value
| 0-10 | ||||||||||||||||||||||||||||||
| 178 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||||||||
| 179 | c = CRYPTO_clear_realloc(a->data, a->length, w + 1, __FILE__, 165); | - | ||||||||||||||||||||||||||||||
| 180 | if (c ==
| 0-10 | ||||||||||||||||||||||||||||||
| 181 | ((void *)0)
| 0-10 | ||||||||||||||||||||||||||||||
| 182 | ) { | - | ||||||||||||||||||||||||||||||
| 183 | ERR_put_error(13,(183),((1|64)),__FILE__,167); | - | ||||||||||||||||||||||||||||||
| 184 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||||||||
| 185 | } | - | ||||||||||||||||||||||||||||||
| 186 | if (w + 1 - a->length > 0
| 0-10 | ||||||||||||||||||||||||||||||
| 187 | memset(c + a->length, 0, w + 1 - a->length); executed 10 times by 1 test: memset(c + a->length, 0, w + 1 - a->length);Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 188 | a->data = c; | - | ||||||||||||||||||||||||||||||
| 189 | a->length = w + 1; | - | ||||||||||||||||||||||||||||||
| 190 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||||||||
| 191 | a->data[w] = ((a->data[w]) & iv) | v; | - | ||||||||||||||||||||||||||||||
| 192 | while ((
| 0-24 | ||||||||||||||||||||||||||||||
| 193 | a->length--; never executed: a->length--; | 0 | ||||||||||||||||||||||||||||||
| 194 | return executed 24 times by 1 test: 1;return 1;Executed by:
executed 24 times by 1 test: return 1;Executed by:
| 24 | ||||||||||||||||||||||||||||||
| 195 | } | - | ||||||||||||||||||||||||||||||
| 196 | - | |||||||||||||||||||||||||||||||
| 197 | int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n) | - | ||||||||||||||||||||||||||||||
| 198 | { | - | ||||||||||||||||||||||||||||||
| 199 | int w, v; | - | ||||||||||||||||||||||||||||||
| 200 | - | |||||||||||||||||||||||||||||||
| 201 | w = n / 8; | - | ||||||||||||||||||||||||||||||
| 202 | v = 1 << (7 - (n & 0x07)); | - | ||||||||||||||||||||||||||||||
| 203 | if ((
| 0-47413 | ||||||||||||||||||||||||||||||
| 204 | ((void *)0)
| 0-47413 | ||||||||||||||||||||||||||||||
| 205 | )
| 0-47413 | ||||||||||||||||||||||||||||||
| 206 | ((void *)0)
| 0-41520 | ||||||||||||||||||||||||||||||
| 207 | )
| 0-41520 | ||||||||||||||||||||||||||||||
| 208 | return executed 5893 times by 1 test: 0;return 0;Executed by:
executed 5893 times by 1 test: return 0;Executed by:
| 5893 | ||||||||||||||||||||||||||||||
| 209 | return executed 41520 times by 1 test: ((a->data[w] & v) != 0);return ((a->data[w] & v) != 0);Executed by:
executed 41520 times by 1 test: return ((a->data[w] & v) != 0);Executed by:
| 41520 | ||||||||||||||||||||||||||||||
| 210 | } | - | ||||||||||||||||||||||||||||||
| 211 | - | |||||||||||||||||||||||||||||||
| 212 | - | |||||||||||||||||||||||||||||||
| 213 | - | |||||||||||||||||||||||||||||||
| 214 | - | |||||||||||||||||||||||||||||||
| 215 | - | |||||||||||||||||||||||||||||||
| 216 | - | |||||||||||||||||||||||||||||||
| 217 | - | |||||||||||||||||||||||||||||||
| 218 | int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a, | - | ||||||||||||||||||||||||||||||
| 219 | const unsigned char *flags, int flags_len) | - | ||||||||||||||||||||||||||||||
| 220 | { | - | ||||||||||||||||||||||||||||||
| 221 | int i, ok; | - | ||||||||||||||||||||||||||||||
| 222 | - | |||||||||||||||||||||||||||||||
| 223 | if (!a
| 0 | ||||||||||||||||||||||||||||||
| 224 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||||||||
| 225 | - | |||||||||||||||||||||||||||||||
| 226 | - | |||||||||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||||||||
| 228 | - | |||||||||||||||||||||||||||||||
| 229 | ok = 1; | - | ||||||||||||||||||||||||||||||
| 230 | for (i = 0; i < a->length
| 0 | ||||||||||||||||||||||||||||||
| 231 | unsigned char mask = i < flags_len
| 0 | ||||||||||||||||||||||||||||||
| 232 | - | |||||||||||||||||||||||||||||||
| 233 | ok = (a->data[i] & mask) == 0; | - | ||||||||||||||||||||||||||||||
| 234 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 235 | return never executed: ok;return ok;never executed: return ok; | 0 | ||||||||||||||||||||||||||||||
| 236 | } | - | ||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |