summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2012-02-06 22:18:33 -0500
committerSimo Sorce <simo@redhat.com>2012-02-07 14:51:40 -0500
commit649e1bcbbb61cdf235b97c105d454b9528db748e (patch)
treea70998a002114da46b9392bc90b8435d1d2b5df6
parentce22fdafba5e94228e4c98c5cf3abf67d7646c49 (diff)
downloadgss-proxy-649e1bcbbb61cdf235b97c105d454b9528db748e.tar.gz
gss-proxy-649e1bcbbb61cdf235b97c105d454b9528db748e.tar.xz
gss-proxy-649e1bcbbb61cdf235b97c105d454b9528db748e.zip
Add more helper functions to gp_conv
-rw-r--r--proxy/src/gp_conv.c65
-rw-r--r--proxy/src/gp_conv.h3
2 files changed, 53 insertions, 15 deletions
diff --git a/proxy/src/gp_conv.c b/proxy/src/gp_conv.c
index 5136b91..0105d00 100644
--- a/proxy/src/gp_conv.c
+++ b/proxy/src/gp_conv.c
@@ -148,11 +148,34 @@ int gp_conv_gssx_to_buffer_alloc(gssx_buffer *in, gss_buffer_t *out)
return 0;
}
+int gp_copy_gssx_to_buffer(gssx_buffer *in, gss_buffer_t out)
+{
+ gss_buffer_desc empty = GSS_C_EMPTY_BUFFER;
+
+ if (in->octet_string_len == 0) {
+ *out = empty;
+ return 0;
+ }
+
+ out->value = gp_memdup(in->octet_string_val,
+ in->octet_string_len);
+ if (!out->value) {
+ return ENOMEM;
+ }
+ out->length = in->octet_string_len;
+ return 0;
+}
+
int gp_conv_buffer_to_gssx(gss_buffer_t in, gssx_buffer *out)
{
return gp_conv_octet_string(in->length, in->value, out);
}
+int gp_conv_buffer_to_gssx_alloc(gss_buffer_t in, gssx_buffer **out)
+{
+ return gp_conv_octet_string_alloc(in->length, in->value, out);
+}
+
void gp_conv_gssx_to_cb(gssx_cb *in, gss_channel_bindings_t out)
{
out->initiator_addrtype = in->initiator_addrtype;
@@ -680,47 +703,59 @@ int gp_conv_oid_set_to_gssx(gss_OID_set in, gssx_OID_set *out)
return 0;
}
-int gp_copy_gssx_name_alloc(gssx_name *in, gssx_name **out)
+int gp_copy_gssx_name(gssx_name *in, gssx_name *out)
{
- gssx_name *o;
int ret;
- o = calloc(1, sizeof(gssx_name));
- if (!o) {
- return ENOMEM;
- }
-
ret = gp_conv_octet_string(in->display_name.octet_string_len,
in->display_name.octet_string_val,
- &o->display_name);
+ &out->display_name);
if (ret) {
goto done;
}
ret = gp_conv_octet_string(in->name_type.octet_string_len,
in->name_type.octet_string_val,
- &o->name_type);
+ &out->name_type);
if (ret) {
goto done;
}
ret = gp_conv_octet_string(in->exported_name.octet_string_len,
in->exported_name.octet_string_val,
- &o->exported_name);
+ &out->exported_name);
if (ret) {
goto done;
}
ret = gp_conv_octet_string(in->exported_composite_name.octet_string_len,
in->exported_composite_name.octet_string_val,
- &o->exported_composite_name);
+ &out->exported_composite_name);
if (ret) {
goto done;
}
- *out = o;
-
done:
if (ret) {
- xdr_free((xdrproc_t)xdr_gssx_name, (char *)o);
- free(o);
+ xdr_free((xdrproc_t)xdr_gssx_name, (char *)out);
}
return ret;
}
+
+int gp_copy_gssx_name_alloc(gssx_name *in, gssx_name **out)
+{
+ gssx_name *o;
+ int ret;
+
+ o = calloc(1, sizeof(gssx_name));
+ if (!o) {
+ return ENOMEM;
+ }
+
+ ret = gp_copy_gssx_name(in, o);
+ if (ret) {
+ free(o);
+ return ret;
+ }
+ *out = o;
+ return 0;
+}
+
+
diff --git a/proxy/src/gp_conv.h b/proxy/src/gp_conv.h
index 82228b7..68e1b3a 100644
--- a/proxy/src/gp_conv.h
+++ b/proxy/src/gp_conv.h
@@ -41,7 +41,9 @@ int gp_conv_oid_to_gssx_alloc(gss_OID in, gssx_OID **out);
void gp_conv_gssx_to_buffer(gssx_buffer *in, gss_buffer_t out);
int gp_conv_gssx_to_buffer_alloc(gssx_buffer *in, gss_buffer_t *out);
+int gp_copy_gssx_to_buffer(gssx_buffer *in, gss_buffer_t out);
int gp_conv_buffer_to_gssx(gss_buffer_t in, gssx_buffer *out);
+int gp_conv_buffer_to_gssx_alloc(gss_buffer_t in, gssx_buffer **out);
void gp_conv_gssx_to_cb(gssx_cb *in, gss_channel_bindings_t out);
int gp_conv_cb_to_gssx(gss_channel_bindings_t in, gssx_cb *out);
@@ -69,6 +71,7 @@ int gp_copy_gssx_status_alloc(gssx_status *in, gssx_status **out);
int gp_conv_gssx_to_oid_set(gssx_OID_set *in, gss_OID_set *out);
int gp_conv_oid_set_to_gssx(gss_OID_set in, gssx_OID_set *out);
+int gp_copy_gssx_name(gssx_name *in, gssx_name *out);
int gp_copy_gssx_name_alloc(gssx_name *in, gssx_name **out);
#endif /* _GSS_CONV_H_ */