/* Provenance: openssl/openssl has_san_id (fixed). * repo: openssl/openssl * commit: d69ae8a93bfc0f2489c008fcf303a98d77a6df4d * parent: 758754966791c537ea95241438454aa86f91f256 * commit_url: https://github.com/openssl/openssl/commit/d69ae8a93bfc0f2489c008fcf303a98d77a6df4d * cve: CVE-2021-4044 * license: OpenSSL License * function: has_san_id * relpath: crypto/x509/x509_vfy.c */ static int has_san_id(X509 *x, int gtype) { int i; int ret = 0; GENERAL_NAMES *gs = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL); if (gs == NULL) return 0; for (i = 0; i < sk_GENERAL_NAME_num(gs); i++) { GENERAL_NAME *g = sk_GENERAL_NAME_value(gs, i); if (g->type == gtype) { ret = 1; break; } } GENERAL_NAMES_free(gs); return ret; }