Coding Style related fixes
authorZhanna Tsitkov <tsitkova@mit.edu>
Wed, 25 Nov 2009 19:03:29 +0000 (19:03 +0000)
committerZhanna Tsitkov <tsitkova@mit.edu>
Wed, 25 Nov 2009 19:03:29 +0000 (19:03 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23356 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/gssapi/generic/oid_ops.c
src/lib/gssapi/generic/util_buffer_set.c
src/lib/gssapi/mechglue/g_seal.c

index bda3a5ab574dfb3a137a3422a7029eb4de673085..d7cd5a444273131286567e264bd3843972c78a8f 100644 (file)
@@ -1,4 +1,4 @@
-/* #pragma ident       "@(#)oid_ops.c  1.19    04/02/23 SMI" */
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 /*
  * lib/gssapi/generic/oid_ops.c
  *
 #include <ctype.h>
 
 OM_uint32
-generic_gss_release_oid(minor_status, oid)
-    OM_uint32  *minor_status;
-    gss_OID    *oid;
+generic_gss_release_oid(OM_uint32 *minor_status, gss_OID *oid)
 {
     if (minor_status)
-       *minor_status = 0;
+        *minor_status = 0;
 
     if (oid == NULL || *oid == GSS_C_NO_OID)
-       return(GSS_S_COMPLETE);
+        return(GSS_S_COMPLETE);
 
     /*
      * The V2 API says the following!
@@ -70,107 +68,103 @@ generic_gss_release_oid(minor_status, oid)
      */
 
     if ((*oid != GSS_C_NT_USER_NAME) &&
-       (*oid != GSS_C_NT_MACHINE_UID_NAME) &&
-       (*oid != GSS_C_NT_STRING_UID_NAME) &&
-       (*oid != GSS_C_NT_HOSTBASED_SERVICE) &&
-       (*oid != GSS_C_NT_ANONYMOUS) &&
-       (*oid != GSS_C_NT_EXPORT_NAME) &&
-       (*oid != gss_nt_service_name)) {
-       free((*oid)->elements);
-       free(*oid);
+        (*oid != GSS_C_NT_MACHINE_UID_NAME) &&
+        (*oid != GSS_C_NT_STRING_UID_NAME) &&
+        (*oid != GSS_C_NT_HOSTBASED_SERVICE) &&
+        (*oid != GSS_C_NT_ANONYMOUS) &&
+        (*oid != GSS_C_NT_EXPORT_NAME) &&
+        (*oid != gss_nt_service_name)) {
+        free((*oid)->elements);
+        free(*oid);
     }
     *oid = GSS_C_NO_OID;
     return(GSS_S_COMPLETE);
 }
 
 OM_uint32
-generic_gss_copy_oid(minor_status, oid, new_oid)
-       OM_uint32       *minor_status;
-       const gss_OID_desc * const oid;
-       gss_OID         *new_oid;
+generic_gss_copy_oid(OM_uint32 *minor_status,
+                     const gss_OID_desc * const oid,
+                     gss_OID *new_oid)
 {
-       gss_OID         p;
-
-       *minor_status = 0;
-
-       p = (gss_OID) malloc(sizeof(gss_OID_desc));
-       if (!p) {
-           *minor_status = ENOMEM;
-           return GSS_S_FAILURE;
-       }
-       p->length = oid->length;
-       p->elements = malloc(p->length);
-       if (!p->elements) {
-               free(p);
-               return GSS_S_FAILURE;
-       }
-       memcpy(p->elements, oid->elements, p->length);
-       *new_oid = p;
-       return(GSS_S_COMPLETE);
+    gss_OID         p;
+
+    *minor_status = 0;
+
+    p = (gss_OID) malloc(sizeof(gss_OID_desc));
+    if (!p) {
+        *minor_status = ENOMEM;
+        return GSS_S_FAILURE;
+    }
+    p->length = oid->length;
+    p->elements = malloc(p->length);
+    if (!p->elements) {
+        free(p);
+        return GSS_S_FAILURE;
+    }
+    memcpy(p->elements, oid->elements, p->length);
+    *new_oid = p;
+    return(GSS_S_COMPLETE);
 }
 
 
 OM_uint32
-generic_gss_create_empty_oid_set(minor_status, oid_set)
-    OM_uint32  *minor_status;
-    gss_OID_set        *oid_set;
+generic_gss_create_empty_oid_set(OM_uint32 *minor_status, gss_OID_set *oid_set)
 {
     *minor_status = 0;
 
     if ((*oid_set = (gss_OID_set) malloc(sizeof(gss_OID_set_desc)))) {
-       memset(*oid_set, 0, sizeof(gss_OID_set_desc));
-       return(GSS_S_COMPLETE);
+        memset(*oid_set, 0, sizeof(gss_OID_set_desc));
+        return(GSS_S_COMPLETE);
     }
     else {
-       *minor_status = ENOMEM;
-       return(GSS_S_FAILURE);
+        *minor_status = ENOMEM;
+        return(GSS_S_FAILURE);
     }
 }
 
 OM_uint32
-generic_gss_add_oid_set_member(minor_status, member_oid, oid_set)
-    OM_uint32  *minor_status;
-    const gss_OID_desc * const member_oid;
-    gss_OID_set        *oid_set;
+generic_gss_add_oid_set_member(OM_uint32 *minor_status,
+                               const gss_OID_desc * const member_oid,
+                               gss_OID_set *oid_set)
 {
-    gss_OID    elist;
-    gss_OID    lastel;
+    gss_OID     elist;
+    gss_OID     lastel;
 
     *minor_status = 0;
 
     if (member_oid == NULL || member_oid->length == 0 ||
-       member_oid->elements == NULL)
-       return (GSS_S_CALL_INACCESSIBLE_READ);
+        member_oid->elements == NULL)
+        return (GSS_S_CALL_INACCESSIBLE_READ);
 
     elist = (*oid_set)->elements;
     /* Get an enlarged copy of the array */
     if (((*oid_set)->elements = (gss_OID) malloc(((*oid_set)->count+1) *
-                                                 sizeof(gss_OID_desc)))) {
-       /* Copy in the old junk */
-       if (elist)
-           memcpy((*oid_set)->elements,
-                  elist,
-                  ((*oid_set)->count * sizeof(gss_OID_desc)));
-
-       /* Duplicate the input element */
-       lastel = &(*oid_set)->elements[(*oid_set)->count];
-       if ((lastel->elements =
-            (void *) malloc((size_t) member_oid->length))) {
-           /* Success - copy elements */
-           memcpy(lastel->elements, member_oid->elements,
-                  (size_t) member_oid->length);
-           /* Set length */
-           lastel->length = member_oid->length;
-
-           /* Update count */
-           (*oid_set)->count++;
-           if (elist)
-               free(elist);
-           *minor_status = 0;
-           return(GSS_S_COMPLETE);
-       }
-       else
-           free((*oid_set)->elements);
+                                                 sizeof(gss_OID_desc)))) {
+        /* Copy in the old junk */
+        if (elist)
+            memcpy((*oid_set)->elements,
+                   elist,
+                   ((*oid_set)->count * sizeof(gss_OID_desc)));
+
+        /* Duplicate the input element */
+        lastel = &(*oid_set)->elements[(*oid_set)->count];
+        if ((lastel->elements =
+             (void *) malloc((size_t) member_oid->length))) {
+            /* Success - copy elements */
+            memcpy(lastel->elements, member_oid->elements,
+                   (size_t) member_oid->length);
+            /* Set length */
+            lastel->length = member_oid->length;
+
+            /* Update count */
+            (*oid_set)->count++;
+            if (elist)
+                free(elist);
+            *minor_status = 0;
+            return(GSS_S_COMPLETE);
+        }
+        else
+            free((*oid_set)->elements);
     }
     /* Failure - restore old contents of list */
     (*oid_set)->elements = elist;
@@ -179,32 +173,31 @@ generic_gss_add_oid_set_member(minor_status, member_oid, oid_set)
 }
 
 OM_uint32
-generic_gss_test_oid_set_member(minor_status, member, set, present)
-    OM_uint32  *minor_status;
-    const gss_OID_desc * const member;
-    gss_OID_set        set;
-    int                *present;
+generic_gss_test_oid_set_member(OM_uint32 *minor_status,
+                                const gss_OID_desc * const member,
+                                gss_OID_set set,
+                                int * present)
 {
-    OM_uint32  i;
-    int                result;
+    OM_uint32   i;
+    int         result;
 
     *minor_status = 0;
 
     if (member == NULL || set == NULL)
-       return (GSS_S_CALL_INACCESSIBLE_READ);
+        return (GSS_S_CALL_INACCESSIBLE_READ);
 
     if (present == NULL)
-       return (GSS_S_CALL_INACCESSIBLE_WRITE);
+        return (GSS_S_CALL_INACCESSIBLE_WRITE);
 
     result = 0;
     for (i=0; i<set->count; i++) {
-       if ((set->elements[i].length == member->length) &&
-           !memcmp(set->elements[i].elements,
-                   member->elements,
-                   (size_t) member->length)) {
-           result = 1;
-           break;
-       }
+        if ((set->elements[i].length == member->length) &&
+            !memcmp(set->elements[i].elements,
+                    member->elements,
+                    (size_t) member->length)) {
+            result = 1;
+            break;
+        }
     }
     *present = result;
     return(GSS_S_COMPLETE);
@@ -214,30 +207,29 @@ generic_gss_test_oid_set_member(minor_status, member, set, present)
  * OID<->string routines.  These are uuuuugly.
  */
 OM_uint32
-generic_gss_oid_to_str(minor_status, oid, oid_str)
-    OM_uint32          *minor_status;
-    const gss_OID_desc * const oid;
-    gss_buffer_t       oid_str;
+generic_gss_oid_to_str(OM_uint32 *minor_status,
+                       const gss_OID_desc * const oid,
+                       gss_buffer_t oid_str)
 {
-    OM_uint32          number;
+    OM_uint32           number;
     OM_uint32 i;
-    unsigned char      *cp;
-    char               *bp;
-    struct k5buf       buf;
+    unsigned char       *cp;
+    char                *bp;
+    struct k5buf        buf;
 
     if (minor_status != NULL)
-       *minor_status = 0;
+        *minor_status = 0;
 
     if (oid_str != GSS_C_NO_BUFFER) {
-       oid_str->length = 0;
-       oid_str->value = NULL;
+        oid_str->length = 0;
+        oid_str->value = NULL;
     }
 
     if (oid == NULL || oid->length == 0 || oid->elements == NULL)
-       return (GSS_S_CALL_INACCESSIBLE_READ);
+        return (GSS_S_CALL_INACCESSIBLE_READ);
 
     if (oid_str == GSS_C_NO_BUFFER)
-       return (GSS_S_CALL_INACCESSIBLE_WRITE);
+        return (GSS_S_CALL_INACCESSIBLE_WRITE);
 
     /* Decoded according to krb5/gssapi_krb5.c */
 
@@ -245,21 +237,21 @@ generic_gss_oid_to_str(minor_status, oid, oid_str)
     number = (unsigned long) cp[0];
     krb5int_buf_init_dynamic(&buf);
     krb5int_buf_add_fmt(&buf, "{ %lu %lu ", (unsigned long)number/40,
-                       (unsigned long)number%40);
+                        (unsigned long)number%40);
     number = 0;
     cp = (unsigned char *) oid->elements;
     for (i=1; i<oid->length; i++) {
-       number = (number << 7) | (cp[i] & 0x7f);
-       if ((cp[i] & 0x80) == 0) {
-           krb5int_buf_add_fmt(&buf, "%lu ", (unsigned long)number);
-           number = 0;
-       }
+        number = (number << 7) | (cp[i] & 0x7f);
+        if ((cp[i] & 0x80) == 0) {
+            krb5int_buf_add_fmt(&buf, "%lu ", (unsigned long)number);
+            number = 0;
+        }
     }
     krb5int_buf_add(&buf, "}");
     bp = krb5int_buf_data(&buf);
     if (bp == NULL) {
-       *minor_status = ENOMEM;
-       return(GSS_S_FAILURE);
+        *minor_status = ENOMEM;
+        return(GSS_S_FAILURE);
     }
     oid_str->length = krb5int_buf_len(&buf)+1;
     oid_str->value = (void *) bp;
@@ -267,43 +259,42 @@ generic_gss_oid_to_str(minor_status, oid, oid_str)
 }
 
 OM_uint32
-generic_gss_str_to_oid(minor_status, oid_str, oid)
-    OM_uint32          *minor_status;
-    gss_buffer_t       oid_str;
-    gss_OID            *oid;
+generic_gss_str_to_oid(OM_uint32 *minor_status,
+                       gss_buffer_t oid_str,
+                       gss_OID * oid)
 {
-    unsigned char      *cp, *bp, *startp;
-    int                brace;
-    long       numbuf;
-    long       onumbuf;
-    OM_uint32  nbytes;
-    int                i;
+    unsigned char       *cp, *bp, *startp;
+    int         brace;
+    long        numbuf;
+    long        onumbuf;
+    OM_uint32   nbytes;
+    int         i;
     unsigned char *op;
 
     if (minor_status != NULL)
-       *minor_status = 0;
+        *minor_status = 0;
 
     if (oid != NULL)
-       *oid = GSS_C_NO_OID;
+        *oid = GSS_C_NO_OID;
 
     if (GSS_EMPTY_BUFFER(oid_str))
-       return (GSS_S_CALL_INACCESSIBLE_READ);
+        return (GSS_S_CALL_INACCESSIBLE_READ);
 
     if (oid == NULL)
-       return (GSS_S_CALL_INACCESSIBLE_WRITE);
+        return (GSS_S_CALL_INACCESSIBLE_WRITE);
 
     brace = 0;
     bp = oid_str->value;
     cp = bp;
     /* Skip over leading space */
     while ((bp < &cp[oid_str->length]) && isspace(*bp))
-       bp++;
+        bp++;
     if (*bp == '{') {
-       brace = 1;
-       bp++;
+        brace = 1;
+        bp++;
     }
     while ((bp < &cp[oid_str->length]) && isspace(*bp))
-       bp++;
+        bp++;
     startp = bp;
     nbytes = 0;
 
@@ -311,118 +302,117 @@ generic_gss_str_to_oid(minor_status, oid_str, oid)
      * The first two numbers are chewed up by the first octet.
      */
     if (sscanf((char *)bp, "%ld", &numbuf) != 1) {
-       *minor_status = EINVAL;
-       return(GSS_S_FAILURE);
+        *minor_status = EINVAL;
+        return(GSS_S_FAILURE);
     }
     while ((bp < &cp[oid_str->length]) && isdigit(*bp))
-       bp++;
+        bp++;
     while ((bp < &cp[oid_str->length]) &&
-          (isspace(*bp) || *bp == '.'))
-       bp++;
+           (isspace(*bp) || *bp == '.'))
+        bp++;
     if (sscanf((char *)bp, "%ld", &numbuf) != 1) {
-       *minor_status = EINVAL;
-       return(GSS_S_FAILURE);
+        *minor_status = EINVAL;
+        return(GSS_S_FAILURE);
     }
     while ((bp < &cp[oid_str->length]) && isdigit(*bp))
-       bp++;
+        bp++;
     while ((bp < &cp[oid_str->length]) &&
-          (isspace(*bp) || *bp == '.'))
-       bp++;
+           (isspace(*bp) || *bp == '.'))
+        bp++;
     nbytes++;
     while (isdigit(*bp)) {
-       if (sscanf((char *)bp, "%ld", &numbuf) != 1) {
-           return(GSS_S_FAILURE);
-       }
-       while (numbuf) {
-           nbytes++;
-           numbuf >>= 7;
-       }
-       while ((bp < &cp[oid_str->length]) && isdigit(*bp))
-           bp++;
-       while ((bp < &cp[oid_str->length]) &&
-              (isspace(*bp) || *bp == '.'))
-           bp++;
+        if (sscanf((char *)bp, "%ld", &numbuf) != 1) {
+            return(GSS_S_FAILURE);
+        }
+        while (numbuf) {
+            nbytes++;
+            numbuf >>= 7;
+        }
+        while ((bp < &cp[oid_str->length]) && isdigit(*bp))
+            bp++;
+        while ((bp < &cp[oid_str->length]) &&
+               (isspace(*bp) || *bp == '.'))
+            bp++;
     }
     if (brace && (*bp != '}')) {
-       return(GSS_S_FAILURE);
+        return(GSS_S_FAILURE);
     }
 
     /*
      * Phew!  We've come this far, so the syntax is good.
      */
     if ((*oid = (gss_OID) malloc(sizeof(gss_OID_desc)))) {
-       if (((*oid)->elements = (void *) malloc(nbytes))) {
-           (*oid)->length = nbytes;
-           op = (unsigned char *) (*oid)->elements;
-           bp = startp;
-           (void) sscanf((char *)bp, "%ld", &numbuf);
-           while (isdigit(*bp))
-               bp++;
-           while (isspace(*bp) || *bp == '.')
-               bp++;
-           onumbuf = 40*numbuf;
-           (void) sscanf((char *)bp, "%ld", &numbuf);
-           onumbuf += numbuf;
-           *op = (unsigned char) onumbuf;
-           op++;
-           while (isdigit(*bp))
-               bp++;
-           while (isspace(*bp) || *bp == '.')
-               bp++;
-           while (isdigit(*bp)) {
-               (void) sscanf((char *)bp, "%ld", &numbuf);
-               nbytes = 0;
-               /* Have to fill in the bytes msb-first */
-               onumbuf = numbuf;
-               while (numbuf) {
-                   nbytes++;
-                   numbuf >>= 7;
-               }
-               numbuf = onumbuf;
-               op += nbytes;
-               i = -1;
-               while (numbuf) {
-                   op[i] = (unsigned char) numbuf & 0x7f;
-                   if (i != -1)
-                       op[i] |= 0x80;
-                   i--;
-                   numbuf >>= 7;
-               }
-               while (isdigit(*bp))
-                   bp++;
-               while (isspace(*bp) || *bp == '.')
-                   bp++;
-           }
-           return(GSS_S_COMPLETE);
-       }
-       else {
-           free(*oid);
-           *oid = GSS_C_NO_OID;
-       }
+        if (((*oid)->elements = (void *) malloc(nbytes))) {
+            (*oid)->length = nbytes;
+            op = (unsigned char *) (*oid)->elements;
+            bp = startp;
+            (void) sscanf((char *)bp, "%ld", &numbuf);
+            while (isdigit(*bp))
+                bp++;
+            while (isspace(*bp) || *bp == '.')
+                bp++;
+            onumbuf = 40*numbuf;
+            (void) sscanf((char *)bp, "%ld", &numbuf);
+            onumbuf += numbuf;
+            *op = (unsigned char) onumbuf;
+            op++;
+            while (isdigit(*bp))
+                bp++;
+            while (isspace(*bp) || *bp == '.')
+                bp++;
+            while (isdigit(*bp)) {
+                (void) sscanf((char *)bp, "%ld", &numbuf);
+                nbytes = 0;
+                /* Have to fill in the bytes msb-first */
+                onumbuf = numbuf;
+                while (numbuf) {
+                    nbytes++;
+                    numbuf >>= 7;
+                }
+                numbuf = onumbuf;
+                op += nbytes;
+                i = -1;
+                while (numbuf) {
+                    op[i] = (unsigned char) numbuf & 0x7f;
+                    if (i != -1)
+                        op[i] |= 0x80;
+                    i--;
+                    numbuf >>= 7;
+                }
+                while (isdigit(*bp))
+                    bp++;
+                while (isspace(*bp) || *bp == '.')
+                    bp++;
+            }
+            return(GSS_S_COMPLETE);
+        }
+        else {
+            free(*oid);
+            *oid = GSS_C_NO_OID;
+        }
     }
     return(GSS_S_FAILURE);
 }
 
 /* Compose an OID of a prefix and an integer suffix */
 OM_uint32
-generic_gss_oid_compose(
-    OM_uint32 *minor_status,
-    const char *prefix,
-    size_t prefix_len,
-    int suffix,
-    gss_OID_desc *oid)
+generic_gss_oid_compose(OM_uint32 *minor_status,
+                        const char *prefix,
+                        size_t prefix_len,
+                        int suffix,
+                        gss_OID_desc *oid)
 {
     int osuffix, i;
     size_t nbytes;
     unsigned char *op;
 
     if (oid == GSS_C_NO_OID) {
-       *minor_status = EINVAL;
-       return GSS_S_FAILURE;
+        *minor_status = EINVAL;
+        return GSS_S_FAILURE;
     }
     if (oid->length < prefix_len) {
-       *minor_status = ERANGE;
-       return GSS_S_FAILURE;
+        *minor_status = ERANGE;
+        return GSS_S_FAILURE;
     }
 
     memcpy(oid->elements, prefix, prefix_len);
@@ -430,24 +420,24 @@ generic_gss_oid_compose(
     nbytes = 0;
     osuffix = suffix;
     while (suffix) {
-       nbytes++;
-       suffix >>= 7;
+        nbytes++;
+        suffix >>= 7;
     }
     suffix = osuffix;
 
     if (oid->length < prefix_len + nbytes) {
-       *minor_status = ERANGE;
-       return GSS_S_FAILURE;
+        *minor_status = ERANGE;
+        return GSS_S_FAILURE;
     }
 
     op = (unsigned char *) oid->elements + prefix_len + nbytes;
     i = -1;
     while (suffix) {
-       op[i] = (unsigned char)suffix & 0x7f;
-       if (i != -1)
-           op[i] |= 0x80;
-       i--;
-       suffix >>= 7;
+        op[i] = (unsigned char)suffix & 0x7f;
+        if (i != -1)
+            op[i] |= 0x80;
+        i--;
+        suffix >>= 7;
     }
 
     oid->length = prefix_len + nbytes;
@@ -457,19 +447,18 @@ generic_gss_oid_compose(
 }
 
 OM_uint32
-generic_gss_oid_decompose(
-    OM_uint32 *minor_status,
-    const char *prefix,
-    size_t prefix_len,
-    gss_OID_desc *oid,
-    int *suffix)
+generic_gss_oid_decompose(OM_uint32 *minor_status,
+                          const char *prefix,
+                          size_t prefix_len,
+                          gss_OID_desc *oid,
+                          int *suffix)
 {
     size_t i, slen;
     unsigned char *op;
 
     if (oid->length < prefix_len ||
-       memcmp(oid->elements, prefix, prefix_len) != 0) {
-       return GSS_S_BAD_MECH;
+        memcmp(oid->elements, prefix, prefix_len) != 0) {
+        return GSS_S_BAD_MECH;
     }
 
     op = (unsigned char *) oid->elements + prefix_len;
@@ -479,11 +468,11 @@ generic_gss_oid_decompose(
     slen = oid->length - prefix_len;
 
     for (i = 0; i < slen; i++) {
-       *suffix = (*suffix << 7) | (op[i] & 0x7f);
-       if (i + 1 != slen && (op[i] & 0x80) == 0) {
-           *minor_status = EINVAL;
-           return GSS_S_FAILURE;
-       }
+        *suffix = (*suffix << 7) | (op[i] & 0x7f);
+        if (i + 1 != slen && (op[i] & 0x80) == 0) {
+            *minor_status = EINVAL;
+            return GSS_S_FAILURE;
+        }
     }
 
     return GSS_S_COMPLETE;
@@ -511,11 +500,9 @@ generic_gss_oid_decompose(
  * PERFORMANCE OF THIS SOFTWARE.
  */
 OM_uint32
-generic_gss_copy_oid_set(
-    OM_uint32 *minor_status,
-    const gss_OID_set_desc * const oidset,
-    gss_OID_set *new_oidset
-    )
+generic_gss_copy_oid_set(OM_uint32 *minor_status,
+                         const gss_OID_set_desc * const oidset,
+                         gss_OID_set *new_oidset)
 {
     gss_OID_set_desc *copy;
     OM_uint32 minor = 0;
@@ -523,45 +510,45 @@ generic_gss_copy_oid_set(
     OM_uint32 i;
 
     if (minor_status != NULL)
-       *minor_status = 0;
+        *minor_status = 0;
 
     if (new_oidset != NULL)
-       *new_oidset = GSS_C_NO_OID_SET;
+        *new_oidset = GSS_C_NO_OID_SET;
 
     if (oidset == GSS_C_NO_OID_SET)
-       return (GSS_S_CALL_INACCESSIBLE_READ);
+        return (GSS_S_CALL_INACCESSIBLE_READ);
 
     if (new_oidset == NULL)
-       return (GSS_S_CALL_INACCESSIBLE_WRITE);
+        return (GSS_S_CALL_INACCESSIBLE_WRITE);
 
     if ((copy = (gss_OID_set_desc *) calloc(1, sizeof (*copy))) == NULL) {
-       major = GSS_S_FAILURE;
-       goto done;
+        major = GSS_S_FAILURE;
+        goto done;
     }
 
     if ((copy->elements = (gss_OID_desc *)
-        calloc(oidset->count, sizeof (*copy->elements))) == NULL) {
-       major = GSS_S_FAILURE;
-       goto done;
+         calloc(oidset->count, sizeof (*copy->elements))) == NULL) {
+        major = GSS_S_FAILURE;
+        goto done;
     }
     copy->count = oidset->count;
 
     for (i = 0; i < copy->count; i++) {
-       gss_OID_desc *out = &copy->elements[i];
-       gss_OID_desc *in = &oidset->elements[i];
-
-       if ((out->elements = (void *) malloc(in->length)) == NULL) {
-           major = GSS_S_FAILURE;
-           goto done;
-       }
-       (void) memcpy(out->elements, in->elements, in->length);
-       out->length = in->length;
+        gss_OID_desc *out = &copy->elements[i];
+        gss_OID_desc *in = &oidset->elements[i];
+
+        if ((out->elements = (void *) malloc(in->length)) == NULL) {
+            major = GSS_S_FAILURE;
+            goto done;
+        }
+        (void) memcpy(out->elements, in->elements, in->length);
+        out->length = in->length;
     }
 
     *new_oidset = copy;
 done:
     if (major != GSS_S_COMPLETE) {
-       (void) gss_release_oid_set(&minor, &copy);
+        (void) gss_release_oid_set(&minor, &copy);
     }
 
     return (major);
index 1e506e7d914bd88fc7092807cf2fab98c4191bf8..46ec66cc9d0a84ebd60a194c3e932bf399b222ef 100644 (file)
@@ -1,3 +1,4 @@
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 /*
  * Copyright 2008 by the Massachusetts Institute of Technology.
  * All Rights Reserved.
 #include <string.h>
 #include <errno.h>
 
-OM_uint32 generic_gss_create_empty_buffer_set
-          (OM_uint32 * minor_status,
-           gss_buffer_set_t *buffer_set)
+OM_uint32
+generic_gss_create_empty_buffer_set(OM_uint32 * minor_status,
+                                    gss_buffer_set_t *buffer_set)
 {
     gss_buffer_set_t set;
 
     set = (gss_buffer_set_desc *) malloc(sizeof(*set));
     if (set == GSS_C_NO_BUFFER_SET) {
-       *minor_status = ENOMEM;
-       return GSS_S_FAILURE;
+        *minor_status = ENOMEM;
+        return GSS_S_FAILURE;
     }
 
     set->count = 0;
@@ -52,38 +53,38 @@ OM_uint32 generic_gss_create_empty_buffer_set
     return GSS_S_COMPLETE;
 }
 
-OM_uint32 generic_gss_add_buffer_set_member
-          (OM_uint32 * minor_status,
-           const gss_buffer_t member_buffer,
-           gss_buffer_set_t *buffer_set)
+OM_uint32
+generic_gss_add_buffer_set_member(OM_uint32 * minor_status,
+                                  const gss_buffer_t member_buffer,
+                                  gss_buffer_set_t *buffer_set)
 {
     gss_buffer_set_t set;
     gss_buffer_t p;
     OM_uint32 ret;
 
     if (*buffer_set == GSS_C_NO_BUFFER_SET) {
-       ret = generic_gss_create_empty_buffer_set(minor_status,
-                                                 buffer_set);
-       if (ret) {
-           return ret;
-       }
+        ret = generic_gss_create_empty_buffer_set(minor_status,
+                                                  buffer_set);
+        if (ret) {
+            return ret;
+        }
     }
 
     set = *buffer_set;
     set->elements = (gss_buffer_desc *)realloc(set->elements,
-                                              (set->count + 1) *
-                                               sizeof(gss_buffer_desc));
+                                               (set->count + 1) *
+                                               sizeof(gss_buffer_desc));
     if (set->elements == NULL) {
-       *minor_status = ENOMEM;
-       return GSS_S_FAILURE;
+        *minor_status = ENOMEM;
+        return GSS_S_FAILURE;
     }
 
     p = &set->elements[set->count];
 
     p->value = malloc(member_buffer->length);
     if (p->value == NULL) {
-       *minor_status = ENOMEM;
-       return GSS_S_FAILURE;
+        *minor_status = ENOMEM;
+        return GSS_S_FAILURE;
     }
     memcpy(p->value, member_buffer->value, member_buffer->length);
     p->length = member_buffer->length;
@@ -94,9 +95,9 @@ OM_uint32 generic_gss_add_buffer_set_member
     return GSS_S_COMPLETE;
 }
 
-OM_uint32 generic_gss_release_buffer_set
-          (OM_uint32 * minor_status,
-           gss_buffer_set_t *buffer_set)
+OM_uint32
+generic_gss_release_buffer_set(OM_uint32 * minor_status,
+                               gss_buffer_set_t *buffer_set)
 {
     size_t i;
     OM_uint32 minor;
@@ -104,16 +105,16 @@ OM_uint32 generic_gss_release_buffer_set
     *minor_status = 0;
 
     if (*buffer_set == GSS_C_NO_BUFFER_SET) {
-       return GSS_S_COMPLETE;
+        return GSS_S_COMPLETE;
     }
 
     for (i = 0; i < (*buffer_set)->count; i++) {
-       generic_gss_release_buffer(&minor, &((*buffer_set)->elements[i]));
+        generic_gss_release_buffer(&minor, &((*buffer_set)->elements[i]));
     }
 
     if ((*buffer_set)->elements != NULL) {
-       free((*buffer_set)->elements);
-       (*buffer_set)->elements = NULL;
+        free((*buffer_set)->elements);
+        (*buffer_set)->elements = NULL;
     }
 
     (*buffer_set)->count = 0;
index acb4c3651ef70f4ea34e572dec131b3c7e74e512..f17241c908915da3c7038a00acc50eb26a24823a 100644 (file)
@@ -1,5 +1,4 @@
-/* #pragma ident       "@(#)g_seal.c   1.19    98/04/21 SMI" */
-
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 /*
  * Copyright 1996 by Sun Microsystems, Inc.
  *
 #include "mglueP.h"
 
 static OM_uint32
-val_wrap_args(
-    OM_uint32 *minor_status,
-    gss_ctx_id_t context_handle,
-    int conf_req_flag,
-    gss_qop_t qop_req,
-    gss_buffer_t input_message_buffer,
-    int *conf_state,
-    gss_buffer_t output_message_buffer)
+val_wrap_args(OM_uint32 *minor_status,
+              gss_ctx_id_t context_handle,
+              int conf_req_flag,
+              gss_qop_t qop_req,
+              gss_buffer_t input_message_buffer,
+              int *conf_state,
+              gss_buffer_t output_message_buffer)
 {
-
     /* Initialize outputs. */
 
     if (minor_status != NULL)
-       *minor_status = 0;
+        *minor_status = 0;
 
     if (output_message_buffer != GSS_C_NO_BUFFER) {
-       output_message_buffer->length = 0;
-       output_message_buffer->value = NULL;
+        output_message_buffer->length = 0;
+        output_message_buffer->value = NULL;
     }
 
     /* Validate arguments. */
 
     if (minor_status == NULL)
-       return (GSS_S_CALL_INACCESSIBLE_WRITE);
+        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_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
 
     if (input_message_buffer == GSS_C_NO_BUFFER)
-       return (GSS_S_CALL_INACCESSIBLE_READ);
+        return (GSS_S_CALL_INACCESSIBLE_READ);
 
     if (output_message_buffer == GSS_C_NO_BUFFER)
-       return (GSS_S_CALL_INACCESSIBLE_WRITE);
+        return (GSS_S_CALL_INACCESSIBLE_WRITE);
 
     return (GSS_S_COMPLETE);
 }
 
 OM_uint32 KRB5_CALLCONV
-gss_wrap (minor_status,
-          context_handle,
-          conf_req_flag,
-          qop_req,
-          input_message_buffer,
-          conf_state,
-          output_message_buffer)
-
-OM_uint32 *            minor_status;
-gss_ctx_id_t           context_handle;
-int                    conf_req_flag;
-gss_qop_t              qop_req;
-gss_buffer_t           input_message_buffer;
-int *                  conf_state;
-gss_buffer_t           output_message_buffer;
+gss_wrap( OM_uint32 *minor_status,
+          gss_ctx_id_t context_handle,
+          int conf_req_flag,
+          gss_qop_t qop_req,
+          gss_buffer_t input_message_buffer,
+          int *conf_state,
+          gss_buffer_t output_message_buffer)
 {
- /* EXPORT DELETE START */
 
-    OM_uint32          status;
-    gss_union_ctx_id_t ctx;
-    gss_mechanism      mech;
+    /* EXPORT DELETE START */
+
+    OM_uint32           status;
+    gss_union_ctx_id_t  ctx;
+    gss_mechanism       mech;
 
     status = val_wrap_args(minor_status, context_handle,
-                          conf_req_flag, qop_req,
-                          input_message_buffer, conf_state,
-                          output_message_buffer);
+                           conf_req_flag, qop_req,
+                           input_message_buffer, conf_state,
+                           output_message_buffer);
     if (status != GSS_S_COMPLETE)
-       return (status);
+        return (status);
 
     /*
      * select the approprate underlying mechanism routine and
@@ -105,60 +95,51 @@ gss_buffer_t               output_message_buffer;
     mech = gssint_get_mechanism (ctx->mech_type);
 
     if (mech) {
-       if (mech->gss_wrap) {
-           status = mech->gss_wrap(
-                                   minor_status,
-                                   ctx->internal_ctx_id,
-                                   conf_req_flag,
-                                   qop_req,
-                                   input_message_buffer,
-                                   conf_state,
-                                   output_message_buffer);
-           if (status != GSS_S_COMPLETE)
-               map_error(minor_status, mech);
-       } else if (mech->gss_wrap_aead ||
-                  (mech->gss_wrap_iov && mech->gss_wrap_iov_length)) {
-           status = gssint_wrap_aead(mech,
-                                     minor_status,
-                                     ctx,
-                                     conf_req_flag,
-                                     (gss_qop_t)qop_req,
-                                     GSS_C_NO_BUFFER,
-                                     input_message_buffer,
-                                     conf_state,
-                                     output_message_buffer);
-       } else
-           status = GSS_S_UNAVAILABLE;
-
-       return(status);
+        if (mech->gss_wrap) {
+            status = mech->gss_wrap(minor_status,
+                                    ctx->internal_ctx_id,
+                                    conf_req_flag,
+                                    qop_req,
+                                    input_message_buffer,
+                                    conf_state,
+                                    output_message_buffer);
+            if (status != GSS_S_COMPLETE)
+                map_error(minor_status, mech);
+        } else if (mech->gss_wrap_aead ||
+                   (mech->gss_wrap_iov && mech->gss_wrap_iov_length)) {
+            status = gssint_wrap_aead(mech,
+                                      minor_status,
+                                      ctx,
+                                      conf_req_flag,
+                                      (gss_qop_t)qop_req,
+                                      GSS_C_NO_BUFFER,
+                                      input_message_buffer,
+                                      conf_state,
+                                      output_message_buffer);
+        } else
+            status = GSS_S_UNAVAILABLE;
+
+        return(status);
     }
- /* EXPORT DELETE END */
   /* EXPORT DELETE END */
 
     return (GSS_S_BAD_MECH);
 }
 
 OM_uint32 KRB5_CALLCONV
-gss_seal (minor_status,
-          context_handle,
-          conf_req_flag,
-          qop_req,
-          input_message_buffer,
-          conf_state,
-          output_message_buffer)
-
-OM_uint32 *            minor_status;
-gss_ctx_id_t           context_handle;
-int                    conf_req_flag;
-int                    qop_req;
-gss_buffer_t           input_message_buffer;
-int *                  conf_state;
-gss_buffer_t           output_message_buffer;
-
+gss_seal(OM_uint32 *minor_status,
+         gss_ctx_id_t context_handle,
+         int conf_req_flag,
+         int qop_req,
+         gss_buffer_t input_message_buffer,
+         int *conf_state,
+         gss_buffer_t output_message_buffer)
 {
+
     return gss_wrap(minor_status, context_handle,
-                   conf_req_flag, (gss_qop_t) qop_req,
-                   input_message_buffer, conf_state,
-                   output_message_buffer);
+                    conf_req_flag, (gss_qop_t) qop_req,
+                    input_message_buffer, conf_state,
+                    output_message_buffer);
 }
 
 /*
@@ -168,16 +149,16 @@ gss_buffer_t              output_message_buffer;
  */
 static OM_uint32
 gssint_wrap_size_limit_iov_shim(gss_mechanism mech,
-                               OM_uint32 *minor_status,
-                               gss_ctx_id_t context_handle,
-                               int conf_req_flag,
-                               gss_qop_t qop_req,
-                               OM_uint32 req_output_size,
-                               OM_uint32 *max_input_size)
+                                OM_uint32 *minor_status,
+                                gss_ctx_id_t context_handle,
+                                int conf_req_flag,
+                                gss_qop_t qop_req,
+                                OM_uint32 req_output_size,
+                                OM_uint32 *max_input_size)
 {
-    gss_iov_buffer_desc        iov[4];
-    OM_uint32          status;
-    OM_uint32          ohlen;
+    gss_iov_buffer_desc iov[4];
+    OM_uint32           status;
+    OM_uint32           ohlen;
 
     iov[0].type = GSS_IOV_BUFFER_TYPE_HEADER;
     iov[0].buffer.value = NULL;
@@ -198,20 +179,20 @@ gssint_wrap_size_limit_iov_shim(gss_mechanism mech,
     assert(mech->gss_wrap_iov_length);
 
     status = mech->gss_wrap_iov_length(minor_status, context_handle,
-                                      conf_req_flag, qop_req,
-                                      NULL, iov,
-                                      sizeof(iov)/sizeof(iov[0]));
+                                       conf_req_flag, qop_req,
+                                       NULL, iov,
+                                       sizeof(iov)/sizeof(iov[0]));
     if (status != GSS_S_COMPLETE) {
-       map_error(minor_status, mech);
-       return status;
+        map_error(minor_status, mech);
+        return status;
     }
 
     ohlen = iov[0].buffer.length + iov[3].buffer.length;
 
     if (iov[2].buffer.length == 0 && ohlen < req_output_size)
-       *max_input_size = req_output_size - ohlen;
+        *max_input_size = req_output_size - ohlen;
     else
-       *max_input_size = 0;
+        *max_input_size = 0;
 
     return GSS_S_COMPLETE;
 }
@@ -220,28 +201,24 @@ gssint_wrap_size_limit_iov_shim(gss_mechanism mech,
  * New for V2
  */
 OM_uint32 KRB5_CALLCONV
-gss_wrap_size_limit(minor_status, context_handle, conf_req_flag,
-                   qop_req, req_output_size, max_input_size)
-    OM_uint32          *minor_status;
-    gss_ctx_id_t       context_handle;
-    int                        conf_req_flag;
-    gss_qop_t          qop_req;
-    OM_uint32          req_output_size;
-    OM_uint32          *max_input_size;
+gss_wrap_size_limit(OM_uint32  *minor_status,
+                    gss_ctx_id_t context_handle,
+                    int conf_req_flag,
+                    gss_qop_t qop_req, OM_uint32 req_output_size, OM_uint32 *max_input_size)
 {
-    gss_union_ctx_id_t ctx;
-    gss_mechanism      mech;
-    OM_uint32          major_status;
+    gss_union_ctx_id_t  ctx;
+    gss_mechanism       mech;
+    OM_uint32           major_status;
 
     if (minor_status == NULL)
-       return (GSS_S_CALL_INACCESSIBLE_WRITE);
+        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);
+        return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
 
     if (max_input_size == NULL)
-       return (GSS_S_CALL_INACCESSIBLE_WRITE);
+        return (GSS_S_CALL_INACCESSIBLE_WRITE);
 
     /*
      * select the approprate underlying mechanism routine and
@@ -252,21 +229,21 @@ gss_wrap_size_limit(minor_status, context_handle, conf_req_flag,
     mech = gssint_get_mechanism (ctx->mech_type);
 
     if (!mech)
-       return (GSS_S_BAD_MECH);
+        return (GSS_S_BAD_MECH);
 
     if (mech->gss_wrap_size_limit)
-       major_status = mech->gss_wrap_size_limit(minor_status,
-                                                ctx->internal_ctx_id,
-                                                conf_req_flag, qop_req,
-                                                req_output_size, max_input_size);
+        major_status = mech->gss_wrap_size_limit(minor_status,
+                                                 ctx->internal_ctx_id,
+                                                 conf_req_flag, qop_req,
+                                                 req_output_size, max_input_size);
     else if (mech->gss_wrap_iov_length)
-       major_status = gssint_wrap_size_limit_iov_shim(mech, minor_status,
-                                                      ctx->internal_ctx_id,
-                                                      conf_req_flag, qop_req,
-                                                      req_output_size, max_input_size);
+        major_status = gssint_wrap_size_limit_iov_shim(mech, minor_status,
+                                                       ctx->internal_ctx_id,
+                                                       conf_req_flag, qop_req,
+                                                       req_output_size, max_input_size);
     else
-       major_status = GSS_S_UNAVAILABLE;
+        major_status = GSS_S_UNAVAILABLE;
     if (major_status != GSS_S_COMPLETE)
-       map_error(minor_status, mech);
+        map_error(minor_status, mech);
     return major_status;
 }