| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/x509/x509_att.c |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /* | - | ||||||||||||||||||
| 2 | * Copyright 1995-2017 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 <openssl/x509v3.h> | - | ||||||||||||||||||
| 18 | #include "x509_lcl.h" | - | ||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x) | - | ||||||||||||||||||
| 21 | { | - | ||||||||||||||||||
| 22 | return sk_X509_ATTRIBUTE_num(x); executed 192 times by 1 test: return sk_X509_ATTRIBUTE_num(x);Executed by:
| 192 | ||||||||||||||||||
| 23 | } | - | ||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid, | - | ||||||||||||||||||
| 26 | int lastpos) | - | ||||||||||||||||||
| 27 | { | - | ||||||||||||||||||
| 28 | const ASN1_OBJECT *obj = OBJ_nid2obj(nid); | - | ||||||||||||||||||
| 29 | - | |||||||||||||||||||
| 30 | if (obj == NULL)
| 0-119 | ||||||||||||||||||
| 31 | return -2; never executed: return -2; | 0 | ||||||||||||||||||
| 32 | return X509at_get_attr_by_OBJ(x, obj, lastpos); executed 119 times by 1 test: return X509at_get_attr_by_OBJ(x, obj, lastpos);Executed by:
| 119 | ||||||||||||||||||
| 33 | } | - | ||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, | - | ||||||||||||||||||
| 36 | const ASN1_OBJECT *obj, int lastpos) | - | ||||||||||||||||||
| 37 | { | - | ||||||||||||||||||
| 38 | int n; | - | ||||||||||||||||||
| 39 | X509_ATTRIBUTE *ex; | - | ||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | if (sk == NULL)
| 20-221 | ||||||||||||||||||
| 42 | return -1; executed 20 times by 1 test: return -1;Executed by:
| 20 | ||||||||||||||||||
| 43 | lastpos++; | - | ||||||||||||||||||
| 44 | if (lastpos < 0)
| 61-160 | ||||||||||||||||||
| 45 | lastpos = 0; executed 61 times by 1 test: lastpos = 0;Executed by:
| 61 | ||||||||||||||||||
| 46 | n = sk_X509_ATTRIBUTE_num(sk); | - | ||||||||||||||||||
| 47 | for (; lastpos < n; lastpos++) {
| 137-510 | ||||||||||||||||||
| 48 | ex = sk_X509_ATTRIBUTE_value(sk, lastpos); | - | ||||||||||||||||||
| 49 | if (OBJ_cmp(ex->object, obj) == 0)
| 84-426 | ||||||||||||||||||
| 50 | return lastpos; executed 84 times by 1 test: return lastpos;Executed by:
| 84 | ||||||||||||||||||
| 51 | } executed 426 times by 1 test: end of blockExecuted by:
| 426 | ||||||||||||||||||
| 52 | return -1; executed 137 times by 1 test: return -1;Executed by:
| 137 | ||||||||||||||||||
| 53 | } | - | ||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc) | - | ||||||||||||||||||
| 56 | { | - | ||||||||||||||||||
| 57 | if (x == NULL || sk_X509_ATTRIBUTE_num(x) <= loc || loc < 0)
| 0-104 | ||||||||||||||||||
| 58 | return NULL; executed 39 times by 1 test: return ((void *)0) ;Executed by:
| 39 | ||||||||||||||||||
| 59 | - | |||||||||||||||||||
| 60 | return sk_X509_ATTRIBUTE_value(x, loc); executed 85 times by 1 test: return sk_X509_ATTRIBUTE_value(x, loc);Executed by:
| 85 | ||||||||||||||||||
| 61 | } | - | ||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc) | - | ||||||||||||||||||
| 64 | { | - | ||||||||||||||||||
| 65 | X509_ATTRIBUTE *ret; | - | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | if (x == NULL || sk_X509_ATTRIBUTE_num(x) <= loc || loc < 0)
| 0 | ||||||||||||||||||
| 68 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 69 | ret = sk_X509_ATTRIBUTE_delete(x, loc); | - | ||||||||||||||||||
| 70 | return ret; never executed: return ret; | 0 | ||||||||||||||||||
| 71 | } | - | ||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x, | - | ||||||||||||||||||
| 74 | X509_ATTRIBUTE *attr) | - | ||||||||||||||||||
| 75 | { | - | ||||||||||||||||||
| 76 | X509_ATTRIBUTE *new_attr = NULL; | - | ||||||||||||||||||
| 77 | STACK_OF(X509_ATTRIBUTE) *sk = NULL; | - | ||||||||||||||||||
| 78 | - | |||||||||||||||||||
| 79 | if (x == NULL) {
| 0-209 | ||||||||||||||||||
| 80 | X509err(X509_F_X509AT_ADD1_ATTR, ERR_R_PASSED_NULL_PARAMETER); | - | ||||||||||||||||||
| 81 | goto err2; never executed: goto err2; | 0 | ||||||||||||||||||
| 82 | } | - | ||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | if (*x == NULL) {
| 0-209 | ||||||||||||||||||
| 85 | if ((sk = sk_X509_ATTRIBUTE_new_null()) == NULL)
| 0 | ||||||||||||||||||
| 86 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 87 | } else never executed: end of block | 0 | ||||||||||||||||||
| 88 | sk = *x; executed 209 times by 1 test: sk = *x;Executed by:
| 209 | ||||||||||||||||||
| 89 | - | |||||||||||||||||||
| 90 | if ((new_attr = X509_ATTRIBUTE_dup(attr)) == NULL)
| 0-209 | ||||||||||||||||||
| 91 | goto err2; never executed: goto err2; | 0 | ||||||||||||||||||
| 92 | if (!sk_X509_ATTRIBUTE_push(sk, new_attr))
| 0-209 | ||||||||||||||||||
| 93 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 94 | if (*x == NULL)
| 0-209 | ||||||||||||||||||
| 95 | *x = sk; never executed: *x = sk; | 0 | ||||||||||||||||||
| 96 | return sk; executed 209 times by 1 test: return sk;Executed by:
| 209 | ||||||||||||||||||
| 97 | err: | - | ||||||||||||||||||
| 98 | X509err(X509_F_X509AT_ADD1_ATTR, ERR_R_MALLOC_FAILURE); | - | ||||||||||||||||||
| 99 | err2: code before this statement never executed: err2: | 0 | ||||||||||||||||||
| 100 | X509_ATTRIBUTE_free(new_attr); | - | ||||||||||||||||||
| 101 | sk_X509_ATTRIBUTE_free(sk); | - | ||||||||||||||||||
| 102 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 103 | } | - | ||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) | - | ||||||||||||||||||
| 106 | **x, const ASN1_OBJECT *obj, | - | ||||||||||||||||||
| 107 | int type, | - | ||||||||||||||||||
| 108 | const unsigned char *bytes, | - | ||||||||||||||||||
| 109 | int len) | - | ||||||||||||||||||
| 110 | { | - | ||||||||||||||||||
| 111 | X509_ATTRIBUTE *attr; | - | ||||||||||||||||||
| 112 | STACK_OF(X509_ATTRIBUTE) *ret; | - | ||||||||||||||||||
| 113 | attr = X509_ATTRIBUTE_create_by_OBJ(NULL, obj, type, bytes, len); | - | ||||||||||||||||||
| 114 | if (!attr)
| 0 | ||||||||||||||||||
| 115 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 116 | ret = X509at_add1_attr(x, attr); | - | ||||||||||||||||||
| 117 | X509_ATTRIBUTE_free(attr); | - | ||||||||||||||||||
| 118 | return ret; never executed: return ret; | 0 | ||||||||||||||||||
| 119 | } | - | ||||||||||||||||||
| 120 | - | |||||||||||||||||||
| 121 | STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) | - | ||||||||||||||||||
| 122 | **x, int nid, int type, | - | ||||||||||||||||||
| 123 | const unsigned char *bytes, | - | ||||||||||||||||||
| 124 | int len) | - | ||||||||||||||||||
| 125 | { | - | ||||||||||||||||||
| 126 | X509_ATTRIBUTE *attr; | - | ||||||||||||||||||
| 127 | STACK_OF(X509_ATTRIBUTE) *ret; | - | ||||||||||||||||||
| 128 | attr = X509_ATTRIBUTE_create_by_NID(NULL, nid, type, bytes, len); | - | ||||||||||||||||||
| 129 | if (!attr)
| 0-209 | ||||||||||||||||||
| 130 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 131 | ret = X509at_add1_attr(x, attr); | - | ||||||||||||||||||
| 132 | X509_ATTRIBUTE_free(attr); | - | ||||||||||||||||||
| 133 | return ret; executed 209 times by 1 test: return ret;Executed by:
| 209 | ||||||||||||||||||
| 134 | } | - | ||||||||||||||||||
| 135 | - | |||||||||||||||||||
| 136 | STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) | - | ||||||||||||||||||
| 137 | **x, const char *attrname, | - | ||||||||||||||||||
| 138 | int type, | - | ||||||||||||||||||
| 139 | const unsigned char *bytes, | - | ||||||||||||||||||
| 140 | int len) | - | ||||||||||||||||||
| 141 | { | - | ||||||||||||||||||
| 142 | X509_ATTRIBUTE *attr; | - | ||||||||||||||||||
| 143 | STACK_OF(X509_ATTRIBUTE) *ret; | - | ||||||||||||||||||
| 144 | attr = X509_ATTRIBUTE_create_by_txt(NULL, attrname, type, bytes, len); | - | ||||||||||||||||||
| 145 | if (!attr)
| 0 | ||||||||||||||||||
| 146 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 147 | ret = X509at_add1_attr(x, attr); | - | ||||||||||||||||||
| 148 | X509_ATTRIBUTE_free(attr); | - | ||||||||||||||||||
| 149 | return ret; never executed: return ret; | 0 | ||||||||||||||||||
| 150 | } | - | ||||||||||||||||||
| 151 | - | |||||||||||||||||||
| 152 | void *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x, | - | ||||||||||||||||||
| 153 | const ASN1_OBJECT *obj, int lastpos, int type) | - | ||||||||||||||||||
| 154 | { | - | ||||||||||||||||||
| 155 | int i; | - | ||||||||||||||||||
| 156 | X509_ATTRIBUTE *at; | - | ||||||||||||||||||
| 157 | i = X509at_get_attr_by_OBJ(x, obj, lastpos); | - | ||||||||||||||||||
| 158 | if (i == -1)
| 0-61 | ||||||||||||||||||
| 159 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 160 | if ((lastpos <= -2) && (X509at_get_attr_by_OBJ(x, obj, i) != -1))
| 0-61 | ||||||||||||||||||
| 161 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 162 | at = X509at_get_attr(x, i); | - | ||||||||||||||||||
| 163 | if (lastpos <= -3 && (X509_ATTRIBUTE_count(at) != 1))
| 0-61 | ||||||||||||||||||
| 164 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 165 | return X509_ATTRIBUTE_get0_data(at, 0, type, NULL); executed 61 times by 1 test: return X509_ATTRIBUTE_get0_data(at, 0, type, ((void *)0) );Executed by:
| 61 | ||||||||||||||||||
| 166 | } | - | ||||||||||||||||||
| 167 | - | |||||||||||||||||||
| 168 | X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, | - | ||||||||||||||||||
| 169 | int atrtype, const void *data, | - | ||||||||||||||||||
| 170 | int len) | - | ||||||||||||||||||
| 171 | { | - | ||||||||||||||||||
| 172 | ASN1_OBJECT *obj; | - | ||||||||||||||||||
| 173 | X509_ATTRIBUTE *ret; | - | ||||||||||||||||||
| 174 | - | |||||||||||||||||||
| 175 | obj = OBJ_nid2obj(nid); | - | ||||||||||||||||||
| 176 | if (obj == NULL) {
| 0-209 | ||||||||||||||||||
| 177 | X509err(X509_F_X509_ATTRIBUTE_CREATE_BY_NID, X509_R_UNKNOWN_NID); | - | ||||||||||||||||||
| 178 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 179 | } | - | ||||||||||||||||||
| 180 | ret = X509_ATTRIBUTE_create_by_OBJ(attr, obj, atrtype, data, len); | - | ||||||||||||||||||
| 181 | if (ret == NULL)
| 0-209 | ||||||||||||||||||
| 182 | ASN1_OBJECT_free(obj); never executed: ASN1_OBJECT_free(obj); | 0 | ||||||||||||||||||
| 183 | return ret; executed 209 times by 1 test: return ret;Executed by:
| 209 | ||||||||||||||||||
| 184 | } | - | ||||||||||||||||||
| 185 | - | |||||||||||||||||||
| 186 | X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, | - | ||||||||||||||||||
| 187 | const ASN1_OBJECT *obj, | - | ||||||||||||||||||
| 188 | int atrtype, const void *data, | - | ||||||||||||||||||
| 189 | int len) | - | ||||||||||||||||||
| 190 | { | - | ||||||||||||||||||
| 191 | X509_ATTRIBUTE *ret; | - | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | if ((attr == NULL) || (*attr == NULL)) {
| 0-209 | ||||||||||||||||||
| 194 | if ((ret = X509_ATTRIBUTE_new()) == NULL) {
| 0-209 | ||||||||||||||||||
| 195 | X509err(X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ, | - | ||||||||||||||||||
| 196 | ERR_R_MALLOC_FAILURE); | - | ||||||||||||||||||
| 197 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 198 | } | - | ||||||||||||||||||
| 199 | } else executed 209 times by 1 test: end of blockExecuted by:
| 209 | ||||||||||||||||||
| 200 | ret = *attr; never executed: ret = *attr; | 0 | ||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | if (!X509_ATTRIBUTE_set1_object(ret, obj))
| 0-209 | ||||||||||||||||||
| 203 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 204 | if (!X509_ATTRIBUTE_set1_data(ret, atrtype, data, len))
| 0-209 | ||||||||||||||||||
| 205 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 206 | - | |||||||||||||||||||
| 207 | if ((attr != NULL) && (*attr == NULL))
| 0-209 | ||||||||||||||||||
| 208 | *attr = ret; never executed: *attr = ret; | 0 | ||||||||||||||||||
| 209 | return ret; executed 209 times by 1 test: return ret;Executed by:
| 209 | ||||||||||||||||||
| 210 | err: | - | ||||||||||||||||||
| 211 | if ((attr == NULL) || (ret != *attr))
| 0 | ||||||||||||||||||
| 212 | X509_ATTRIBUTE_free(ret); never executed: X509_ATTRIBUTE_free(ret); | 0 | ||||||||||||||||||
| 213 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 214 | } | - | ||||||||||||||||||
| 215 | - | |||||||||||||||||||
| 216 | X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, | - | ||||||||||||||||||
| 217 | const char *atrname, int type, | - | ||||||||||||||||||
| 218 | const unsigned char *bytes, | - | ||||||||||||||||||
| 219 | int len) | - | ||||||||||||||||||
| 220 | { | - | ||||||||||||||||||
| 221 | ASN1_OBJECT *obj; | - | ||||||||||||||||||
| 222 | X509_ATTRIBUTE *nattr; | - | ||||||||||||||||||
| 223 | - | |||||||||||||||||||
| 224 | obj = OBJ_txt2obj(atrname, 0); | - | ||||||||||||||||||
| 225 | if (obj == NULL) {
| 0 | ||||||||||||||||||
| 226 | X509err(X509_F_X509_ATTRIBUTE_CREATE_BY_TXT, | - | ||||||||||||||||||
| 227 | X509_R_INVALID_FIELD_NAME); | - | ||||||||||||||||||
| 228 | ERR_add_error_data(2, "name=", atrname); | - | ||||||||||||||||||
| 229 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 230 | } | - | ||||||||||||||||||
| 231 | nattr = X509_ATTRIBUTE_create_by_OBJ(attr, obj, type, bytes, len); | - | ||||||||||||||||||
| 232 | ASN1_OBJECT_free(obj); | - | ||||||||||||||||||
| 233 | return nattr; never executed: return nattr; | 0 | ||||||||||||||||||
| 234 | } | - | ||||||||||||||||||
| 235 | - | |||||||||||||||||||
| 236 | int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj) | - | ||||||||||||||||||
| 237 | { | - | ||||||||||||||||||
| 238 | if ((attr == NULL) || (obj == NULL))
| 0-209 | ||||||||||||||||||
| 239 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 240 | ASN1_OBJECT_free(attr->object); | - | ||||||||||||||||||
| 241 | attr->object = OBJ_dup(obj); | - | ||||||||||||||||||
| 242 | return attr->object != NULL; executed 209 times by 1 test: return attr->object != ((void *)0) ;Executed by:
| 209 | ||||||||||||||||||
| 243 | } | - | ||||||||||||||||||
| 244 | - | |||||||||||||||||||
| 245 | int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, | - | ||||||||||||||||||
| 246 | const void *data, int len) | - | ||||||||||||||||||
| 247 | { | - | ||||||||||||||||||
| 248 | ASN1_TYPE *ttmp = NULL; | - | ||||||||||||||||||
| 249 | ASN1_STRING *stmp = NULL; | - | ||||||||||||||||||
| 250 | int atype = 0; | - | ||||||||||||||||||
| 251 | if (!attr)
| 0-209 | ||||||||||||||||||
| 252 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 253 | if (attrtype & MBSTRING_FLAG) {
| 0-209 | ||||||||||||||||||
| 254 | stmp = ASN1_STRING_set_by_NID(NULL, data, len, attrtype, | - | ||||||||||||||||||
| 255 | OBJ_obj2nid(attr->object)); | - | ||||||||||||||||||
| 256 | if (!stmp) {
| 0 | ||||||||||||||||||
| 257 | X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_ASN1_LIB); | - | ||||||||||||||||||
| 258 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 259 | } | - | ||||||||||||||||||
| 260 | atype = stmp->type; | - | ||||||||||||||||||
| 261 | } else if (len != -1) { never executed: end of block
| 0-105 | ||||||||||||||||||
| 262 | if ((stmp = ASN1_STRING_type_new(attrtype)) == NULL)
| 0-105 | ||||||||||||||||||
| 263 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 264 | if (!ASN1_STRING_set(stmp, data, len))
| 0-105 | ||||||||||||||||||
| 265 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 266 | atype = attrtype; | - | ||||||||||||||||||
| 267 | } executed 105 times by 1 test: end of blockExecuted by:
| 105 | ||||||||||||||||||
| 268 | /* | - | ||||||||||||||||||
| 269 | * This is a bit naughty because the attribute should really have at | - | ||||||||||||||||||
| 270 | * least one value but some types use and zero length SET and require | - | ||||||||||||||||||
| 271 | * this. | - | ||||||||||||||||||
| 272 | */ | - | ||||||||||||||||||
| 273 | if (attrtype == 0) {
| 0-209 | ||||||||||||||||||
| 274 | ASN1_STRING_free(stmp); | - | ||||||||||||||||||
| 275 | return 1; never executed: return 1; | 0 | ||||||||||||||||||
| 276 | } | - | ||||||||||||||||||
| 277 | if ((ttmp = ASN1_TYPE_new()) == NULL)
| 0-209 | ||||||||||||||||||
| 278 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 279 | if ((len == -1) && !(attrtype & MBSTRING_FLAG)) {
| 0-105 | ||||||||||||||||||
| 280 | if (!ASN1_TYPE_set1(ttmp, attrtype, data))
| 0-104 | ||||||||||||||||||
| 281 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 282 | } else { executed 104 times by 1 test: end of blockExecuted by:
| 104 | ||||||||||||||||||
| 283 | ASN1_TYPE_set(ttmp, atype, stmp); | - | ||||||||||||||||||
| 284 | stmp = NULL; | - | ||||||||||||||||||
| 285 | } executed 105 times by 1 test: end of blockExecuted by:
| 105 | ||||||||||||||||||
| 286 | if (!sk_ASN1_TYPE_push(attr->set, ttmp))
| 0-209 | ||||||||||||||||||
| 287 | goto err; never executed: goto err; | 0 | ||||||||||||||||||
| 288 | return 1; executed 209 times by 1 test: return 1;Executed by:
| 209 | ||||||||||||||||||
| 289 | err: | - | ||||||||||||||||||
| 290 | X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_MALLOC_FAILURE); | - | ||||||||||||||||||
| 291 | ASN1_TYPE_free(ttmp); | - | ||||||||||||||||||
| 292 | ASN1_STRING_free(stmp); | - | ||||||||||||||||||
| 293 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 294 | } | - | ||||||||||||||||||
| 295 | - | |||||||||||||||||||
| 296 | int X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr) | - | ||||||||||||||||||
| 297 | { | - | ||||||||||||||||||
| 298 | if (attr == NULL)
| 0-61 | ||||||||||||||||||
| 299 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 300 | return sk_ASN1_TYPE_num(attr->set); executed 61 times by 1 test: return sk_ASN1_TYPE_num(attr->set);Executed by:
| 61 | ||||||||||||||||||
| 301 | } | - | ||||||||||||||||||
| 302 | - | |||||||||||||||||||
| 303 | ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr) | - | ||||||||||||||||||
| 304 | { | - | ||||||||||||||||||
| 305 | if (attr == NULL)
| 0-118 | ||||||||||||||||||
| 306 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 307 | return attr->object; executed 118 times by 1 test: return attr->object;Executed by:
| 118 | ||||||||||||||||||
| 308 | } | - | ||||||||||||||||||
| 309 | - | |||||||||||||||||||
| 310 | void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, | - | ||||||||||||||||||
| 311 | int atrtype, void *data) | - | ||||||||||||||||||
| 312 | { | - | ||||||||||||||||||
| 313 | ASN1_TYPE *ttmp; | - | ||||||||||||||||||
| 314 | ttmp = X509_ATTRIBUTE_get0_type(attr, idx); | - | ||||||||||||||||||
| 315 | if (!ttmp)
| 0-61 | ||||||||||||||||||
| 316 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 317 | if (atrtype != ASN1_TYPE_get(ttmp)) {
| 0-61 | ||||||||||||||||||
| 318 | X509err(X509_F_X509_ATTRIBUTE_GET0_DATA, X509_R_WRONG_TYPE); | - | ||||||||||||||||||
| 319 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 320 | } | - | ||||||||||||||||||
| 321 | return ttmp->value.ptr; executed 61 times by 1 test: return ttmp->value.ptr;Executed by:
| 61 | ||||||||||||||||||
| 322 | } | - | ||||||||||||||||||
| 323 | - | |||||||||||||||||||
| 324 | ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx) | - | ||||||||||||||||||
| 325 | { | - | ||||||||||||||||||
| 326 | if (attr == NULL)
| 39-84 | ||||||||||||||||||
| 327 | return NULL; executed 39 times by 1 test: return ((void *)0) ;Executed by:
| 39 | ||||||||||||||||||
| 328 | return sk_ASN1_TYPE_value(attr->set, idx); executed 84 times by 1 test: return sk_ASN1_TYPE_value(attr->set, idx);Executed by:
| 84 | ||||||||||||||||||
| 329 | } | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |