static void *v2i_IPAddrBlocks(const struct v3_ext_method *method,
                              struct v3_ext_ctx *ctx,
                              STACK_OF(CONF_VALUE) *values)
{
    static const char v4addr_chars[] = "0123456789.";
    static const char v6addr_chars[] = "0123456789.:abcdefABCDEF";
    IPAddrBlocks *addr = NULL;
    char *s = NULL, *t;
    int i;
    if ((addr = sk_IPAddressFamily_new(IPAddressFamily_cmp)) == NULL) {
        X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);
        return NULL;
    }
    for (i = 0; i < sk_CONF_VALUE_num(values); i++) {
        CONF_VALUE *val = sk_CONF_VALUE_value(values, i);
        unsigned char min[ADDR_RAW_BUF_LEN], max[ADDR_RAW_BUF_LEN];
        unsigned afi, *safi = NULL, safi_;
        const char *addr_chars = NULL;
        int prefixlen, i1, i2, delim, length;
        if (!name_cmp(val->name, "IPv4")) {
            afi = IANA_AFI_IPV4;
        } else if (!name_cmp(val->name, "IPv6")) {
            afi = IANA_AFI_IPV6;
        } else if (!name_cmp(val->name, "IPv4-SAFI")) {
            afi = IANA_AFI_IPV4;
            safi = &safi_;
        } else if (!name_cmp(val->name, "IPv6-SAFI")) {
            afi = IANA_AFI_IPV6;
            safi = &safi_;
        } else {
            X509V3err(X509V3_F_V2I_IPADDRBLOCKS,
                      X509V3_R_EXTENSION_NAME_ERROR);
            X509V3_conf_err(val);
            goto err;
        }
        switch (afi) {
        case IANA_AFI_IPV4:
            addr_chars = v4addr_chars;
            break;
        case IANA_AFI_IPV6:
            addr_chars = v6addr_chars;
            break;
        }
        length = length_from_afi(afi);
        if (safi != NULL) {
            *safi = strtoul(val->value, &t, 0);
            t += strspn(t, " \t");
            if (*safi > 0xFF || *t++ != ':') {
                X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_INVALID_SAFI);
                X509V3_conf_err(val);
                goto err;
            }
            t += strspn(t, " \t");
            s = OPENSSL_strdup(t);
        } else {
            s = OPENSSL_strdup(val->value);
        }
        if (s == NULL) {
            X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);
            goto err;
        }
        if (strcmp(s, "inherit") == 0) {
            if (!v3_addr_add_inherit(addr, afi, safi)) {
                X509V3err(X509V3_F_V2I_IPADDRBLOCKS,
                          X509V3_R_INVALID_INHERITANCE);
                X509V3_conf_err(val);
                goto err;
            }
            OPENSSL_free(s);
            s = NULL;
            continue;
        }
        i1 = strspn(s, addr_chars);
        i2 = i1 + strspn(s + i1, " \t");
        delim = s[i2++];
        s[i1] = '\0';
        if (a2i_ipadd(min, s) != length) {
            X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_INVALID_IPADDRESS);
            X509V3_conf_err(val);
            goto err;
        }
        switch (delim) {
        case '/':
            prefixlen = (int)strtoul(s + i2, &t, 10);
            if (t == s + i2 || *t != '\0') {
                X509V3err(X509V3_F_V2I_IPADDRBLOCKS,
                          X509V3_R_EXTENSION_VALUE_ERROR);
                X509V3_conf_err(val);
                goto err;
            }
            if (!v3_addr_add_prefix(addr, afi, safi, min, prefixlen)) {
                X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);
                goto err;
            }
            break;
        case '-':
            i1 = i2 + strspn(s + i2, " \t");
            i2 = i1 + strspn(s + i1, addr_chars);
            if (i1 == i2 || s[i2] != '\0') {
                X509V3err(X509V3_F_V2I_IPADDRBLOCKS,
                          X509V3_R_EXTENSION_VALUE_ERROR);
                X509V3_conf_err(val);
                goto err;
            }
            if (a2i_ipadd(max, s + i1) != length) {
                X509V3err(X509V3_F_V2I_IPADDRBLOCKS,
                          X509V3_R_INVALID_IPADDRESS);
                X509V3_conf_err(val);
                goto err;
            }
            if (memcmp(min, max, length_from_afi(afi)) > 0) {
                X509V3err(X509V3_F_V2I_IPADDRBLOCKS,
                          X509V3_R_EXTENSION_VALUE_ERROR);
                X509V3_conf_err(val);
                goto err;
            }
            if (!v3_addr_add_range(addr, afi, safi, min, max)) {
                X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);
                goto err;
            }
            break;
        case '\0':
            if (!v3_addr_add_prefix(addr, afi, safi, min, length * 8)) {
                X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);
                goto err;
            }
            break;
        default:
            X509V3err(X509V3_F_V2I_IPADDRBLOCKS,
                      X509V3_R_EXTENSION_VALUE_ERROR);
            X509V3_conf_err(val);
            goto err;
        }
        OPENSSL_free(s);
        s = NULL;
    }
    if (!v3_addr_canonize(addr))
        goto err;
    return addr;
 err:
    OPENSSL_free(s);
    sk_IPAddressFamily_pop_free(addr, IPAddressFamily_free);
    return NULL;
}
['static void *v2i_IPAddrBlocks(const struct v3_ext_method *method,\n                              struct v3_ext_ctx *ctx,\n                              STACK_OF(CONF_VALUE) *values)\n{\n    static const char v4addr_chars[] = "0123456789.";\n    static const char v6addr_chars[] = "0123456789.:abcdefABCDEF";\n    IPAddrBlocks *addr = NULL;\n    char *s = NULL, *t;\n    int i;\n    if ((addr = sk_IPAddressFamily_new(IPAddressFamily_cmp)) == NULL) {\n        X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    for (i = 0; i < sk_CONF_VALUE_num(values); i++) {\n        CONF_VALUE *val = sk_CONF_VALUE_value(values, i);\n        unsigned char min[ADDR_RAW_BUF_LEN], max[ADDR_RAW_BUF_LEN];\n        unsigned afi, *safi = NULL, safi_;\n        const char *addr_chars = NULL;\n        int prefixlen, i1, i2, delim, length;\n        if (!name_cmp(val->name, "IPv4")) {\n            afi = IANA_AFI_IPV4;\n        } else if (!name_cmp(val->name, "IPv6")) {\n            afi = IANA_AFI_IPV6;\n        } else if (!name_cmp(val->name, "IPv4-SAFI")) {\n            afi = IANA_AFI_IPV4;\n            safi = &safi_;\n        } else if (!name_cmp(val->name, "IPv6-SAFI")) {\n            afi = IANA_AFI_IPV6;\n            safi = &safi_;\n        } else {\n            X509V3err(X509V3_F_V2I_IPADDRBLOCKS,\n                      X509V3_R_EXTENSION_NAME_ERROR);\n            X509V3_conf_err(val);\n            goto err;\n        }\n        switch (afi) {\n        case IANA_AFI_IPV4:\n            addr_chars = v4addr_chars;\n            break;\n        case IANA_AFI_IPV6:\n            addr_chars = v6addr_chars;\n            break;\n        }\n        length = length_from_afi(afi);\n        if (safi != NULL) {\n            *safi = strtoul(val->value, &t, 0);\n            t += strspn(t, " \\t");\n            if (*safi > 0xFF || *t++ != \':\') {\n                X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_INVALID_SAFI);\n                X509V3_conf_err(val);\n                goto err;\n            }\n            t += strspn(t, " \\t");\n            s = OPENSSL_strdup(t);\n        } else {\n            s = OPENSSL_strdup(val->value);\n        }\n        if (s == NULL) {\n            X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);\n            goto err;\n        }\n        if (strcmp(s, "inherit") == 0) {\n            if (!v3_addr_add_inherit(addr, afi, safi)) {\n                X509V3err(X509V3_F_V2I_IPADDRBLOCKS,\n                          X509V3_R_INVALID_INHERITANCE);\n                X509V3_conf_err(val);\n                goto err;\n            }\n            OPENSSL_free(s);\n            s = NULL;\n            continue;\n        }\n        i1 = strspn(s, addr_chars);\n        i2 = i1 + strspn(s + i1, " \\t");\n        delim = s[i2++];\n        s[i1] = \'\\0\';\n        if (a2i_ipadd(min, s) != length) {\n            X509V3err(X509V3_F_V2I_IPADDRBLOCKS, X509V3_R_INVALID_IPADDRESS);\n            X509V3_conf_err(val);\n            goto err;\n        }\n        switch (delim) {\n        case \'/\':\n            prefixlen = (int)strtoul(s + i2, &t, 10);\n            if (t == s + i2 || *t != \'\\0\') {\n                X509V3err(X509V3_F_V2I_IPADDRBLOCKS,\n                          X509V3_R_EXTENSION_VALUE_ERROR);\n                X509V3_conf_err(val);\n                goto err;\n            }\n            if (!v3_addr_add_prefix(addr, afi, safi, min, prefixlen)) {\n                X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);\n                goto err;\n            }\n            break;\n        case \'-\':\n            i1 = i2 + strspn(s + i2, " \\t");\n            i2 = i1 + strspn(s + i1, addr_chars);\n            if (i1 == i2 || s[i2] != \'\\0\') {\n                X509V3err(X509V3_F_V2I_IPADDRBLOCKS,\n                          X509V3_R_EXTENSION_VALUE_ERROR);\n                X509V3_conf_err(val);\n                goto err;\n            }\n            if (a2i_ipadd(max, s + i1) != length) {\n                X509V3err(X509V3_F_V2I_IPADDRBLOCKS,\n                          X509V3_R_INVALID_IPADDRESS);\n                X509V3_conf_err(val);\n                goto err;\n            }\n            if (memcmp(min, max, length_from_afi(afi)) > 0) {\n                X509V3err(X509V3_F_V2I_IPADDRBLOCKS,\n                          X509V3_R_EXTENSION_VALUE_ERROR);\n                X509V3_conf_err(val);\n                goto err;\n            }\n            if (!v3_addr_add_range(addr, afi, safi, min, max)) {\n                X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);\n                goto err;\n            }\n            break;\n        case \'\\0\':\n            if (!v3_addr_add_prefix(addr, afi, safi, min, length * 8)) {\n                X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);\n                goto err;\n            }\n            break;\n        default:\n            X509V3err(X509V3_F_V2I_IPADDRBLOCKS,\n                      X509V3_R_EXTENSION_VALUE_ERROR);\n            X509V3_conf_err(val);\n            goto err;\n        }\n        OPENSSL_free(s);\n        s = NULL;\n    }\n    if (!v3_addr_canonize(addr))\n        goto err;\n    return addr;\n err:\n    OPENSSL_free(s);\n    sk_IPAddressFamily_pop_free(addr, IPAddressFamily_free);\n    return NULL;\n}', 'DEFINE_STACK_OF(IPAddressFamily)', '_STACK *sk_new(int (*c) (const void *, const void *))\n{\n    _STACK *ret;\n    if ((ret = OPENSSL_zalloc(sizeof(_STACK))) == NULL)\n        goto err;\n    if ((ret->data = OPENSSL_zalloc(sizeof(*ret->data) * MIN_NODES)) == NULL)\n        goto err;\n    ret->comp = c;\n    ret->num_alloc = MIN_NODES;\n    return (ret);\n err:\n    OPENSSL_free(ret);\n    return (NULL);\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (num <= 0)\n        return NULL;\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)file;\n    (void)line;\n    ret = malloc(num);\n#endif\n#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\n#endif\n    return ret;\n}', 'DEFINE_STACK_OF(CONF_VALUE)', 'int sk_num(const _STACK *st)\n{\n    if (st == NULL)\n        return -1;\n    return st->num;\n}']