heimdal: Fix size types and array access
authorAndreas Schneider <asn@samba.org>
Wed, 21 Mar 2018 12:02:26 +0000 (13:02 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 3 Apr 2018 18:20:10 +0000 (20:20 +0200)
This fixes compilation with -Wstrict-overflow=2.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/heimdal/lib/gssapi/mech/gss_set_cred_option.c
source4/heimdal/lib/krb5/addr_families.c

index d33453d92feb34238229b09a3b602b6a326874c0..653565b856d8a1402b8e84874450ba53c2a3e8de 100644 (file)
@@ -41,7 +41,7 @@ gss_set_cred_option (OM_uint32 *minor_status,
        struct _gss_cred *cred = (struct _gss_cred *) *cred_handle;
        OM_uint32       major_status = GSS_S_COMPLETE;
        struct _gss_mechanism_cred *mc;
-       int one_ok = 0;
+       OM_uint32 one_ok = 0;
 
        *minor_status = 0;
 
index 5d321a7e917d2975f32a968296e05637a67b7c88..1f7b72666085c2198961a9534f3f8e142a800a49 100644 (file)
@@ -803,7 +803,7 @@ static struct addr_operations at[] = {
     }
 };
 
-static int num_addrs = sizeof(at) / sizeof(at[0]);
+static size_t num_addrs = sizeof(at) / sizeof(at[0]);
 
 static size_t max_sockaddr_size = 0;
 
@@ -814,22 +814,26 @@ static size_t max_sockaddr_size = 0;
 static struct addr_operations *
 find_af(int af)
 {
-    struct addr_operations *a;
+    size_t i;
 
-    for (a = at; a < at + num_addrs; ++a)
-       if (af == a->af)
-           return a;
+    for (i = 0; i < num_addrs; i++) {
+       if (af == at[i].af) {
+               return &at[i];
+       }
+    }
     return NULL;
 }
 
 static struct addr_operations *
 find_atype(krb5_address_type atype)
 {
-    struct addr_operations *a;
+    size_t i;
 
-    for (a = at; a < at + num_addrs; ++a)
-       if (atype == a->atype)
-           return a;
+    for (i = 0; i < num_addrs; i++) {
+       if (atype == at[i].atype) {
+               return &at[i];
+       }
+    }
     return NULL;
 }
 
@@ -949,10 +953,11 @@ KRB5_LIB_FUNCTION size_t KRB5_LIB_CALL
 krb5_max_sockaddr_size (void)
 {
     if (max_sockaddr_size == 0) {
-       struct addr_operations *a;
+       size_t i;
 
-       for(a = at; a < at + num_addrs; ++a)
-           max_sockaddr_size = max(max_sockaddr_size, a->max_sockaddr_size);
+       for (i = 0; i < num_addrs; i++) {
+           max_sockaddr_size = max(max_sockaddr_size, at[i].max_sockaddr_size);
+       }
     }
     return max_sockaddr_size;
 }