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

Re: telnetd from 0.4c dumps core



joda@pdc.kth.se (Johan Danielsson) writes:

> Richard Nyberg <rnyberg@it.su.se> writes:
> 
> > a gets its addr_type from krb5_make_addrport which sets it to
> > KRB5_ADDRESS_ADDRPORT (256).

You can try this patch, relative to 0.4c.

/Johan

--- addr_families.c	2001/07/02 22:26:42	1.27
+++ addr_families.c	2001/07/24 12:07:20	1.29
@@ -33,7 +33,7 @@
 
 #include "krb5_locl.h"
 
-RCSID("$Id: addr_families.c,v 1.27 2001/07/02 22:26:42 joda Exp $");
+RCSID("$Id: addr_families.c,v 1.29 2001/07/24 12:07:20 joda Exp $");
 
 struct addr_operations {
     int af;
@@ -349,8 +349,7 @@
  * table
  */
 
-#define AF_ARANGE		(-100)
-#define KRB5_ADDRESS_ARANGE	AF_ARANGE
+#define KRB5_ADDRESS_ARANGE	(-100)
 
 struct arange {
     krb5_address low;
@@ -423,12 +422,26 @@
 arange_copy (krb5_context context, const krb5_address *inaddr, 
 	     krb5_address *outaddr)
 {
+    krb5_error_code ret;
     struct arange *i, *o;
-    copy_HostAddress(inaddr, outaddr);
+
+    outaddr->addr_type = KRB5_ADDRESS_ARANGE;
+    ret = krb5_data_alloc(&outaddr->address, sizeof(*o));
+    if(ret)
+	return ret;
     i = inaddr->address.data;
     o = outaddr->address.data;
-    krb5_copy_address(context, &i->low, &o->low);
-    krb5_copy_address(context, &i->high, &o->high);
+    ret = krb5_copy_address(context, &i->low, &o->low);
+    if(ret) {
+	krb5_data_free(&outaddr->address);
+	return ret;
+    }
+    ret = krb5_copy_address(context, &i->high, &o->high);
+    if(ret) {
+	krb5_free_address(context, &o->low);
+	krb5_data_free(&outaddr->address);
+	return ret;
+    }
     return 0;
 }
 
@@ -512,8 +525,10 @@
      ipv6_h_addr2addr,
      ipv6_uninteresting, ipv6_anyaddr, ipv6_print_addr, ipv6_parse_addr} ,
 #endif
+    {KRB5_ADDRESS_ADDRPORT, KRB5_ADDRESS_ADDRPORT, 0,
+     NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL },
     /* fake address type */
-    {AF_ARANGE, KRB5_ADDRESS_ARANGE, sizeof(struct arange),
+    {KRB5_ADDRESS_ARANGE, KRB5_ADDRESS_ARANGE, sizeof(struct arange),
      NULL, NULL, NULL, NULL, NULL, NULL, NULL,
      arange_print_addr, arange_parse_addr, 
      arange_order_addr, arange_free, arange_copy }
@@ -741,14 +756,26 @@
        should we call? this works for now, though */
     struct addr_operations *a;
     a = find_atype(addr1->addr_type); 
+    if(a == NULL) {
+	krb5_set_error_string (context, "Address family %d not supported", 
+			       addr1->addr_type);
+	return KRB5_PROG_ATYPE_NOSUPP;
+    }
     if(a->order_addr != NULL) 
 	return (*a->order_addr)(context, addr1, addr2); 
     a = find_atype(addr2->addr_type); 
+    if(a == NULL) {
+	krb5_set_error_string (context, "Address family %d not supported", 
+			       addr2->addr_type);
+	return KRB5_PROG_ATYPE_NOSUPP;
+    }
     if(a->order_addr != NULL) 
 	return (*a->order_addr)(context, addr1, addr2);
 
     if(addr1->addr_type != addr2->addr_type)
 	return addr1->addr_type - addr2->addr_type;
+    if(addr1->address.length != addr2->address.length)
+	return addr1->address.length - addr2->address.length;
     return memcmp (addr1->address.data,
 		   addr2->address.data,
 		   addr1->address.length);