summaryrefslogtreecommitdiff
path: root/usr/src/lib/libgss
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libgss')
-rw-r--r--usr/src/lib/libgss/g_accept_sec_context.c78
-rw-r--r--usr/src/lib/libgss/g_acquire_cred.c127
-rw-r--r--usr/src/lib/libgss/g_canon_name.c48
-rw-r--r--usr/src/lib/libgss/g_compare_name.c46
-rw-r--r--usr/src/lib/libgss/g_delete_sec_context.c50
-rw-r--r--usr/src/lib/libgss/g_dsp_name.c60
-rw-r--r--usr/src/lib/libgss/g_dsp_status.c26
-rw-r--r--usr/src/lib/libgss/g_dup_name.c51
-rw-r--r--usr/src/lib/libgss/g_exp_sec_context.c52
-rw-r--r--usr/src/lib/libgss/g_export_name.c30
-rw-r--r--usr/src/lib/libgss/g_imp_name.c53
-rw-r--r--usr/src/lib/libgss/g_imp_sec_context.c55
-rw-r--r--usr/src/lib/libgss/g_init_sec_context.c75
-rw-r--r--usr/src/lib/libgss/g_initialize.c16
-rw-r--r--usr/src/lib/libgss/g_inquire_context.c68
-rw-r--r--usr/src/lib/libgss/g_inquire_cred.c37
-rw-r--r--usr/src/lib/libgss/g_inquire_names.c53
-rw-r--r--usr/src/lib/libgss/g_process_context.c14
-rw-r--r--usr/src/lib/libgss/g_seal.c65
-rw-r--r--usr/src/lib/libgss/g_sign.c64
-rw-r--r--usr/src/lib/libgss/g_store_cred.c50
-rw-r--r--usr/src/lib/libgss/g_unseal.c28
-rw-r--r--usr/src/lib/libgss/g_verify.c15
-rw-r--r--usr/src/lib/libgss/oid_ops.c49
24 files changed, 819 insertions, 391 deletions
diff --git a/usr/src/lib/libgss/g_accept_sec_context.c b/usr/src/lib/libgss/g_accept_sec_context.c
index b008655b8e..79b092ef9d 100644
--- a/usr/src/lib/libgss/g_accept_sec_context.c
+++ b/usr/src/lib/libgss/g_accept_sec_context.c
@@ -20,12 +20,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine for gss_accept_sec_context
*/
@@ -37,6 +35,53 @@
#include <string.h>
#include <errno.h>
+static OM_uint32
+val_acc_sec_ctx_args(
+ OM_uint32 *minor_status,
+ gss_ctx_id_t *context_handle,
+ gss_buffer_t input_token_buffer,
+ gss_name_t *src_name,
+ gss_OID *mech_type,
+ gss_buffer_t output_token,
+ gss_cred_id_t *d_cred)
+{
+
+ /* Initialize outputs. */
+
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (src_name != NULL)
+ *src_name = GSS_C_NO_NAME;
+
+ if (mech_type != NULL)
+ *mech_type = GSS_C_NO_OID;
+
+ if (output_token != GSS_C_NO_BUFFER) {
+ output_token->length = 0;
+ output_token->value = NULL;
+ }
+
+ if (d_cred != NULL)
+ *d_cred = GSS_C_NO_CREDENTIAL;
+
+ /* Validate arguments. */
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (context_handle == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (input_token_buffer == GSS_C_NO_BUFFER)
+ return (GSS_S_CALL_INACCESSIBLE_READ);
+
+ if (output_token == GSS_C_NO_BUFFER)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ return (GSS_S_COMPLETE);
+}
+
OM_uint32
gss_accept_sec_context(minor_status,
context_handle,
@@ -76,25 +121,16 @@ gss_cred_id_t *d_cred; /* delegated cred handle */
OM_uint32 flags;
gss_mechanism mech;
- /* check parameters first */
- if (minor_status == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
- *minor_status = 0;
-
- if (context_handle == NULL || output_token == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
-
- /* clear optional fields */
- output_token->value = NULL;
- output_token->length = 0;
- if (src_name)
- *src_name = NULL;
-
- if (mech_type)
- *mech_type = NULL;
+ status = val_acc_sec_ctx_args(minor_status,
+ context_handle,
+ input_token_buffer,
+ src_name,
+ mech_type,
+ output_token,
+ d_cred);
+ if (status != GSS_S_COMPLETE)
+ return (status);
- if (d_cred)
- *d_cred = NULL;
/*
* if context_handle is GSS_C_NO_CONTEXT, allocate a union context
* descriptor to hold the mech type information as well as the
diff --git a/usr/src/lib/libgss/g_acquire_cred.c b/usr/src/lib/libgss/g_acquire_cred.c
index 12d3bda4ed..767ba79a7c 100644
--- a/usr/src/lib/libgss/g_acquire_cred.c
+++ b/usr/src/lib/libgss/g_acquire_cred.c
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine for gss_acquire_cred
*/
@@ -76,6 +74,38 @@ create_actual_mechs(mechs_array, count)
return (actual_mechs);
}
+static OM_uint32
+val_acq_cred_args(
+ OM_uint32 *minor_status,
+ gss_cred_id_t *output_cred_handle,
+ gss_OID_set *actual_mechs,
+ OM_uint32 *time_rec)
+{
+
+ /* Initialize outputs. */
+
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (output_cred_handle != NULL)
+ *output_cred_handle = GSS_C_NO_CREDENTIAL;
+
+ if (actual_mechs != NULL)
+ *actual_mechs = GSS_C_NULL_OID_SET;
+
+ if (time_rec != NULL)
+ *time_rec = 0;
+
+ /* Validate arguments. */
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (output_cred_handle == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ return (GSS_S_COMPLETE);
+}
OM_uint32
gss_acquire_cred(minor_status,
@@ -106,22 +136,15 @@ OM_uint32 * time_rec;
int i;
gss_union_cred_t creds;
- /* start by checking parameters */
- if (!minor_status)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
- *minor_status = 0;
-
- if (!output_cred_handle)
- return (GSS_S_CALL_INACCESSIBLE_WRITE | GSS_S_NO_CRED);
-
- *output_cred_handle = GSS_C_NO_CREDENTIAL;
+ major = val_acq_cred_args(minor_status,
+ output_cred_handle,
+ actual_mechs,
+ time_rec);
+ if (major != GSS_S_COMPLETE)
+ return (major);
- /* Set output parameters to NULL for now */
- if (actual_mechs)
- *actual_mechs = GSS_C_NULL_OID_SET;
-
- if (time_rec)
- *time_rec = 0;
+ /* Initial value needed below. */
+ major = GSS_S_FAILURE;
/*
* if desired_mechs equals GSS_C_NULL_OID_SET, then pick an
@@ -211,6 +234,46 @@ OM_uint32 * time_rec;
return (GSS_S_COMPLETE);
}
+static OM_uint32
+val_add_cred_args(
+ OM_uint32 *minor_status,
+ gss_cred_id_t input_cred_handle,
+ gss_cred_id_t *output_cred_handle,
+ gss_OID_set *actual_mechs,
+ OM_uint32 *initiator_time_rec,
+ OM_uint32 *acceptor_time_rec)
+{
+
+ /* Initialize outputs. */
+
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (output_cred_handle != NULL)
+ *output_cred_handle = GSS_C_NO_CREDENTIAL;
+
+ if (actual_mechs != NULL)
+ *actual_mechs = GSS_C_NO_OID_SET;
+
+ if (acceptor_time_rec != NULL)
+ *acceptor_time_rec = 0;
+
+ if (initiator_time_rec != NULL)
+ *initiator_time_rec = 0;
+
+ /* Validate arguments. */
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (input_cred_handle == GSS_C_NO_CREDENTIAL &&
+ output_cred_handle == NULL)
+
+ return (GSS_S_CALL_INACCESSIBLE_WRITE | GSS_S_NO_CRED);
+
+ return (GSS_S_COMPLETE);
+}
+
/* V2 INTERFACE */
OM_uint32
gss_add_cred(minor_status, input_cred_handle,
@@ -240,26 +303,14 @@ gss_add_cred(minor_status, input_cred_handle,
gss_OID new_mechs_array = NULL;
gss_cred_id_t *new_cred_array = NULL;
- /* check input parameters */
- if (minor_status == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
- *minor_status = 0;
-
- if (input_cred_handle == GSS_C_NO_CREDENTIAL &&
- output_cred_handle == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE | GSS_S_NO_CRED);
-
- if (output_cred_handle)
- *output_cred_handle = GSS_C_NO_CREDENTIAL;
-
- if (actual_mechs)
- *actual_mechs = NULL;
-
- if (acceptor_time_rec)
- *acceptor_time_rec = 0;
-
- if (initiator_time_rec)
- *initiator_time_rec = 0;
+ status = val_add_cred_args(minor_status,
+ input_cred_handle,
+ output_cred_handle,
+ actual_mechs,
+ initiator_time_rec,
+ acceptor_time_rec);
+ if (status != GSS_S_COMPLETE)
+ return (status);
mech = __gss_get_mechanism(desired_mech);
if (!mech)
diff --git a/usr/src/lib/libgss/g_canon_name.c b/usr/src/lib/libgss/g_canon_name.c
index 6dcdc9606e..e97fc0a5cc 100644
--- a/usr/src/lib/libgss/g_canon_name.c
+++ b/usr/src/lib/libgss/g_canon_name.c
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* routine gss_canonicalize_name
*
@@ -45,6 +43,32 @@
#include <string.h>
#include <errno.h>
+static OM_uint32 val_canon_name_args(
+ OM_uint32 *minor_status,
+ const gss_name_t input_name,
+ const gss_OID mech_type,
+ gss_name_t *output_name)
+{
+
+ /* Initialize outputs. */
+
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (output_name != NULL)
+ *output_name = GSS_C_NO_NAME;
+
+ /* Validate arguments. */
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (input_name == GSS_C_NO_NAME || mech_type == GSS_C_NULL_OID)
+ return (GSS_S_CALL_INACCESSIBLE_READ);
+
+ return (GSS_S_COMPLETE);
+}
+
OM_uint32
gss_canonicalize_name(minor_status,
input_name,
@@ -58,17 +82,15 @@ gss_name_t *output_name;
gss_union_name_t in_union, out_union = NULL, dest_union = NULL;
OM_uint32 major_status = GSS_S_FAILURE;
- if (minor_status == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
-
- *minor_status = 0;
+ major_status = val_canon_name_args(minor_status,
+ input_name,
+ mech_type,
+ output_name);
+ if (major_status != GSS_S_COMPLETE)
+ return (major_status);
- if (output_name)
- *output_name = 0;
-
- /* check the input parameters */
- if (input_name == NULL || mech_type == GSS_C_NULL_OID)
- return (GSS_S_CALL_INACCESSIBLE_READ);
+ /* Initial value needed below. */
+ major_status = GSS_S_FAILURE;
in_union = (gss_union_name_t)input_name;
/*
diff --git a/usr/src/lib/libgss/g_compare_name.c b/usr/src/lib/libgss/g_compare_name.c
index 1fefbee01f..0a04ba4ec2 100644
--- a/usr/src/lib/libgss/g_compare_name.c
+++ b/usr/src/lib/libgss/g_compare_name.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine for gss_compare_name
*
@@ -37,6 +34,30 @@
#endif
#include <string.h>
+static OM_uint32
+val_comp_name_args(
+ OM_uint32 *minor_status,
+ gss_name_t name1,
+ gss_name_t name2,
+ int *name_equal)
+{
+
+ /* Initialize outputs. */
+
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ /* Validate arguments. */
+
+ if (name1 == GSS_C_NO_NAME || name2 == GSS_C_NO_NAME)
+ return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
+
+ if (name_equal == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ return (GSS_S_COMPLETE);
+}
+
OM_uint32
gss_compare_name(minor_status,
name1,
@@ -54,15 +75,10 @@ int *name_equal;
gss_mechanism mech;
gss_name_t internal_name;
- if (minor_status == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
- *minor_status = 0;
-
- if (name1 == 0 || name2 == 0)
- return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
-
- if (name_equal == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
+ major_status = val_comp_name_args(minor_status,
+ name1, name2, name_equal);
+ if (major_status != GSS_S_COMPLETE)
+ return (major_status);
union_name1 = (gss_union_name_t)name1;
union_name2 = (gss_union_name_t)name2;
diff --git a/usr/src/lib/libgss/g_delete_sec_context.c b/usr/src/lib/libgss/g_delete_sec_context.c
index bb089c08cf..149062a941 100644
--- a/usr/src/lib/libgss/g_delete_sec_context.c
+++ b/usr/src/lib/libgss/g_delete_sec_context.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright (c) 1996,1997, by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine for gss_delete_sec_context
*/
@@ -36,6 +33,34 @@
#include <stdlib.h>
#endif
+static OM_uint32
+val_del_sec_ctx_args(
+ OM_uint32 *minor_status,
+ gss_ctx_id_t *context_handle,
+ gss_buffer_t output_token)
+{
+
+ /* Initialize outputs. */
+
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (output_token != GSS_C_NO_BUFFER) {
+ output_token->length = 0;
+ output_token->value = NULL;
+ }
+
+ /* Validate arguments. */
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (context_handle == NULL || *context_handle == GSS_C_NO_CONTEXT)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE | GSS_S_NO_CONTEXT);
+
+ return (GSS_S_COMPLETE);
+}
+
OM_uint32
gss_delete_sec_context(minor_status,
context_handle,
@@ -50,12 +75,11 @@ gss_buffer_t output_token;
gss_union_ctx_id_t ctx;
gss_mechanism mech;
- if (minor_status == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
-
- /* if the context_handle is Null, return NO_CONTEXT error */
- if (context_handle == NULL || *context_handle == GSS_C_NO_CONTEXT)
- return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
+ status = val_del_sec_ctx_args(minor_status,
+ context_handle,
+ output_token);
+ if (status != GSS_S_COMPLETE)
+ return (status);
/*
* select the approprate underlying mechanism routine and
diff --git a/usr/src/lib/libgss/g_dsp_name.c b/usr/src/lib/libgss/g_dsp_name.c
index b027ff466f..471bf38e24 100644
--- a/usr/src/lib/libgss/g_dsp_name.c
+++ b/usr/src/lib/libgss/g_dsp_name.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine for gss_display_name()
*
@@ -38,6 +35,41 @@
#endif
#include <string.h>
+static OM_uint32
+val_dsp_name_args(
+ OM_uint32 *minor_status,
+ gss_name_t input_name,
+ gss_buffer_t output_name_buffer,
+ gss_OID *output_name_type)
+{
+
+ /* Initialize outputs. */
+
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (output_name_buffer != GSS_C_NO_BUFFER) {
+ output_name_buffer->length = 0;
+ output_name_buffer->value = NULL;
+ }
+
+ if (output_name_type != NULL)
+ *output_name_type = GSS_C_NO_OID;
+
+ /* Validate arguments. */
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (output_name_buffer == GSS_C_NO_BUFFER)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (input_name == GSS_C_NO_NAME)
+ return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
+
+ return (GSS_S_COMPLETE);
+}
+
OM_uint32
gss_display_name(minor_status,
input_name,
@@ -53,18 +85,10 @@ gss_OID * output_name_type;
OM_uint32 major_status;
gss_union_name_t union_name;
- if (minor_status == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
- *minor_status = 0;
-
- if (input_name == 0)
- return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
-
- if (output_name_buffer == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
-
- if (output_name_type)
- *output_name_type = NULL;
+ major_status = val_dsp_name_args(minor_status, input_name,
+ output_name_buffer, output_name_type);
+ if (major_status != GSS_S_COMPLETE)
+ return (major_status);
union_name = (gss_union_name_t)input_name;
diff --git a/usr/src/lib/libgss/g_dsp_status.c b/usr/src/lib/libgss/g_dsp_status.c
index 8ea9afacac..0d1da795de 100644
--- a/usr/src/lib/libgss/g_dsp_status.c
+++ b/usr/src/lib/libgss/g_dsp_status.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine gss_display_status
*
@@ -66,18 +63,19 @@ gss_buffer_t status_string;
gss_OID mech_type = (gss_OID) req_mech_type;
gss_mechanism mech;
- /* check the input parameters */
- if (!minor_status)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
+ if (minor_status != NULL)
+ *minor_status = 0;
- *minor_status = 0;
+ if (status_string != GSS_C_NO_BUFFER) {
+ status_string->length = 0;
+ status_string->value = NULL;
+ }
- if (!message_context || status_string == NULL)
+ if (minor_status == NULL ||
+ message_context == NULL ||
+ status_string == GSS_C_NO_BUFFER)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
- status_string->length = 0;
- status_string->value = NULL;
-
/* we handle major status codes, and the mechs do the minor */
if (status_type == GSS_C_GSS_CODE)
return (displayMajor(status_value, message_context,
diff --git a/usr/src/lib/libgss/g_dup_name.c b/usr/src/lib/libgss/g_dup_name.c
index e60220581b..0ea8ea53aa 100644
--- a/usr/src/lib/libgss/g_dup_name.c
+++ b/usr/src/lib/libgss/g_dup_name.c
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* routine gss_duplicate_name
*
@@ -39,6 +37,36 @@
#include <string.h>
#include <errno.h>
+static OM_uint32
+val_dup_name_args(
+ OM_uint32 *minor_status,
+ const gss_name_t src_name,
+ gss_name_t *dest_name)
+{
+
+ /* Initialize outputs. */
+
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (dest_name != NULL)
+ *dest_name = GSS_C_NO_NAME;
+
+ /* Validate arguments. */
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ /* if output_name is NULL, simply return */
+ if (dest_name == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (src_name == GSS_C_NO_NAME)
+ return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
+
+ return (GSS_S_COMPLETE);
+}
+
OM_uint32
gss_duplicate_name(minor_status,
src_name,
@@ -50,20 +78,11 @@ gss_name_t *dest_name;
gss_union_name_t src_union, dest_union;
OM_uint32 major_status = GSS_S_FAILURE;
+ major_status = val_dup_name_args(minor_status, src_name, dest_name);
+ if (major_status != GSS_S_COMPLETE)
+ return (major_status);
- if (!minor_status)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
-
- *minor_status = 0;
-
- /* if output_name is NULL, simply return */
- if (dest_name == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE | GSS_S_BAD_NAME);
-
- *dest_name = 0;
-
- if (src_name == NULL)
- return (GSS_S_CALL_INACCESSIBLE_READ);
+ major_status = GSS_S_FAILURE;
src_union = (gss_union_name_t)src_name;
diff --git a/usr/src/lib/libgss/g_exp_sec_context.c b/usr/src/lib/libgss/g_exp_sec_context.c
index 954ac9dec1..d0e054a9fd 100644
--- a/usr/src/lib/libgss/g_exp_sec_context.c
+++ b/usr/src/lib/libgss/g_exp_sec_context.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine for gss_export_sec_context
*/
@@ -38,6 +35,36 @@
#endif
#include <string.h>
+static OM_uint32 val_exp_sec_ctx_args(
+ OM_uint32 *minor_status,
+ gss_ctx_id_t *context_handle,
+ gss_buffer_t interprocess_token)
+{
+
+ /* Initialize outputs. */
+
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (interprocess_token != GSS_C_NO_BUFFER) {
+ interprocess_token->length = 0;
+ interprocess_token->value = NULL;
+ }
+
+ /* Validate arguments. */
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (context_handle == NULL || *context_handle == GSS_C_NO_CONTEXT)
+ return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
+
+ if (interprocess_token == GSS_C_NO_BUFFER)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ return (GSS_S_COMPLETE);
+}
+
OM_uint32
gss_export_sec_context(minor_status,
context_handle,
@@ -55,15 +82,10 @@ gss_buffer_t interprocess_token;
gss_buffer_desc token;
char *buf;
- if (minor_status == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
- *minor_status = 0;
-
- if (context_handle == NULL || *context_handle == GSS_C_NO_CONTEXT)
- return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
-
- if (interprocess_token == NULL)
- return (GSS_S_CALL_INACCESSIBLE_READ);
+ status = val_exp_sec_ctx_args(minor_status,
+ context_handle, interprocess_token);
+ if (status != GSS_S_COMPLETE)
+ return (status);
/*
* select the approprate underlying mechanism routine and
diff --git a/usr/src/lib/libgss/g_export_name.c b/usr/src/lib/libgss/g_export_name.c
index 2b81c39f9c..89a9d45bc8 100644
--- a/usr/src/lib/libgss/g_export_name.c
+++ b/usr/src/lib/libgss/g_export_name.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright (c) 1996,1997, by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine gss_export_name
*
@@ -50,19 +47,22 @@ gss_buffer_t exported_name;
{
gss_union_name_t union_name;
+ /* Initialize outputs. */
- if (minor_status)
+ if (minor_status != NULL)
*minor_status = 0;
- /* check out parameter */
- if (!exported_name)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
+ if (exported_name != GSS_C_NO_BUFFER) {
+ exported_name->value = NULL;
+ exported_name->length = 0;
+ }
- exported_name->value = NULL;
- exported_name->length = 0;
+ /* Validate arguments. */
+
+ if (minor_status == NULL || exported_name == GSS_C_NO_BUFFER)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
- /* check input parameter */
- if (!input_name)
+ if (input_name == GSS_C_NO_NAME)
return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
union_name = (gss_union_name_t)input_name;
diff --git a/usr/src/lib/libgss/g_imp_name.c b/usr/src/lib/libgss/g_imp_name.c
index 9f3a58f62c..43177c95ce 100644
--- a/usr/src/lib/libgss/g_imp_name.c
+++ b/usr/src/lib/libgss/g_imp_name.c
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine gss_import_name
*
@@ -44,6 +42,37 @@ get_der_length(unsigned char **, unsigned int, unsigned int *);
/* local function to import GSS_C_EXPORT_NAME names */
static OM_uint32 importExportName(OM_uint32 *, gss_union_name_t);
+static OM_uint32
+val_imp_name_args(
+ OM_uint32 *minor_status,
+ gss_buffer_t input_name_buffer,
+ gss_name_t *output_name)
+{
+
+ /* Initialize outputs. */
+
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (output_name != NULL)
+ *output_name = GSS_C_NO_NAME;
+
+ /* Validate arguments. */
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (output_name == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (input_name_buffer == GSS_C_NO_BUFFER)
+ return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
+
+ if (GSS_EMPTY_BUFFER(input_name_buffer))
+ return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
+
+ return (GSS_S_COMPLETE);
+}
OM_uint32
gss_import_name(minor_status,
@@ -59,19 +88,11 @@ gss_name_t *output_name;
gss_union_name_t union_name;
OM_uint32 major_status = GSS_S_FAILURE, tmp;
- /* check output parameters */
- if (!minor_status)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
-
- *minor_status = 0;
-
- if (GSS_EMPTY_BUFFER(input_name_buffer))
- return (GSS_S_CALL_INACCESSIBLE_READ);
-
- if (output_name == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
-
- *output_name = 0;
+ major_status = val_imp_name_args(minor_status,
+ input_name_buffer,
+ output_name);
+ if (major_status != GSS_S_COMPLETE)
+ return (major_status);
/*
* First create the union name struct that will hold the external
diff --git a/usr/src/lib/libgss/g_imp_sec_context.c b/usr/src/lib/libgss/g_imp_sec_context.c
index a34ebd1ec8..db3544653c 100644
--- a/usr/src/lib/libgss/g_imp_sec_context.c
+++ b/usr/src/lib/libgss/g_imp_sec_context.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine gss_export_sec_context
*/
@@ -36,6 +33,37 @@
#include <stdlib.h>
#include <string.h>
+static OM_uint32
+val_imp_sec_ctx_args(
+ OM_uint32 *minor_status,
+ gss_buffer_t interprocess_token,
+ gss_ctx_id_t *context_handle)
+{
+
+ /* Initialize outputs. */
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (context_handle != NULL)
+ *context_handle = GSS_C_NO_CONTEXT;
+
+ /* Validate arguments. */
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (context_handle == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (interprocess_token == GSS_C_NO_BUFFER)
+ return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_DEFECTIVE_TOKEN);
+
+ if (GSS_EMPTY_BUFFER(interprocess_token))
+ return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_DEFECTIVE_TOKEN);
+
+ return (GSS_S_COMPLETE);
+}
+
OM_uint32
gss_import_sec_context(minor_status,
interprocess_token,
@@ -53,17 +81,12 @@ gss_ctx_id_t *context_handle;
gss_buffer_desc token;
gss_mechanism mech;
- if (minor_status == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
- *minor_status = 0;
-
- if (context_handle == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE | GSS_S_NO_CONTEXT);
- *context_handle = GSS_C_NO_CONTEXT;
-
- if (GSS_EMPTY_BUFFER(interprocess_token))
- return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_DEFECTIVE_TOKEN);
+ status = val_imp_sec_ctx_args(minor_status,
+ interprocess_token, context_handle);
+ if (status != GSS_S_COMPLETE)
+ return (status);
+ /* Initial value needed below. */
status = GSS_S_FAILURE;
ctx = (gss_union_ctx_id_t)malloc(sizeof (gss_union_ctx_id_desc));
diff --git a/usr/src/lib/libgss/g_init_sec_context.c b/usr/src/lib/libgss/g_init_sec_context.c
index c0743e41bf..814b28a784 100644
--- a/usr/src/lib/libgss/g_init_sec_context.c
+++ b/usr/src/lib/libgss/g_init_sec_context.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine for gss_init_sec_context
*/
@@ -34,6 +31,45 @@
#include <stdlib.h>
#include <string.h>
+static OM_uint32
+val_init_sec_ctx_args(
+ OM_uint32 *minor_status,
+ gss_ctx_id_t *context_handle,
+ gss_name_t target_name,
+ gss_OID *actual_mech_type,
+ gss_buffer_t output_token)
+{
+
+ /* Initialize outputs. */
+
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (actual_mech_type != NULL)
+ *actual_mech_type = GSS_C_NO_OID;
+
+ if (output_token != GSS_C_NO_BUFFER) {
+ output_token->length = 0;
+ output_token->value = NULL;
+ }
+
+ /* Validate arguments. */
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (context_handle == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE | GSS_S_NO_CONTEXT);
+
+ if (target_name == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
+
+ if (output_token == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ return (GSS_S_COMPLETE);
+}
+
OM_uint32
gss_init_sec_context(minor_status,
claimant_cred_handle,
@@ -73,26 +109,13 @@ OM_uint32 * time_rec;
gss_mechanism mech;
gss_cred_id_t input_cred_handle;
- if (minor_status == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
- *minor_status = 0;
-
- /* clear output values */
- if (actual_mech_type)
- *actual_mech_type = NULL;
-
- if (context_handle == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE | GSS_S_NO_CONTEXT);
-
- if (target_name == NULL)
- return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME);
-
- if (output_token == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
-
- output_token->value = NULL;
- output_token->length = 0;
-
+ status = val_init_sec_ctx_args(minor_status,
+ context_handle,
+ target_name,
+ actual_mech_type,
+ output_token);
+ if (status != GSS_S_COMPLETE)
+ return (status);
if (req_mech_type)
mech_type = (gss_OID)req_mech_type;
diff --git a/usr/src/lib/libgss/g_initialize.c b/usr/src/lib/libgss/g_initialize.c
index dbfa43d405..3c6dbd5d5f 100644
--- a/usr/src/lib/libgss/g_initialize.c
+++ b/usr/src/lib/libgss/g_initialize.c
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains functions to initialize the gssapi library and
* load mechanism libraries.
@@ -189,14 +187,16 @@ gss_OID_set *mechSet;
int count, i, j;
gss_OID curItem;
- if (!minorStatus)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
+ /* Initialize outputs. */
- *minorStatus = 0;
+ if (minorStatus != NULL)
+ *minorStatus = 0;
+ if (mechSet != NULL)
+ *mechSet = GSS_C_NO_OID_SET;
- /* check output parameter */
- if (mechSet == NULL)
+ /* Validate arguments. */
+ if (minorStatus == NULL || mechSet == NULL)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
fileName = MECH_CONF;
diff --git a/usr/src/lib/libgss/g_inquire_context.c b/usr/src/lib/libgss/g_inquire_context.c
index 09ce566d3b..b4044aa99c 100644
--- a/usr/src/lib/libgss/g_inquire_context.c
+++ b/usr/src/lib/libgss/g_inquire_context.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine for gss_inquire_context
*/
@@ -33,6 +30,40 @@
#include <mechglueP.h>
#include <stdlib.h>
+static OM_uint32
+val_inq_ctx_args(
+ OM_uint32 *minor_status,
+ gss_ctx_id_t context_handle,
+ gss_name_t *src_name,
+ gss_name_t *targ_name,
+ gss_OID *mech_type)
+{
+
+ /* Initialize outputs. */
+
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (src_name != NULL)
+ *src_name = GSS_C_NO_NAME;
+
+ if (targ_name != NULL)
+ *targ_name = GSS_C_NO_NAME;
+
+ if (mech_type != NULL)
+ *mech_type = GSS_C_NO_OID;
+
+ /* Validate arguments. */
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (context_handle == GSS_C_NO_CONTEXT)
+ return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
+
+ return (GSS_S_COMPLETE);
+}
+
/* Last argument new for V2 */
OM_uint32
gss_inquire_context(
@@ -62,24 +93,13 @@ int *open;
OM_uint32 status, temp_minor;
gss_name_t localTargName = NULL, localSourceName = NULL;
- if (!minor_status)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
-
- *minor_status = 0;
-
- /* if the context_handle is Null, return NO_CONTEXT error */
- if (context_handle == GSS_C_NO_CONTEXT)
- return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
-
- /* set all output value to NULL */
- if (src_name)
- *src_name = NULL;
-
- if (targ_name)
- *targ_name = NULL;
-
- if (mech_type)
- *mech_type = NULL;
+ status = val_inq_ctx_args(minor_status,
+ context_handle,
+ src_name,
+ targ_name,
+ mech_type);
+ if (status != GSS_S_COMPLETE)
+ return (status);
/*
* select the approprate underlying mechanism routine and
diff --git a/usr/src/lib/libgss/g_inquire_cred.c b/usr/src/lib/libgss/g_inquire_cred.c
index f7b4d025c4..4f185f8499 100644
--- a/usr/src/lib/libgss/g_inquire_cred.c
+++ b/usr/src/lib/libgss/g_inquire_cred.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine for gss_inquire_cred
*/
@@ -58,16 +55,20 @@ gss_OID_set *mechanisms;
gss_name_t internal_name;
int i;
- /* check parms and set to defaults */
- if (minor_status == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
- *minor_status = 0;
+ /* Initialize outputs. */
- if (name)
- *name = NULL;
+ if (minor_status != NULL)
+ *minor_status = 0;
- if (mechanisms)
- *mechanisms = NULL;
+ if (name != NULL)
+ *name = GSS_C_NO_NAME;
+
+ if (mechanisms != NULL)
+ *mechanisms = GSS_C_NO_OID_SET;
+
+ /* Validate arguments. */
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
if (cred_handle == GSS_C_NO_CREDENTIAL) {
/*
@@ -222,6 +223,14 @@ gss_inquire_cred_by_mech(minor_status, cred_handle, mech_type, name,
OM_uint32 status, temp_minor_status;
gss_name_t internal_name;
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (name != NULL)
+ *name = GSS_C_NO_NAME;
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
mech = __gss_get_mechanism(mech_type);
if (!mech)
diff --git a/usr/src/lib/libgss/g_inquire_names.c b/usr/src/lib/libgss/g_inquire_names.c
index d24895bd90..9ee1567b33 100644
--- a/usr/src/lib/libgss/g_inquire_names.c
+++ b/usr/src/lib/libgss/g_inquire_names.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine for gss_inquire_context
*/
@@ -46,9 +43,18 @@ gss_OID_set * name_types;
OM_uint32 status;
gss_mechanism mech;
+ /* Initialize outputs. */
+
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (name_types != NULL)
+ *name_types = GSS_C_NO_OID_SET;
+
+ /* Validate arguments. */
+
if (minor_status == NULL)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
- *minor_status = 0;
if (name_types == NULL)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
@@ -77,6 +83,30 @@ gss_OID_set * name_types;
return (GSS_S_BAD_MECH);
}
+static OM_uint32 val_inq_mechs4name_args(
+ OM_uint32 *minor_status,
+ const gss_name_t input_name,
+ gss_OID_set *mech_set)
+{
+
+ /* Initialize outputs. */
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (mech_set != NULL)
+ *mech_set = GSS_C_NO_OID_SET;
+
+ /* Validate arguments. */
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (input_name == GSS_C_NO_NAME)
+ return (GSS_S_BAD_NAME);
+
+ return (GSS_S_COMPLETE);
+}
+
OM_uint32
gss_inquire_mechs_for_name(minor_status, input_name, mech_set)
@@ -95,12 +125,9 @@ gss_OID_set * mech_set;
gss_buffer_desc name_buffer;
int i;
- if (minor_status == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
- *minor_status = 0;
-
- if (input_name == NULL)
- return (GSS_S_BAD_NAME);
+ status = val_inq_mechs4name_args(minor_status, input_name, mech_set);
+ if (status != GSS_S_COMPLETE)
+ return (status);
status = gss_create_empty_oid_set(minor_status, mech_set);
if (status != GSS_S_COMPLETE)
diff --git a/usr/src/lib/libgss/g_process_context.c b/usr/src/lib/libgss/g_process_context.c
index b1f3b18c94..5753dc8441 100644
--- a/usr/src/lib/libgss/g_process_context.c
+++ b/usr/src/lib/libgss/g_process_context.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright (c) 1996,1997, by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine gss_process_context
*/
@@ -53,6 +50,9 @@ gss_buffer_t token_buffer;
if (context_handle == GSS_C_NO_CONTEXT)
return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
+ if (token_buffer == GSS_C_NO_BUFFER)
+ return (GSS_S_CALL_INACCESSIBLE_READ);
+
if (GSS_EMPTY_BUFFER(token_buffer))
return (GSS_S_CALL_INACCESSIBLE_READ);
diff --git a/usr/src/lib/libgss/g_seal.c b/usr/src/lib/libgss/g_seal.c
index db1fac77da..19725d9f51 100644
--- a/usr/src/lib/libgss/g_seal.c
+++ b/usr/src/lib/libgss/g_seal.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,18 +19,51 @@
* CDDL HEADER END
*/
/*
- * Copyright (c) 1996,1997, by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine for gss_seal
*/
#include <mechglueP.h>
+static OM_uint32
+val_seal_args(
+ OM_uint32 *minor_status,
+ gss_ctx_id_t context_handle,
+ gss_buffer_t input_message_buffer,
+ gss_buffer_t output_message_buffer)
+{
+
+ /* Initialize outputs. */
+
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (output_message_buffer != GSS_C_NO_BUFFER) {
+ output_message_buffer->length = 0;
+ output_message_buffer->value = NULL;
+ }
+
+ /* Validate arguments. */
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (context_handle == GSS_C_NO_CONTEXT)
+ return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
+
+ if (input_message_buffer == GSS_C_NO_BUFFER)
+ return (GSS_S_CALL_INACCESSIBLE_READ);
+
+ if (output_message_buffer == GSS_C_NO_BUFFER)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ return (GSS_S_COMPLETE);
+}
+
/*ARGSUSED*/
OM_uint32
gss_seal(minor_status,
@@ -56,19 +88,12 @@ gss_buffer_t output_message_buffer;
gss_union_ctx_id_t ctx;
gss_mechanism mech;
-
- if (minor_status == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
- *minor_status = 0;
-
- if (context_handle == GSS_C_NO_CONTEXT)
- return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
-
- if (input_message_buffer == NULL)
- return (GSS_S_CALL_INACCESSIBLE_READ);
-
- if (output_message_buffer == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
+ status = val_seal_args(minor_status,
+ context_handle,
+ input_message_buffer,
+ output_message_buffer);
+ if (status != GSS_S_COMPLETE)
+ return (status);
/*
* select the approprate underlying mechanism routine and
diff --git a/usr/src/lib/libgss/g_sign.c b/usr/src/lib/libgss/g_sign.c
index fa5edbd54d..809c894929 100644
--- a/usr/src/lib/libgss/g_sign.c
+++ b/usr/src/lib/libgss/g_sign.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,18 +19,51 @@
* CDDL HEADER END
*/
/*
- * Copyright (c) 1996,1997, by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine gss_sign
*/
#include <mechglueP.h>
+static OM_uint32
+val_sign_args(
+ OM_uint32 *minor_status,
+ gss_ctx_id_t context_handle,
+ gss_buffer_t message_buffer,
+ gss_buffer_t msg_token)
+{
+
+ /* Initialize outputs. */
+
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (msg_token != GSS_C_NO_BUFFER) {
+ msg_token->value = NULL;
+ msg_token->length = 0;
+ }
+
+ /* Validate arguments. */
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (context_handle == GSS_C_NO_CONTEXT)
+ return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
+
+ if (message_buffer == GSS_C_NO_BUFFER)
+ return (GSS_S_CALL_INACCESSIBLE_READ);
+
+ if (msg_token == GSS_C_NO_BUFFER)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ return (GSS_S_COMPLETE);
+}
+
OM_uint32
gss_sign(minor_status,
context_handle,
@@ -50,21 +82,11 @@ gss_buffer_t msg_token;
gss_union_ctx_id_t ctx;
gss_mechanism mech;
- if (minor_status == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
- *minor_status = 0;
-
- if (context_handle == GSS_C_NO_CONTEXT)
- return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
-
- if (message_buffer == NULL)
- return (GSS_S_CALL_INACCESSIBLE_READ);
-
- if (msg_token == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE);
+ status = val_sign_args(minor_status, context_handle,
+ message_buffer, msg_token);
+ if (status != GSS_S_COMPLETE)
+ return (status);
- msg_token->value = NULL;
- msg_token->length = 0;
/*
* select the approprate underlying mechanism routine and
* call it.
diff --git a/usr/src/lib/libgss/g_store_cred.c b/usr/src/lib/libgss/g_store_cred.c
index 5191640c28..26b118e264 100644
--- a/usr/src/lib/libgss/g_store_cred.c
+++ b/usr/src/lib/libgss/g_store_cred.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,18 +19,41 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine for gss_store_cred
*/
#include <mechglueP.h>
+static OM_uint32 val_store_cred_args(
+ OM_uint32 *minor_status,
+ const gss_cred_id_t input_cred_handle,
+ gss_OID_set *elements_stored)
+{
+
+ /* Initialize outputs. */
+
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (elements_stored != NULL)
+ *elements_stored = GSS_C_NULL_OID_SET;
+
+ /* Validate arguments. */
+
+ if (minor_status == NULL)
+ return (GSS_S_CALL_INACCESSIBLE_WRITE);
+
+ if (input_cred_handle == GSS_C_NO_CREDENTIAL)
+ return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CRED);
+
+ return (GSS_S_COMPLETE);
+}
+
OM_uint32 gss_store_cred(minor_status,
input_cred_handle,
cred_usage,
@@ -58,16 +80,14 @@ gss_cred_usage_t *cred_usage_stored;
gss_OID dmech;
int i;
- /* Start by checking parameters */
- if (minor_status == NULL)
- return (GSS_S_CALL_INACCESSIBLE_WRITE|GSS_S_NO_CRED);
- *minor_status = 0;
-
- if (input_cred_handle == GSS_C_NO_CREDENTIAL)
- return (GSS_S_CALL_INACCESSIBLE_READ);
+ major_status = val_store_cred_args(minor_status,
+ input_cred_handle,
+ elements_stored);
+ if (major_status != GSS_S_COMPLETE)
+ return (major_status);
- if (elements_stored != NULL)
- *elements_stored = GSS_C_NULL_OID_SET;
+ /* Initial value needed below. */
+ major_status = GSS_S_FAILURE;
if (cred_usage_stored != NULL)
*cred_usage_stored = GSS_C_BOTH; /* there's no GSS_C_NEITHER */
diff --git a/usr/src/lib/libgss/g_unseal.c b/usr/src/lib/libgss/g_unseal.c
index 05c8e21eff..9dd7243032 100644
--- a/usr/src/lib/libgss/g_unseal.c
+++ b/usr/src/lib/libgss/g_unseal.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright (c) 1996,1997, by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine gss_unseal
*/
@@ -53,22 +50,27 @@ int * qop_state;
gss_union_ctx_id_t ctx;
gss_mechanism mech;
+ if (minor_status != NULL)
+ *minor_status = 0;
+
+ if (output_message_buffer != GSS_C_NO_BUFFER) {
+ output_message_buffer->length = 0;
+ output_message_buffer->value = NULL;
+ }
+
if (minor_status == NULL)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
- *minor_status = 0;
if (context_handle == GSS_C_NO_CONTEXT)
return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
- if (GSS_EMPTY_BUFFER(input_message_buffer))
+ if (input_message_buffer == GSS_C_NO_BUFFER ||
+ GSS_EMPTY_BUFFER(input_message_buffer))
return (GSS_S_CALL_INACCESSIBLE_READ);
- if (output_message_buffer == NULL)
+ if (output_message_buffer == GSS_C_NO_BUFFER)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
- output_message_buffer->length = 0;
- output_message_buffer->value = NULL;
-
/*
* select the approprate underlying mechanism routine and
* call it.
diff --git a/usr/src/lib/libgss/g_verify.c b/usr/src/lib/libgss/g_verify.c
index 2d4ec3de53..774ba13583 100644
--- a/usr/src/lib/libgss/g_verify.c
+++ b/usr/src/lib/libgss/g_verify.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright (c) 1996,1997, by Sun Microsystems, Inc.
- * All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* glue routine for gss_verify
*/
@@ -49,7 +46,6 @@ int * qop_state;
gss_union_ctx_id_t ctx;
gss_mechanism mech;
-
if (minor_status == NULL)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
*minor_status = 0;
@@ -57,7 +53,8 @@ int * qop_state;
if (context_handle == GSS_C_NO_CONTEXT)
return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
- if ((message_buffer == NULL) || GSS_EMPTY_BUFFER(token_buffer))
+ if ((message_buffer == GSS_C_NO_BUFFER) ||
+ GSS_EMPTY_BUFFER(token_buffer))
return (GSS_S_CALL_INACCESSIBLE_READ);
/*
diff --git a/usr/src/lib/libgss/oid_ops.c b/usr/src/lib/libgss/oid_ops.c
index 3e806b510b..c080c8e51c 100644
--- a/usr/src/lib/libgss/oid_ops.c
+++ b/usr/src/lib/libgss/oid_ops.c
@@ -1,10 +1,28 @@
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* lib/gssapi/generic/oid_ops.c
*
@@ -58,7 +76,7 @@ gss_OID *oid;
if (minor_status)
*minor_status = 0;
- if (*oid == GSS_C_NO_OID)
+ if (oid == NULL || *oid == GSS_C_NO_OID)
return (GSS_S_COMPLETE);
/*
@@ -245,13 +263,18 @@ gss_buffer_t oid_str;
unsigned char *cp;
char *bp;
- if (minor_status)
+ if (minor_status != NULL)
*minor_status = 0;
+ if (oid_str != GSS_C_NO_BUFFER) {
+ oid_str->length = 0;
+ oid_str->value = NULL;
+ }
+
if (oid == GSS_C_NO_OID || oid->length == 0 || oid->elements == NULL)
return (GSS_S_CALL_INACCESSIBLE_READ);
- if (oid_str == NULL)
+ if (oid_str == GSS_C_NO_BUFFER)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
/* First determine the size of the string */
@@ -331,9 +354,12 @@ gss_OID *oid;
int index;
unsigned char *op;
- if (minor_status)
+ if (minor_status != NULL)
*minor_status = 0;
+ if (oid != NULL)
+ *oid = GSS_C_NO_OID;
+
if (GSS_EMPTY_BUFFER(oid_str))
return (GSS_S_CALL_INACCESSIBLE_READ);
@@ -482,17 +508,18 @@ gss_copy_oid_set(
OM_uint32 major = GSS_S_COMPLETE;
OM_uint32 index;
- if (minor_status)
+ if (minor_status != NULL)
*minor_status = 0;
- if (oidset == NULL)
+ if (new_oidset != NULL)
+ *new_oidset = GSS_C_NO_OID_SET;
+
+ if (oidset == GSS_C_NO_OID_SET)
return (GSS_S_CALL_INACCESSIBLE_READ);
if (new_oidset == NULL)
return (GSS_S_CALL_INACCESSIBLE_WRITE);
- *new_oidset = NULL;
-
if ((copy = (gss_OID_set_desc *) calloc(1, sizeof (*copy))) == NULL) {
major = GSS_S_FAILURE;
goto done;