📄 os400sys.c
字号:
/* ASCII wrappers for the GSSAPI procedures. */static intCurl_gss_convert_in_place(OM_uint32 * minor_status, gss_buffer_t buf){ unsigned int i; char * t; /* Convert `buf' in place, from EBCDIC to ASCII. If error, release the buffer and return -1. Else return 0. */ i = buf->length; if (i) { if (!(t = malloc(i))) { gss_release_buffer(minor_status, buf); if (minor_status) *minor_status = ENOMEM; return -1; } QadrtConvertE2A(t, buf->value, i, i); memcpy(buf->value, t, i); free(t); } return 0;}OM_uint32Curl_gss_import_name_a(OM_uint32 * minor_status, gss_buffer_t in_name, gss_OID in_name_type, gss_name_t * out_name){ int rc; unsigned int i; gss_buffer_desc in; if (!in_name || !in_name->value || !in_name->length) return gss_import_name(minor_status, in_name, in_name_type, out_name); memcpy((char *) &in, (char *) in_name, sizeof in); i = in.length; if (!(in.value = malloc(i + 1))) { if (minor_status) *minor_status = ENOMEM; return GSS_S_FAILURE; } QadrtConvertA2E(in.value, in_name->value, i, i); ((char *) in.value)[i] = '\0'; rc = gss_import_name(minor_status, &in, in_name_type, out_name); free(in.value); return rc;}OM_uint32Curl_gss_display_status_a(OM_uint32 * minor_status, OM_uint32 status_value, int status_type, gss_OID mech_type, gss_msg_ctx_t * message_context, gss_buffer_t status_string){ int rc; rc = gss_display_status(minor_status, status_value, status_type, mech_type, message_context, status_string); if (rc != GSS_S_COMPLETE || !status_string || !status_string->length || !status_string->value) return rc; /* No way to allocate a buffer here, because it will be released by gss_release_buffer(). The solution is to overwrite the EBCDIC buffer with ASCII to return it. */ if (Curl_gss_convert_in_place(minor_status, status_string)) return GSS_S_FAILURE; return rc;}OM_uint32Curl_gss_init_sec_context_a(OM_uint32 * minor_status, gss_cred_id_t cred_handle, gss_ctx_id_t * context_handle, gss_name_t target_name, gss_OID mech_type, gss_flags_t req_flags, OM_uint32 time_req, gss_channel_bindings_t input_chan_bindings, gss_buffer_t input_token, gss_OID * actual_mech_type, gss_buffer_t output_token, gss_flags_t * ret_flags, OM_uint32 * time_rec){ int rc; unsigned int i; gss_buffer_desc in; gss_buffer_t inp; in.value = NULL; if ((inp = input_token)) if (inp->length && inp->value) { i = inp->length; if (!(in.value = malloc(i + 1))) { if (minor_status) *minor_status = ENOMEM; return GSS_S_FAILURE; } QadrtConvertA2E(in.value, input_token->value, i, i); ((char *) in.value)[i] = '\0'; in.length = i; inp = ∈ } rc = gss_init_sec_context(minor_status, cred_handle, context_handle, target_name, mech_type, req_flags, time_req, input_chan_bindings, inp, actual_mech_type, output_token, ret_flags, time_rec); if (in.value) free(in.value); if (rc != GSS_S_COMPLETE || !output_token || !output_token->length || !output_token->value) return rc; /* No way to allocate a buffer here, because it will be released by gss_release_buffer(). The solution is to overwrite the EBCDIC buffer with ASCII to return it. */ if (Curl_gss_convert_in_place(minor_status, output_token)) return GSS_S_FAILURE; return rc;}OM_uint32Curl_gss_delete_sec_context_a(OM_uint32 * minor_status, gss_ctx_id_t * context_handle, gss_buffer_t output_token){ int rc; rc = gss_delete_sec_context(minor_status, context_handle, output_token); if (rc != GSS_S_COMPLETE || !output_token || !output_token->length || !output_token->value) return rc; /* No way to allocate a buffer here, because it will be released by gss_release_buffer(). The solution is to overwrite the EBCDIC buffer with ASCII to return it. */ if (Curl_gss_convert_in_place(minor_status, output_token)) return GSS_S_FAILURE; return rc;}#endif /* HAVE_GSSAPI */#ifndef CURL_DISABLE_LDAP/* ASCII wrappers for the LDAP procedures. */void *Curl_ldap_init_a(char * host, int port){ unsigned int i; char * ehost; void * result; if (!host) return (void *) ldap_init(host, port); i = strlen(host); if (!(ehost = malloc(i + 1))) return (void *) NULL; QadrtConvertA2E(ehost, host, i, i); ehost[i] = '\0'; result = (void *) ldap_init(ehost, port); free(ehost); return result;}intCurl_ldap_simple_bind_s_a(void * ld, char * dn, char * passwd){ int i; char * edn; char * epasswd; edn = (char *) NULL; epasswd = (char *) NULL; if (dn) { i = strlen(dn); if (!(edn = malloc(i + 1))) return LDAP_NO_MEMORY; QadrtConvertA2E(edn, dn, i, i); edn[i] = '\0'; } if (passwd) { i = strlen(passwd); if (!(epasswd = malloc(i + 1))) { if (edn) free(edn); return LDAP_NO_MEMORY; } QadrtConvertA2E(epasswd, passwd, i, i); epasswd[i] = '\0'; } i = ldap_simple_bind_s(ld, edn, epasswd); if (epasswd) free(epasswd); if (edn) free(edn); return i;}intCurl_ldap_search_s_a(void * ld, char * base, int scope, char * filter, char * * attrs, int attrsonly, LDAPMessage * * res){ int i; int j; char * ebase; char * efilter; char * * eattrs; int status; ebase = (char *) NULL; efilter = (char *) NULL; eattrs = (char * *) NULL; status = LDAP_SUCCESS; if (base) { i = strlen(base); if (!(ebase = malloc(i + 1))) status = LDAP_NO_MEMORY; else { QadrtConvertA2E(ebase, base, i, i); ebase[i] = '\0'; } } if (filter && status == LDAP_SUCCESS) { i = strlen(filter); if (!(efilter = malloc(i + 1))) status = LDAP_NO_MEMORY; else { QadrtConvertA2E(efilter, filter, i, i); efilter[i] = '\0'; } } if (attrs && status == LDAP_SUCCESS) { for (i = 0; attrs[i++];) ; if (!(eattrs = (char * *) calloc(i, sizeof *eattrs))) status = LDAP_NO_MEMORY; else { for (j = 0; attrs[j]; j++) { i = strlen(attrs[j]); if (!(eattrs[j] = malloc(i + 1))) { status = LDAP_NO_MEMORY; break; } QadrtConvertA2E(eattrs[j], attrs[j], i, i); eattrs[j][i] = '\0'; } } } if (status == LDAP_SUCCESS) status = ldap_search_s(ld, ebase? ebase: "", scope, efilter? efilter: "(objectclass=*)", eattrs, attrsonly, res); if (eattrs) { for (j = 0; eattrs[j]; j++) free(eattrs[j]); free(eattrs); } if (efilter) free(efilter); if (ebase) free(ebase); return status;}struct berval * *Curl_ldap_get_values_len_a(void * ld, LDAPMessage * entry, const char * attr){ int i; char * cp; struct berval * * result; cp = (char *) NULL; if (attr) { i = strlen(attr); if (!(cp = malloc(i + 1))) { ldap_set_lderrno(ld, LDAP_NO_MEMORY, NULL, ldap_err2string(LDAP_NO_MEMORY)); return (struct berval * *) NULL; } QadrtConvertA2E(cp, attr, i, i); cp[i] = '\0'; } result = ldap_get_values_len(ld, entry, cp); if (cp) free(cp); /* Result data are binary in nature, so they haven't been converted to EBCDIC. Therefore do not convert. */ return result;}char *Curl_ldap_err2string_a(int error){ int i; char * cp; char * cp2; cp = ldap_err2string(error); if (!cp) return cp; i = strlen(cp); if (!(cp2 = Curl_thread_buffer(LK_LDAP_ERROR, MAX_CONV_EXPANSION * i + 1))) return cp2; i = QadrtConvertE2A(cp2, cp, MAX_CONV_EXPANSION * i, i); cp2[i] = '\0'; return cp2;}char *Curl_ldap_get_dn_a(void * ld, LDAPMessage * entry){ int i; char * cp; char * cp2; cp = ldap_get_dn(ld, entry); if (!cp) return cp; i = strlen(cp); if (!(cp2 = malloc(i + 1))) return cp2; QadrtConvertE2A(cp2, cp, i, i); /* No way to allocate a buffer here, because it will be released by ldap_memfree() and ldap_memalloc() does not exist. The solution is to overwrite the EBCDIC buffer with ASCII to return it. */ strcpy(cp, cp2); free(cp2); return cp;}char *Curl_ldap_first_attribute_a(void * ld, LDAPMessage * entry, BerElement * * berptr){ int i; char * cp; char * cp2; cp = ldap_first_attribute(ld, entry, berptr); if (!cp) return cp; i = strlen(cp); if (!(cp2 = malloc(i + 1))) return cp2; QadrtConvertE2A(cp2, cp, i, i); /* No way to allocate a buffer here, because it will be released by ldap_memfree() and ldap_memalloc() does not exist. The solution is to overwrite the EBCDIC buffer with ASCII to return it. */ strcpy(cp, cp2); free(cp2); return cp;}char *Curl_ldap_next_attribute_a(void * ld, LDAPMessage * entry, BerElement * berptr){ int i; char * cp; char * cp2; cp = ldap_next_attribute(ld, entry, berptr); if (!cp) return cp; i = strlen(cp); if (!(cp2 = malloc(i + 1))) return cp2; QadrtConvertE2A(cp2, cp, i, i); /* No way to allocate a buffer here, because it will be released by ldap_memfree() and ldap_memalloc() does not exist. The solution is to overwrite the EBCDIC buffer with ASCII to return it. */ strcpy(cp, cp2); free(cp2); return cp;}#endif /* CURL_DISABLE_LDAP */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -