tech-crypto archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Heimdal: patch to fix krb5_enctype vs int confusions



I've recently been trying to arrange for it to be possible to compile
NetBSD with -fshort-enums, since it looks like the ARM ABI might require
this.  I got quite a lot of warnings from GCC where values of type
krb5_enctype * were being passed to functions expecting int *, and
suchlike.  The fixes seemed pretty mechanical, and are below.  Could
relevant people cast an eye over this and tell me what they think.  I
haven't got a Kerberos setup around here to test the patches against, but
I could set one up if need be.

Index: crypto/dist/heimdal/kdc/kerberos5.c
===================================================================
RCS file: /cvsroot/basesrc/crypto/dist/heimdal/kdc/kerberos5.c,v
retrieving revision 1.4
diff -u -r1.4 kerberos5.c
--- crypto/dist/heimdal/kdc/kerberos5.c 2001/09/17 12:32:36     1.4
+++ crypto/dist/heimdal/kdc/kerberos5.c 2002/01/03 22:34:07
@@ -109,7 +109,7 @@
          krb5_enctype *cetype,
          Key **skey,
          krb5_enctype *setype,
-         int *etypes,
+         krb5_enctype *etypes,
          unsigned num_etypes)
 {
     krb5_error_code ret;
Index: crypto/dist/heimdal/lib/krb5/crypto.c
===================================================================
RCS file: /cvsroot/basesrc/crypto/dist/heimdal/lib/krb5/crypto.c,v
retrieving revision 1.7
diff -u -r1.7 crypto.c
--- crypto/dist/heimdal/lib/krb5/crypto.c       2001/09/17 12:32:38     1.7
+++ crypto/dist/heimdal/lib/krb5/crypto.c       2002/01/03 22:34:10
@@ -2143,18 +2143,18 @@
 krb5_keytype_to_enctypes (krb5_context context,
                          krb5_keytype keytype,
                          unsigned *len,
-                         int **val)
+                         krb5_enctype **val)
 {
     int i;
     unsigned n = 0;
-    int *ret;
+    krb5_enctype *ret;

     for (i = num_etypes - 1; i >= 0; --i) {
        if (etypes[i]->keytype->type == keytype
            && !(etypes[i]->flags & F_PSEUDO))
            ++n;
     }
-    ret = malloc(n * sizeof(int));
+    ret = malloc(n * sizeof(*ret));
     if (ret == NULL && n != 0) {
        krb5_set_error_string(context, "malloc: out of memory");
        return ENOMEM;
@@ -2179,10 +2179,10 @@
 krb5_keytype_to_enctypes_default (krb5_context context,
                                  krb5_keytype keytype,
                                  unsigned *len,
-                                 int **val)
+                                 krb5_enctype **val)
 {
     int i, n;
-    int *ret;
+    krb5_enctype *ret;

     if (keytype != KEYTYPE_DES || context->etypes_des == NULL)
        return krb5_keytype_to_enctypes (context, keytype, len, val);
Index: crypto/dist/heimdal/lib/krb5/get_in_tkt.c
===================================================================
RCS file: /cvsroot/basesrc/crypto/dist/heimdal/lib/krb5/get_in_tkt.c,v
retrieving revision 1.1.1.5
diff -u -r1.1.1.5 get_in_tkt.c
--- crypto/dist/heimdal/lib/krb5/get_in_tkt.c   2001/09/17 12:25:03     1.1.1.5
+++ crypto/dist/heimdal/lib/krb5/get_in_tkt.c   2002/01/03 22:34:10
@@ -38,7 +38,7 @@
 krb5_error_code
 krb5_init_etype (krb5_context context,
                 unsigned *len,
-                int **val,
+                krb5_enctype **val,
                 const krb5_enctype *etypes)
 {
     int i;
@@ -58,7 +58,7 @@
     for (i = 0; tmp[i]; ++i)
        ;
     *len = i;
-    *val = malloc(i * sizeof(int));
+    *val = malloc(i * sizeof(**val));
     if (i != 0 && *val == NULL) {
        ret = ENOMEM;
        krb5_set_error_string(context, "malloc: out of memory");
@@ -370,14 +370,14 @@
           krb5_principal client,
           krb5_key_proc key_proc,
           krb5_const_pointer keyseed,
-          int *enctypes,
+          krb5_enctype *enctypes,
           unsigned netypes,
           krb5_salt *salt)
 {
     krb5_error_code ret;
     PA_DATA *pa2;
     krb5_salt salt2;
-    int *ep;
+    krb5_enctype *ep;
     int i;

     if(salt == NULL) {
@@ -386,7 +386,7 @@
        salt = &salt2;
     }
     if (!enctypes) {
-       enctypes = (int *)context->etypes; /* XXX */
+       enctypes = context->etypes;
        netypes = 0;
        for (ep = enctypes; *ep != ETYPE_NULL; ep++)
            netypes++;
Index: crypto/dist/heimdal/lib/krb5/krb5-protos.h
===================================================================
RCS file: /cvsroot/basesrc/crypto/dist/heimdal/lib/krb5/krb5-protos.h,v
retrieving revision 1.5
diff -u -r1.5 krb5-protos.h
--- crypto/dist/heimdal/lib/krb5/krb5-protos.h  2001/09/17 12:32:38     1.5
+++ crypto/dist/heimdal/lib/krb5/krb5-protos.h  2002/01/03 22:34:10
@@ -1603,7 +1603,7 @@
 krb5_init_etype __P((
        krb5_context context,
        unsigned *len,
-       int **val,
+       krb5_enctype **val,
        const krb5_enctype *etypes));

 krb5_error_code
@@ -1633,14 +1633,14 @@
        krb5_context context,
        krb5_keytype keytype,
        unsigned *len,
-       int **val));
+       krb5_enctype **val));

 krb5_error_code
 krb5_keytype_to_enctypes_default __P((
        krb5_context context,
        krb5_keytype keytype,
        unsigned *len,
-       int **val));
+       krb5_enctype **val));

 krb5_error_code
 krb5_keytype_to_string __P((

-- 
Ben Harris                                                   
<bjh21%netbsd.org@localhost>
Portmaster, NetBSD/arm26               <URL:http://www.netbsd.org/Ports/arm26/>




Home | Main Index | Thread Index | Old Index