| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/x509/x509name.c |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /* | - | ||||||||||||||||||
| 2 | * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. | - | ||||||||||||||||||
| 3 | * | - | ||||||||||||||||||
| 4 | * Licensed under the OpenSSL license (the "License"). You may not use | - | ||||||||||||||||||
| 5 | * this file except in compliance with the License. You can obtain a copy | - | ||||||||||||||||||
| 6 | * in the file LICENSE in the source distribution or at | - | ||||||||||||||||||
| 7 | * https://www.openssl.org/source/license.html | - | ||||||||||||||||||
| 8 | */ | - | ||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | #include <stdio.h> | - | ||||||||||||||||||
| 11 | #include "internal/cryptlib.h" | - | ||||||||||||||||||
| 12 | #include <openssl/safestack.h> | - | ||||||||||||||||||
| 13 | #include <openssl/asn1.h> | - | ||||||||||||||||||
| 14 | #include <openssl/objects.h> | - | ||||||||||||||||||
| 15 | #include <openssl/evp.h> | - | ||||||||||||||||||
| 16 | #include <openssl/x509.h> | - | ||||||||||||||||||
| 17 | #include "internal/x509_int.h" | - | ||||||||||||||||||
| 18 | - | |||||||||||||||||||
| 19 | int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len) | - | ||||||||||||||||||
| 20 | { | - | ||||||||||||||||||
| 21 | ASN1_OBJECT *obj; | - | ||||||||||||||||||
| 22 | - | |||||||||||||||||||
| 23 | obj = OBJ_nid2obj(nid); | - | ||||||||||||||||||
| 24 | if (obj == NULL)
| 0 | ||||||||||||||||||
| 25 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
| 26 | return X509_NAME_get_text_by_OBJ(name, obj, buf, len); never executed: return X509_NAME_get_text_by_OBJ(name, obj, buf, len); | 0 | ||||||||||||||||||
| 27 | } | - | ||||||||||||||||||
| 28 | - | |||||||||||||||||||
| 29 | int X509_NAME_get_text_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, | - | ||||||||||||||||||
| 30 | char *buf, int len) | - | ||||||||||||||||||
| 31 | { | - | ||||||||||||||||||
| 32 | int i; | - | ||||||||||||||||||
| 33 | const ASN1_STRING *data; | - | ||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | i = X509_NAME_get_index_by_OBJ(name, obj, -1); | - | ||||||||||||||||||
| 36 | if (i < 0)
| 0 | ||||||||||||||||||
| 37 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
| 38 | data = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name, i)); | - | ||||||||||||||||||
| 39 | if (buf == NULL)
| 0 | ||||||||||||||||||
| 40 | return data->length; never executed: return data->length; | 0 | ||||||||||||||||||
| 41 | if (len <= 0)
| 0 | ||||||||||||||||||
| 42 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 43 | i = (data->length > (len - 1)) ? (len - 1) : data->length;
| 0 | ||||||||||||||||||
| 44 | memcpy(buf, data->data, i); | - | ||||||||||||||||||
| 45 | buf[i] = '\0'; | - | ||||||||||||||||||
| 46 | return i; never executed: return i; | 0 | ||||||||||||||||||
| 47 | } | - | ||||||||||||||||||
| 48 | - | |||||||||||||||||||
| 49 | int X509_NAME_entry_count(const X509_NAME *name) | - | ||||||||||||||||||
| 50 | { | - | ||||||||||||||||||
| 51 | if (name == NULL)
| 0-7276 | ||||||||||||||||||
| 52 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 53 | return sk_X509_NAME_ENTRY_num(name->entries); executed 7276 times by 1 test: return sk_X509_NAME_ENTRY_num(name->entries);Executed by:
| 7276 | ||||||||||||||||||
| 54 | } | - | ||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | int X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos) | - | ||||||||||||||||||
| 57 | { | - | ||||||||||||||||||
| 58 | ASN1_OBJECT *obj; | - | ||||||||||||||||||
| 59 | - | |||||||||||||||||||
| 60 | obj = OBJ_nid2obj(nid); | - | ||||||||||||||||||
| 61 | if (obj == NULL)
| 0-124210 | ||||||||||||||||||
| 62 | return -2; never executed: return -2; | 0 | ||||||||||||||||||
| 63 | return X509_NAME_get_index_by_OBJ(name, obj, lastpos); executed 124210 times by 1 test: return X509_NAME_get_index_by_OBJ(name, obj, lastpos);Executed by:
| 124210 | ||||||||||||||||||
| 64 | } | - | ||||||||||||||||||
| 65 | - | |||||||||||||||||||
| 66 | /* NOTE: you should be passing -1, not 0 as lastpos */ | - | ||||||||||||||||||
| 67 | int X509_NAME_get_index_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int lastpos) | - | ||||||||||||||||||
| 68 | { | - | ||||||||||||||||||
| 69 | int n; | - | ||||||||||||||||||
| 70 | X509_NAME_ENTRY *ne; | - | ||||||||||||||||||
| 71 | STACK_OF(X509_NAME_ENTRY) *sk; | - | ||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | if (name == NULL)
| 0-124231 | ||||||||||||||||||
| 74 | return -1; never executed: return -1; | 0 | ||||||||||||||||||
| 75 | if (lastpos < 0)
| 53961-70270 | ||||||||||||||||||
| 76 | lastpos = -1; executed 70270 times by 1 test: lastpos = -1;Executed by:
| 70270 | ||||||||||||||||||
| 77 | sk = name->entries; | - | ||||||||||||||||||
| 78 | n = sk_X509_NAME_ENTRY_num(sk); | - | ||||||||||||||||||
| 79 | for (lastpos++; lastpos < n; lastpos++) {
| 69521-109246 | ||||||||||||||||||
| 80 | ne = sk_X509_NAME_ENTRY_value(sk, lastpos); | - | ||||||||||||||||||
| 81 | if (OBJ_cmp(ne->object, obj) == 0)
| 54536-54710 | ||||||||||||||||||
| 82 | return lastpos; executed 54710 times by 1 test: return lastpos;Executed by:
| 54710 | ||||||||||||||||||
| 83 | } executed 54536 times by 1 test: end of blockExecuted by:
| 54536 | ||||||||||||||||||
| 84 | return -1; executed 69521 times by 1 test: return -1;Executed by:
| 69521 | ||||||||||||||||||
| 85 | } | - | ||||||||||||||||||
| 86 | - | |||||||||||||||||||
| 87 | X509_NAME_ENTRY *X509_NAME_get_entry(const X509_NAME *name, int loc) | - | ||||||||||||||||||
| 88 | { | - | ||||||||||||||||||
| 89 | if (name == NULL || sk_X509_NAME_ENTRY_num(name->entries) <= loc
| 0-69967 | ||||||||||||||||||
| 90 | || loc < 0)
| 0-69967 | ||||||||||||||||||
| 91 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 92 | - | |||||||||||||||||||
| 93 | return sk_X509_NAME_ENTRY_value(name->entries, loc); executed 69967 times by 1 test: return sk_X509_NAME_ENTRY_value(name->entries, loc);Executed by:
| 69967 | ||||||||||||||||||
| 94 | } | - | ||||||||||||||||||
| 95 | - | |||||||||||||||||||
| 96 | X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc) | - | ||||||||||||||||||
| 97 | { | - | ||||||||||||||||||
| 98 | X509_NAME_ENTRY *ret; | - | ||||||||||||||||||
| 99 | int i, n, set_prev, set_next; | - | ||||||||||||||||||
| 100 | STACK_OF(X509_NAME_ENTRY) *sk; | - | ||||||||||||||||||
| 101 | - | |||||||||||||||||||
| 102 | if (name == NULL || sk_X509_NAME_ENTRY_num(name->entries) <= loc
| 0-6 | ||||||||||||||||||
| 103 | || loc < 0)
| 0-6 | ||||||||||||||||||
| 104 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 105 | - | |||||||||||||||||||
| 106 | sk = name->entries; | - | ||||||||||||||||||
| 107 | ret = sk_X509_NAME_ENTRY_delete(sk, loc); | - | ||||||||||||||||||
| 108 | n = sk_X509_NAME_ENTRY_num(sk); | - | ||||||||||||||||||
| 109 | name->modified = 1; | - | ||||||||||||||||||
| 110 | if (loc == n)
| 0-6 | ||||||||||||||||||
| 111 | return ret; executed 6 times by 1 test: return ret;Executed by:
| 6 | ||||||||||||||||||
| 112 | - | |||||||||||||||||||
| 113 | /* else we need to fixup the set field */ | - | ||||||||||||||||||
| 114 | if (loc != 0)
| 0 | ||||||||||||||||||
| 115 | set_prev = (sk_X509_NAME_ENTRY_value(sk, loc - 1))->set; never executed: set_prev = (sk_X509_NAME_ENTRY_value(sk, loc - 1))->set; | 0 | ||||||||||||||||||
| 116 | else | - | ||||||||||||||||||
| 117 | set_prev = ret->set - 1; never executed: set_prev = ret->set - 1; | 0 | ||||||||||||||||||
| 118 | set_next = sk_X509_NAME_ENTRY_value(sk, loc)->set; | - | ||||||||||||||||||
| 119 | - | |||||||||||||||||||
| 120 | /*- | - | ||||||||||||||||||
| 121 | * set_prev is the previous set | - | ||||||||||||||||||
| 122 | * set is the current set | - | ||||||||||||||||||
| 123 | * set_next is the following | - | ||||||||||||||||||
| 124 | * prev 1 1 1 1 1 1 1 1 | - | ||||||||||||||||||
| 125 | * set 1 1 2 2 | - | ||||||||||||||||||
| 126 | * next 1 1 2 2 2 2 3 2 | - | ||||||||||||||||||
| 127 | * so basically only if prev and next differ by 2, then | - | ||||||||||||||||||
| 128 | * re-number down by 1 | - | ||||||||||||||||||
| 129 | */ | - | ||||||||||||||||||
| 130 | if (set_prev + 1 < set_next)
| 0 | ||||||||||||||||||
| 131 | for (i = loc; i < n; i++)
| 0 | ||||||||||||||||||
| 132 | sk_X509_NAME_ENTRY_value(sk, i)->set--; never executed: sk_X509_NAME_ENTRY_value(sk, i)->set--; | 0 | ||||||||||||||||||
| 133 | return ret; never executed: return ret; | 0 | ||||||||||||||||||
| 134 | } | - | ||||||||||||||||||
| 135 | - | |||||||||||||||||||
| 136 | int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type, | - | ||||||||||||||||||
| 137 | const unsigned char *bytes, int len, int loc, | - | ||||||||||||||||||
| 138 | int set) | - | ||||||||||||||||||
| 139 | { | - | ||||||||||||||||||
| 140 | X509_NAME_ENTRY *ne; | - | ||||||||||||||||||
| 141 | int ret; | - | ||||||||||||||||||
| 142 | - | |||||||||||||||||||
| 143 | ne = X509_NAME_ENTRY_create_by_OBJ(NULL, obj, type, bytes, len); | - | ||||||||||||||||||
| 144 | if (!ne)
| 0 | ||||||||||||||||||
| 145 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 146 | ret = X509_NAME_add_entry(name, ne, loc, set); | - | ||||||||||||||||||
| 147 | X509_NAME_ENTRY_free(ne); | - | ||||||||||||||||||
| 148 | return ret; never executed: return ret; | 0 | ||||||||||||||||||
| 149 | } | - | ||||||||||||||||||
| 150 | - | |||||||||||||||||||
| 151 | int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, | - | ||||||||||||||||||
| 152 | const unsigned char *bytes, int len, int loc, | - | ||||||||||||||||||
| 153 | int set) | - | ||||||||||||||||||
| 154 | { | - | ||||||||||||||||||
| 155 | X509_NAME_ENTRY *ne; | - | ||||||||||||||||||
| 156 | int ret; | - | ||||||||||||||||||
| 157 | ne = X509_NAME_ENTRY_create_by_NID(NULL, nid, type, bytes, len); | - | ||||||||||||||||||
| 158 | if (!ne)
| 0-745 | ||||||||||||||||||
| 159 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 160 | ret = X509_NAME_add_entry(name, ne, loc, set); | - | ||||||||||||||||||
| 161 | X509_NAME_ENTRY_free(ne); | - | ||||||||||||||||||
| 162 | return ret; executed 745 times by 1 test: return ret;Executed by:
| 745 | ||||||||||||||||||
| 163 | } | - | ||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, | - | ||||||||||||||||||
| 166 | const unsigned char *bytes, int len, int loc, | - | ||||||||||||||||||
| 167 | int set) | - | ||||||||||||||||||
| 168 | { | - | ||||||||||||||||||
| 169 | X509_NAME_ENTRY *ne; | - | ||||||||||||||||||
| 170 | int ret; | - | ||||||||||||||||||
| 171 | ne = X509_NAME_ENTRY_create_by_txt(NULL, field, type, bytes, len); | - | ||||||||||||||||||
| 172 | if (!ne)
| 0-20 | ||||||||||||||||||
| 173 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 174 | ret = X509_NAME_add_entry(name, ne, loc, set); | - | ||||||||||||||||||
| 175 | X509_NAME_ENTRY_free(ne); | - | ||||||||||||||||||
| 176 | return ret; executed 20 times by 1 test: return ret;Executed by:
| 20 | ||||||||||||||||||
| 177 | } | - | ||||||||||||||||||
| 178 | - | |||||||||||||||||||
| 179 | /* | - | ||||||||||||||||||
| 180 | * if set is -1, append to previous set, 0 'a new one', and 1, prepend to the | - | ||||||||||||||||||
| 181 | * guy we are about to stomp on. | - | ||||||||||||||||||
| 182 | */ | - | ||||||||||||||||||
| 183 | int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc, | - | ||||||||||||||||||
| 184 | int set) | - | ||||||||||||||||||
| 185 | { | - | ||||||||||||||||||
| 186 | X509_NAME_ENTRY *new_name = NULL; | - | ||||||||||||||||||
| 187 | int n, i, inc; | - | ||||||||||||||||||
| 188 | STACK_OF(X509_NAME_ENTRY) *sk; | - | ||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | if (name == NULL)
| 0-19686 | ||||||||||||||||||
| 191 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 192 | sk = name->entries; | - | ||||||||||||||||||
| 193 | n = sk_X509_NAME_ENTRY_num(sk); | - | ||||||||||||||||||
| 194 | if (loc > n)
| 0-19686 | ||||||||||||||||||
| 195 | loc = n; never executed: loc = n; | 0 | ||||||||||||||||||
| 196 | else if (loc < 0)
| 0-19686 | ||||||||||||||||||
| 197 | loc = n; executed 19686 times by 1 test: loc = n;Executed by:
| 19686 | ||||||||||||||||||
| 198 | inc = (set == 0); | - | ||||||||||||||||||
| 199 | name->modified = 1; | - | ||||||||||||||||||
| 200 | - | |||||||||||||||||||
| 201 | if (set == -1) {
| 0-19686 | ||||||||||||||||||
| 202 | if (loc == 0) {
| 0 | ||||||||||||||||||
| 203 | set = 0; | - | ||||||||||||||||||
| 204 | inc = 1; | - | ||||||||||||||||||
| 205 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 206 | set = sk_X509_NAME_ENTRY_value(sk, loc - 1)->set; | - | ||||||||||||||||||
| 207 | } never executed: end of block | 0 | ||||||||||||||||||
| 208 | } else { /* if (set >= 0) */ | - | ||||||||||||||||||
| 209 | - | |||||||||||||||||||
| 210 | if (loc >= n) {
| 0-19686 | ||||||||||||||||||
| 211 | if (loc != 0)
| 4431-15255 | ||||||||||||||||||
| 212 | set = sk_X509_NAME_ENTRY_value(sk, loc - 1)->set + 1; executed 15255 times by 1 test: set = sk_X509_NAME_ENTRY_value(sk, loc - 1)->set + 1;Executed by:
| 15255 | ||||||||||||||||||
| 213 | else | - | ||||||||||||||||||
| 214 | set = 0; executed 4431 times by 1 test: set = 0;Executed by:
| 4431 | ||||||||||||||||||
| 215 | } else | - | ||||||||||||||||||
| 216 | set = sk_X509_NAME_ENTRY_value(sk, loc)->set; never executed: set = sk_X509_NAME_ENTRY_value(sk, loc)->set; | 0 | ||||||||||||||||||
| 217 | } | - | ||||||||||||||||||
| 218 | - | |||||||||||||||||||
| 219 | /* | - | ||||||||||||||||||
| 220 | * X509_NAME_ENTRY_dup is ASN1 generated code, that can't be easily | - | ||||||||||||||||||
| 221 | * const'ified; harmless cast since dup() don't modify its input. | - | ||||||||||||||||||
| 222 | */ | - | ||||||||||||||||||
| 223 | if ((new_name = X509_NAME_ENTRY_dup((X509_NAME_ENTRY *)ne)) == NULL)
| 399-19287 | ||||||||||||||||||
| 224 | goto err; executed 399 times by 1 test: goto err;Executed by:
| 399 | ||||||||||||||||||
| 225 | new_name->set = set; | - | ||||||||||||||||||
| 226 | if (!sk_X509_NAME_ENTRY_insert(sk, new_name, loc)) {
| 0-19287 | ||||||||||||||||||
| 227 | X509err(X509_F_X509_NAME_ADD_ENTRY, ERR_R_MALLOC_FAILURE); | - | ||||||||||||||||||
| 228 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 229 | } | - | ||||||||||||||||||
| 230 | if (inc) {
| 4842-14445 | ||||||||||||||||||
| 231 | n = sk_X509_NAME_ENTRY_num(sk); | - | ||||||||||||||||||
| 232 | for (i = loc + 1; i < n; i++)
| 0-14445 | ||||||||||||||||||
| 233 | sk_X509_NAME_ENTRY_value(sk, i)->set += 1; never executed: sk_X509_NAME_ENTRY_value(sk, i)->set += 1; | 0 | ||||||||||||||||||
| 234 | } executed 14445 times by 1 test: end of blockExecuted by:
| 14445 | ||||||||||||||||||
| 235 | return 1; executed 19287 times by 1 test: return 1;Executed by:
| 19287 | ||||||||||||||||||
| 236 | err: | - | ||||||||||||||||||
| 237 | X509_NAME_ENTRY_free(new_name); | - | ||||||||||||||||||
| 238 | return 0; executed 399 times by 1 test: return 0;Executed by:
| 399 | ||||||||||||||||||
| 239 | } | - | ||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, | - | ||||||||||||||||||
| 242 | const char *field, int type, | - | ||||||||||||||||||
| 243 | const unsigned char *bytes, | - | ||||||||||||||||||
| 244 | int len) | - | ||||||||||||||||||
| 245 | { | - | ||||||||||||||||||
| 246 | ASN1_OBJECT *obj; | - | ||||||||||||||||||
| 247 | X509_NAME_ENTRY *nentry; | - | ||||||||||||||||||
| 248 | - | |||||||||||||||||||
| 249 | obj = OBJ_txt2obj(field, 0); | - | ||||||||||||||||||
| 250 | if (obj == NULL) {
| 0-20 | ||||||||||||||||||
| 251 | X509err(X509_F_X509_NAME_ENTRY_CREATE_BY_TXT, | - | ||||||||||||||||||
| 252 | X509_R_INVALID_FIELD_NAME); | - | ||||||||||||||||||
| 253 | ERR_add_error_data(2, "name=", field); | - | ||||||||||||||||||
| 254 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 255 | } | - | ||||||||||||||||||
| 256 | nentry = X509_NAME_ENTRY_create_by_OBJ(ne, obj, type, bytes, len); | - | ||||||||||||||||||
| 257 | ASN1_OBJECT_free(obj); | - | ||||||||||||||||||
| 258 | return nentry; executed 20 times by 1 test: return nentry;Executed by:
| 20 | ||||||||||||||||||
| 259 | } | - | ||||||||||||||||||
| 260 | - | |||||||||||||||||||
| 261 | X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, | - | ||||||||||||||||||
| 262 | int type, | - | ||||||||||||||||||
| 263 | const unsigned char *bytes, | - | ||||||||||||||||||
| 264 | int len) | - | ||||||||||||||||||
| 265 | { | - | ||||||||||||||||||
| 266 | ASN1_OBJECT *obj; | - | ||||||||||||||||||
| 267 | X509_NAME_ENTRY *nentry; | - | ||||||||||||||||||
| 268 | - | |||||||||||||||||||
| 269 | obj = OBJ_nid2obj(nid); | - | ||||||||||||||||||
| 270 | if (obj == NULL) {
| 0-745 | ||||||||||||||||||
| 271 | X509err(X509_F_X509_NAME_ENTRY_CREATE_BY_NID, X509_R_UNKNOWN_NID); | - | ||||||||||||||||||
| 272 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 273 | } | - | ||||||||||||||||||
| 274 | nentry = X509_NAME_ENTRY_create_by_OBJ(ne, obj, type, bytes, len); | - | ||||||||||||||||||
| 275 | ASN1_OBJECT_free(obj); | - | ||||||||||||||||||
| 276 | return nentry; executed 745 times by 1 test: return nentry;Executed by:
| 745 | ||||||||||||||||||
| 277 | } | - | ||||||||||||||||||
| 278 | - | |||||||||||||||||||
| 279 | X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, | - | ||||||||||||||||||
| 280 | const ASN1_OBJECT *obj, int type, | - | ||||||||||||||||||
| 281 | const unsigned char *bytes, | - | ||||||||||||||||||
| 282 | int len) | - | ||||||||||||||||||
| 283 | { | - | ||||||||||||||||||
| 284 | X509_NAME_ENTRY *ret; | - | ||||||||||||||||||
| 285 | - | |||||||||||||||||||
| 286 | if ((ne == NULL) || (*ne == NULL)) {
| 0-765 | ||||||||||||||||||
| 287 | if ((ret = X509_NAME_ENTRY_new()) == NULL)
| 0-765 | ||||||||||||||||||
| 288 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 289 | } else executed 765 times by 1 test: end of blockExecuted by:
| 765 | ||||||||||||||||||
| 290 | ret = *ne; never executed: ret = *ne; | 0 | ||||||||||||||||||
| 291 | - | |||||||||||||||||||
| 292 | if (!X509_NAME_ENTRY_set_object(ret, obj))
| 0-765 | ||||||||||||||||||
| 293 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 294 | if (!X509_NAME_ENTRY_set_data(ret, type, bytes, len))
| 0-765 | ||||||||||||||||||
| 295 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 296 | - | |||||||||||||||||||
| 297 | if ((ne != NULL) && (*ne == NULL))
| 0-765 | ||||||||||||||||||
| 298 | *ne = ret; never executed: *ne = ret; | 0 | ||||||||||||||||||
| 299 | return ret; executed 765 times by 1 test: return ret;Executed by:
| 765 | ||||||||||||||||||
| 300 | err: | - | ||||||||||||||||||
| 301 | if ((ne == NULL) || (ret != *ne))
| 0 | ||||||||||||||||||
| 302 | X509_NAME_ENTRY_free(ret); never executed: X509_NAME_ENTRY_free(ret); | 0 | ||||||||||||||||||
| 303 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 304 | } | - | ||||||||||||||||||
| 305 | - | |||||||||||||||||||
| 306 | int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, const ASN1_OBJECT *obj) | - | ||||||||||||||||||
| 307 | { | - | ||||||||||||||||||
| 308 | if ((ne == NULL) || (obj == NULL)) {
| 0-765 | ||||||||||||||||||
| 309 | X509err(X509_F_X509_NAME_ENTRY_SET_OBJECT, | - | ||||||||||||||||||
| 310 | ERR_R_PASSED_NULL_PARAMETER); | - | ||||||||||||||||||
| 311 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 312 | } | - | ||||||||||||||||||
| 313 | ASN1_OBJECT_free(ne->object); | - | ||||||||||||||||||
| 314 | ne->object = OBJ_dup(obj); | - | ||||||||||||||||||
| 315 | return ((ne->object == NULL) ? 0 : 1); executed 765 times by 1 test: return ((ne->object == ((void *)0) ) ? 0 : 1);Executed by:
| 0-765 | ||||||||||||||||||
| 316 | } | - | ||||||||||||||||||
| 317 | - | |||||||||||||||||||
| 318 | int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, | - | ||||||||||||||||||
| 319 | const unsigned char *bytes, int len) | - | ||||||||||||||||||
| 320 | { | - | ||||||||||||||||||
| 321 | int i; | - | ||||||||||||||||||
| 322 | - | |||||||||||||||||||
| 323 | if ((ne == NULL) || ((bytes == NULL) && (len != 0)))
| 0-765 | ||||||||||||||||||
| 324 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 325 | if ((type > 0) && (type & MBSTRING_FLAG))
| 0-765 | ||||||||||||||||||
| 326 | return ASN1_STRING_set_by_NID(&ne->value, bytes, executed 765 times by 1 test: return ASN1_STRING_set_by_NID(&ne->value, bytes, len, type, OBJ_obj2nid(ne->object)) ? 1 : 0;Executed by:
| 0-765 | ||||||||||||||||||
| 327 | len, type, executed 765 times by 1 test: return ASN1_STRING_set_by_NID(&ne->value, bytes, len, type, OBJ_obj2nid(ne->object)) ? 1 : 0;Executed by:
| 0-765 | ||||||||||||||||||
| 328 | OBJ_obj2nid(ne->object)) ? 1 : 0; executed 765 times by 1 test: return ASN1_STRING_set_by_NID(&ne->value, bytes, len, type, OBJ_obj2nid(ne->object)) ? 1 : 0;Executed by:
| 0-765 | ||||||||||||||||||
| 329 | if (len < 0)
| 0 | ||||||||||||||||||
| 330 | len = strlen((const char *)bytes); never executed: len = strlen((const char *)bytes); | 0 | ||||||||||||||||||
| 331 | i = ASN1_STRING_set(ne->value, bytes, len); | - | ||||||||||||||||||
| 332 | if (!i)
| 0 | ||||||||||||||||||
| 333 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 334 | if (type != V_ASN1_UNDEF) {
| 0 | ||||||||||||||||||
| 335 | if (type == V_ASN1_APP_CHOOSE)
| 0 | ||||||||||||||||||
| 336 | ne->value->type = ASN1_PRINTABLE_type(bytes, len); never executed: ne->value->type = ASN1_PRINTABLE_type(bytes, len); | 0 | ||||||||||||||||||
| 337 | else | - | ||||||||||||||||||
| 338 | ne->value->type = type; never executed: ne->value->type = type; | 0 | ||||||||||||||||||
| 339 | } | - | ||||||||||||||||||
| 340 | return 1; never executed: return 1; | 0 | ||||||||||||||||||
| 341 | } | - | ||||||||||||||||||
| 342 | - | |||||||||||||||||||
| 343 | ASN1_OBJECT *X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne) | - | ||||||||||||||||||
| 344 | { | - | ||||||||||||||||||
| 345 | if (ne == NULL)
| 0-15251 | ||||||||||||||||||
| 346 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 347 | return ne->object; executed 15251 times by 1 test: return ne->object;Executed by:
| 15251 | ||||||||||||||||||
| 348 | } | - | ||||||||||||||||||
| 349 | - | |||||||||||||||||||
| 350 | ASN1_STRING *X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne) | - | ||||||||||||||||||
| 351 | { | - | ||||||||||||||||||
| 352 | if (ne == NULL)
| 0-69948 | ||||||||||||||||||
| 353 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 354 | return ne->value; executed 69948 times by 1 test: return ne->value;Executed by:
| 69948 | ||||||||||||||||||
| 355 | } | - | ||||||||||||||||||
| 356 | - | |||||||||||||||||||
| 357 | int X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne) | - | ||||||||||||||||||
| 358 | { | - | ||||||||||||||||||
| 359 | return ne->set; executed 25596 times by 1 test: return ne->set;Executed by:
| 25596 | ||||||||||||||||||
| 360 | } | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |