| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/o_str.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | int OPENSSL_memcmp(const void *v1, const void *v2, size_t n) | - | ||||||||||||||||||
| 4 | { | - | ||||||||||||||||||
| 5 | const unsigned char *c1 = v1, *c2 = v2; | - | ||||||||||||||||||
| 6 | int ret = 0; | - | ||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | while (n
| 0 | ||||||||||||||||||
| 9 | n--, c1++, c2++; never executed: n--, c1++, c2++; | 0 | ||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||
| 12 | } | - | ||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | char *CRYPTO_strdup(const char *str, const char* file, int line) | - | ||||||||||||||||||
| 15 | { | - | ||||||||||||||||||
| 16 | char *ret; | - | ||||||||||||||||||
| 17 | - | |||||||||||||||||||
| 18 | if (str ==
| 0-226510 | ||||||||||||||||||
| 19 | ((void *)0)
| 0-226510 | ||||||||||||||||||
| 20 | ) | - | ||||||||||||||||||
| 21 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 22 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 23 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 24 | ret = CRYPTO_malloc(strlen(str) + 1, file, line); | - | ||||||||||||||||||
| 25 | if (ret !=
| 0-226510 | ||||||||||||||||||
| 26 | ((void *)0)
| 0-226510 | ||||||||||||||||||
| 27 | ) | - | ||||||||||||||||||
| 28 | strcpy(ret, str); executed 226510 times by 12 tests: strcpy(ret, str);Executed by:
| 226510 | ||||||||||||||||||
| 29 | return executed 226510 times by 12 tests: ret;return ret;Executed by:
executed 226510 times by 12 tests: return ret;Executed by:
| 226510 | ||||||||||||||||||
| 30 | } | - | ||||||||||||||||||
| 31 | - | |||||||||||||||||||
| 32 | char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line) | - | ||||||||||||||||||
| 33 | { | - | ||||||||||||||||||
| 34 | size_t maxlen; | - | ||||||||||||||||||
| 35 | char *ret; | - | ||||||||||||||||||
| 36 | - | |||||||||||||||||||
| 37 | if (str ==
| 998-18080 | ||||||||||||||||||
| 38 | ((void *)0)
| 998-18080 | ||||||||||||||||||
| 39 | ) | - | ||||||||||||||||||
| 40 | return executed 998 times by 1 test: return ((void *)0) ;Executed by:
executed 998 times by 1 test: return ((void *)0) ;Executed by:
| 998 | ||||||||||||||||||
| 41 | ((void *)0) executed 998 times by 1 test: return ((void *)0) ;Executed by:
| 998 | ||||||||||||||||||
| 42 | ; executed 998 times by 1 test: return ((void *)0) ;Executed by:
| 998 | ||||||||||||||||||
| 43 | - | |||||||||||||||||||
| 44 | maxlen = OPENSSL_strnlen(str, s); | - | ||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | ret = CRYPTO_malloc(maxlen + 1, file, line); | - | ||||||||||||||||||
| 47 | if (ret
| 0-18080 | ||||||||||||||||||
| 48 | memcpy(ret, str, maxlen); | - | ||||||||||||||||||
| 49 | ret[maxlen] = '\0'; | - | ||||||||||||||||||
| 50 | } executed 18080 times by 1 test: end of blockExecuted by:
| 18080 | ||||||||||||||||||
| 51 | return executed 18080 times by 1 test: ret;return ret;Executed by:
executed 18080 times by 1 test: return ret;Executed by:
| 18080 | ||||||||||||||||||
| 52 | } | - | ||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | void *CRYPTO_memdup(const void *data, size_t siz, const char* file, int line) | - | ||||||||||||||||||
| 55 | { | - | ||||||||||||||||||
| 56 | void *ret; | - | ||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | if (data ==
| 0-126466 | ||||||||||||||||||
| 59 | ((void *)0)
| 0-126466 | ||||||||||||||||||
| 60 | || siz >= 0x7fffffff
| 0-126466 | ||||||||||||||||||
| 61 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 62 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 63 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 64 | - | |||||||||||||||||||
| 65 | ret = CRYPTO_malloc(siz, file, line); | - | ||||||||||||||||||
| 66 | if (ret ==
| 0-126466 | ||||||||||||||||||
| 67 | ((void *)0)
| 0-126466 | ||||||||||||||||||
| 68 | ) { | - | ||||||||||||||||||
| 69 | ERR_put_error(15,(115),((1|64)),__FILE__,66); | - | ||||||||||||||||||
| 70 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 71 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 72 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 73 | } | - | ||||||||||||||||||
| 74 | return executed 126466 times by 1 test: memcpy(ret, data, siz);return memcpy(ret, data, siz);Executed by:
executed 126466 times by 1 test: return memcpy(ret, data, siz);Executed by:
| 126466 | ||||||||||||||||||
| 75 | } | - | ||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | size_t OPENSSL_strnlen(const char *str, size_t maxlen) | - | ||||||||||||||||||
| 78 | { | - | ||||||||||||||||||
| 79 | const char *p; | - | ||||||||||||||||||
| 80 | - | |||||||||||||||||||
| 81 | for (p = str; maxlen-- != 0
executed 13728419 times by 12 tests: ;Executed by:
| 25614-16194599 | ||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | return executed 2491794 times by 12 tests: p - str;return p - str;Executed by:
executed 2491794 times by 12 tests: return p - str;Executed by:
| 2491794 | ||||||||||||||||||
| 84 | } | - | ||||||||||||||||||
| 85 | - | |||||||||||||||||||
| 86 | size_t OPENSSL_strlcpy(char *dst, const char *src, size_t size) | - | ||||||||||||||||||
| 87 | { | - | ||||||||||||||||||
| 88 | size_t l = 0; | - | ||||||||||||||||||
| 89 | for (; size > 1
| 9058-27559499 | ||||||||||||||||||
| 90 | *dst++ = *src++; | - | ||||||||||||||||||
| 91 | l++; | - | ||||||||||||||||||
| 92 | } executed 24856165 times by 1 test: end of blockExecuted by:
| 24856165 | ||||||||||||||||||
| 93 | if (size
| 1919-2710473 | ||||||||||||||||||
| 94 | * executed 2710473 times by 1 test: dst = '\0';*dst = '\0';Executed by:
executed 2710473 times by 1 test: *dst = '\0';Executed by:
| 2710473 | ||||||||||||||||||
| 95 | return executed 2712392 times by 1 test: l + strlen(src);return l + strlen(src);Executed by:
executed 2712392 times by 1 test: return l + strlen(src);Executed by:
| 2712392 | ||||||||||||||||||
| 96 | } | - | ||||||||||||||||||
| 97 | - | |||||||||||||||||||
| 98 | size_t OPENSSL_strlcat(char *dst, const char *src, size_t size) | - | ||||||||||||||||||
| 99 | { | - | ||||||||||||||||||
| 100 | size_t l = 0; | - | ||||||||||||||||||
| 101 | for (; size > 0
| 0-21486302 | ||||||||||||||||||
| 102 | l++; executed 19355459 times by 1 test: l++;Executed by:
| 19355459 | ||||||||||||||||||
| 103 | return executed 2130843 times by 1 test: l + OPENSSL_strlcpy(dst, src, size);return l + OPENSSL_strlcpy(dst, src, size);Executed by:
executed 2130843 times by 1 test: return l + OPENSSL_strlcpy(dst, src, size);Executed by:
| 2130843 | ||||||||||||||||||
| 104 | } | - | ||||||||||||||||||
| 105 | - | |||||||||||||||||||
| 106 | int OPENSSL_hexchar2int(unsigned char c) | - | ||||||||||||||||||
| 107 | { | - | ||||||||||||||||||
| 108 | - | |||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | - | |||||||||||||||||||
| 111 | - | |||||||||||||||||||
| 112 | switch (c) { | - | ||||||||||||||||||
| 113 | case executed 155917 times by 2 tests: '0':case '0':Executed by:
executed 155917 times by 2 tests: case '0':Executed by:
| 155917 | ||||||||||||||||||
| 114 | return executed 155917 times by 2 tests: 0;return 0;Executed by:
executed 155917 times by 2 tests: return 0;Executed by:
| 155917 | ||||||||||||||||||
| 115 | case executed 75519 times by 2 tests: '1':case '1':Executed by:
executed 75519 times by 2 tests: case '1':Executed by:
| 75519 | ||||||||||||||||||
| 116 | return executed 75519 times by 2 tests: 1;return 1;Executed by:
executed 75519 times by 2 tests: return 1;Executed by:
| 75519 | ||||||||||||||||||
| 117 | case executed 70030 times by 2 tests: '2':case '2':Executed by:
executed 70030 times by 2 tests: case '2':Executed by:
| 70030 | ||||||||||||||||||
| 118 | return executed 70030 times by 2 tests: 2;return 2;Executed by:
executed 70030 times by 2 tests: return 2;Executed by:
| 70030 | ||||||||||||||||||
| 119 | case executed 66553 times by 2 tests: '3':case '3':Executed by:
executed 66553 times by 2 tests: case '3':Executed by:
| 66553 | ||||||||||||||||||
| 120 | return executed 66553 times by 2 tests: 3;return 3;Executed by:
executed 66553 times by 2 tests: return 3;Executed by:
| 66553 | ||||||||||||||||||
| 121 | case executed 75176 times by 2 tests: '4':case '4':Executed by:
executed 75176 times by 2 tests: case '4':Executed by:
| 75176 | ||||||||||||||||||
| 122 | return executed 75176 times by 2 tests: 4;return 4;Executed by:
executed 75176 times by 2 tests: return 4;Executed by:
| 75176 | ||||||||||||||||||
| 123 | case executed 68575 times by 2 tests: '5':case '5':Executed by:
executed 68575 times by 2 tests: case '5':Executed by:
| 68575 | ||||||||||||||||||
| 124 | return executed 68575 times by 2 tests: 5;return 5;Executed by:
executed 68575 times by 2 tests: return 5;Executed by:
| 68575 | ||||||||||||||||||
| 125 | case executed 67523 times by 2 tests: '6':case '6':Executed by:
executed 67523 times by 2 tests: case '6':Executed by:
| 67523 | ||||||||||||||||||
| 126 | return executed 67523 times by 2 tests: 6;return 6;Executed by:
executed 67523 times by 2 tests: return 6;Executed by:
| 67523 | ||||||||||||||||||
| 127 | case executed 66151 times by 2 tests: '7':case '7':Executed by:
executed 66151 times by 2 tests: case '7':Executed by:
| 66151 | ||||||||||||||||||
| 128 | return executed 66151 times by 2 tests: 7;return 7;Executed by:
executed 66151 times by 2 tests: return 7;Executed by:
| 66151 | ||||||||||||||||||
| 129 | case executed 63978 times by 2 tests: '8':case '8':Executed by:
executed 63978 times by 2 tests: case '8':Executed by:
| 63978 | ||||||||||||||||||
| 130 | return executed 63978 times by 2 tests: 8;return 8;Executed by:
executed 63978 times by 2 tests: return 8;Executed by:
| 63978 | ||||||||||||||||||
| 131 | case executed 65097 times by 2 tests: '9':case '9':Executed by:
executed 65097 times by 2 tests: case '9':Executed by:
| 65097 | ||||||||||||||||||
| 132 | return executed 65097 times by 2 tests: 9;return 9;Executed by:
executed 65097 times by 2 tests: return 9;Executed by:
| 65097 | ||||||||||||||||||
| 133 | case executed 61123 times by 2 tests: 'a':case 'a':Executed by:
executed 61123 times by 2 tests: casecase 'a':Executed by:
executed 5470 times by 2 tests: 'A':case 'A':Executed by:
executed 5470 times by 2 tests: case 'A':Executed by:
| 5470-61123 | ||||||||||||||||||
| 134 | return executed 66593 times by 2 tests: 0x0A;return 0x0A;Executed by:
executed 66593 times by 2 tests: return 0x0A;Executed by:
| 66593 | ||||||||||||||||||
| 135 | case executed 58044 times by 2 tests: 'b':case 'b':Executed by:
executed 58044 times by 2 tests: casecase 'b':Executed by:
executed 5647 times by 2 tests: 'B':case 'B':Executed by:
executed 5647 times by 2 tests: case 'B':Executed by:
| 5647-58044 | ||||||||||||||||||
| 136 | return executed 63691 times by 2 tests: 0x0B;return 0x0B;Executed by:
executed 63691 times by 2 tests: return 0x0B;Executed by:
| 63691 | ||||||||||||||||||
| 137 | case executed 60633 times by 2 tests: 'c':case 'c':Executed by:
executed 60633 times by 2 tests: casecase 'c':Executed by:
executed 5335 times by 2 tests: 'C':case 'C':Executed by:
executed 5335 times by 2 tests: case 'C':Executed by:
| 5335-60633 | ||||||||||||||||||
| 138 | return executed 65968 times by 2 tests: 0x0C;return 0x0C;Executed by:
executed 65968 times by 2 tests: return 0x0C;Executed by:
| 65968 | ||||||||||||||||||
| 139 | case executed 58883 times by 2 tests: 'd':case 'd':Executed by:
executed 58883 times by 2 tests: casecase 'd':Executed by:
executed 5608 times by 2 tests: 'D':case 'D':Executed by:
executed 5608 times by 2 tests: case 'D':Executed by:
| 5608-58883 | ||||||||||||||||||
| 140 | return executed 64491 times by 2 tests: 0x0D;return 0x0D;Executed by:
executed 64491 times by 2 tests: return 0x0D;Executed by:
| 64491 | ||||||||||||||||||
| 141 | case executed 59695 times by 2 tests: 'e':case 'e':Executed by:
executed 59695 times by 2 tests: casecase 'e':Executed by:
executed 5717 times by 2 tests: 'E':case 'E':Executed by:
executed 5717 times by 2 tests: case 'E':Executed by:
| 5717-59695 | ||||||||||||||||||
| 142 | return executed 65412 times by 2 tests: 0x0E;return 0x0E;Executed by:
executed 65412 times by 2 tests: return 0x0E;Executed by:
| 65412 | ||||||||||||||||||
| 143 | case executed 68533 times by 2 tests: 'f':case 'f':Executed by:
executed 68533 times by 2 tests: casecase 'f':Executed by:
executed 9686 times by 2 tests: 'F':case 'F':Executed by:
executed 9686 times by 2 tests: case 'F':Executed by:
| 9686-68533 | ||||||||||||||||||
| 144 | return executed 78219 times by 2 tests: 0x0F;return 0x0F;Executed by:
executed 78219 times by 2 tests: return 0x0F;Executed by:
| 78219 | ||||||||||||||||||
| 145 | } | - | ||||||||||||||||||
| 146 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 147 | } | - | ||||||||||||||||||
| 148 | - | |||||||||||||||||||
| 149 | - | |||||||||||||||||||
| 150 | - | |||||||||||||||||||
| 151 | - | |||||||||||||||||||
| 152 | unsigned char *OPENSSL_hexstr2buf(const char *str, long *len) | - | ||||||||||||||||||
| 153 | { | - | ||||||||||||||||||
| 154 | unsigned char *hexbuf, *q; | - | ||||||||||||||||||
| 155 | unsigned char ch, cl; | - | ||||||||||||||||||
| 156 | int chi, cli; | - | ||||||||||||||||||
| 157 | const unsigned char *p; | - | ||||||||||||||||||
| 158 | size_t s; | - | ||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | s = strlen(str); | - | ||||||||||||||||||
| 161 | if ((
| 0-3305 | ||||||||||||||||||
| 162 | ((void *)0)
| 0-3305 | ||||||||||||||||||
| 163 | ) { | - | ||||||||||||||||||
| 164 | ERR_put_error(15,(118),((1|64)),__FILE__,157); | - | ||||||||||||||||||
| 165 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 166 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 167 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 168 | } | - | ||||||||||||||||||
| 169 | for (p = (const unsigned char *)str, q = hexbuf; *
| 3305-185590 | ||||||||||||||||||
| 170 | ch = *p++; | - | ||||||||||||||||||
| 171 | if (ch == ':'
| 0-185590 | ||||||||||||||||||
| 172 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 173 | cl = *p++; | - | ||||||||||||||||||
| 174 | if (!cl
| 0-185590 | ||||||||||||||||||
| 175 | ERR_put_error(15,(118),(103),__FILE__,167) | - | ||||||||||||||||||
| 176 | ; | - | ||||||||||||||||||
| 177 | CRYPTO_free(hexbuf, __FILE__, 168); | - | ||||||||||||||||||
| 178 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 179 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 180 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 181 | } | - | ||||||||||||||||||
| 182 | cli = OPENSSL_hexchar2int(cl); | - | ||||||||||||||||||
| 183 | chi = OPENSSL_hexchar2int(ch); | - | ||||||||||||||||||
| 184 | if (cli < 0
| 0-185590 | ||||||||||||||||||
| 185 | CRYPTO_free(hexbuf, __FILE__, 174); | - | ||||||||||||||||||
| 186 | ERR_put_error(15,(118),(102),__FILE__,175); | - | ||||||||||||||||||
| 187 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 188 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 189 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 190 | } | - | ||||||||||||||||||
| 191 | *q++ = (unsigned char)((chi << 4) | cli); | - | ||||||||||||||||||
| 192 | } executed 185590 times by 2 tests: end of blockExecuted by:
| 185590 | ||||||||||||||||||
| 193 | - | |||||||||||||||||||
| 194 | if (len
| 26-3279 | ||||||||||||||||||
| 195 | * executed 3279 times by 1 test: len = q - hexbuf;*len = q - hexbuf;Executed by:
executed 3279 times by 1 test: *len = q - hexbuf;Executed by:
| 3279 | ||||||||||||||||||
| 196 | return executed 3305 times by 2 tests: hexbuf;return hexbuf;Executed by:
executed 3305 times by 2 tests: return hexbuf;Executed by:
| 3305 | ||||||||||||||||||
| 197 | } | - | ||||||||||||||||||
| 198 | - | |||||||||||||||||||
| 199 | - | |||||||||||||||||||
| 200 | - | |||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | - | |||||||||||||||||||
| 203 | - | |||||||||||||||||||
| 204 | char *OPENSSL_buf2hexstr(const unsigned char *buffer, long len) | - | ||||||||||||||||||
| 205 | { | - | ||||||||||||||||||
| 206 | static const char hexdig[] = "0123456789ABCDEF"; | - | ||||||||||||||||||
| 207 | char *tmp, *q; | - | ||||||||||||||||||
| 208 | const unsigned char *p; | - | ||||||||||||||||||
| 209 | int i; | - | ||||||||||||||||||
| 210 | - | |||||||||||||||||||
| 211 | if (len == 0
| 438-1212 | ||||||||||||||||||
| 212 | { | - | ||||||||||||||||||
| 213 | return executed 438 times by 1 test: CRYPTO_zalloc(1, __FILE__, 200);return CRYPTO_zalloc(1, __FILE__, 200);Executed by:
executed 438 times by 1 test: return CRYPTO_zalloc(1, __FILE__, 200);Executed by:
| 438 | ||||||||||||||||||
| 214 | } | - | ||||||||||||||||||
| 215 | - | |||||||||||||||||||
| 216 | if ((
| 0-1212 | ||||||||||||||||||
| 217 | ((void *)0)
| 0-1212 | ||||||||||||||||||
| 218 | ) { | - | ||||||||||||||||||
| 219 | ERR_put_error(15,(117),((1|64)),__FILE__,204); | - | ||||||||||||||||||
| 220 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 221 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 222 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 223 | } | - | ||||||||||||||||||
| 224 | q = tmp; | - | ||||||||||||||||||
| 225 | for (i = 0, p = buffer; i < len
| 1212-134911 | ||||||||||||||||||
| 226 | *q++ = hexdig[(*p >> 4) & 0xf]; | - | ||||||||||||||||||
| 227 | *q++ = hexdig[*p & 0xf]; | - | ||||||||||||||||||
| 228 | *q++ = ':'; | - | ||||||||||||||||||
| 229 | } executed 134911 times by 1 test: end of blockExecuted by:
| 134911 | ||||||||||||||||||
| 230 | q[-1] = 0; | - | ||||||||||||||||||
| 231 | - | |||||||||||||||||||
| 232 | - | |||||||||||||||||||
| 233 | - | |||||||||||||||||||
| 234 | - | |||||||||||||||||||
| 235 | return executed 1212 times by 1 test: tmp;return tmp;Executed by:
executed 1212 times by 1 test: return tmp;Executed by:
| 1212 | ||||||||||||||||||
| 236 | } | - | ||||||||||||||||||
| 237 | - | |||||||||||||||||||
| 238 | int openssl_strerror_r(int errnum, char *buf, size_t buflen) | - | ||||||||||||||||||
| 239 | { | - | ||||||||||||||||||
| 240 | return executed 263398 times by 11 tests: !strerror_r(errnum, buf, buflen);return !strerror_r(errnum, buf, buflen);Executed by:
executed 263398 times by 11 tests: return !strerror_r(errnum, buf, buflen);Executed by:
| 263398 | ||||||||||||||||||
| 241 | } | - | ||||||||||||||||||
| Switch to Source code | Preprocessed file |