[OpenAFS] rxkad patch

Hartmut Reuter reuter@rzg.mpg.de
Wed, 17 May 2006 18:20:47 +0200


This is a multi-part message in MIME format.
--------------080806090501060103060501
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Here once again my patch for rxkad to allocate only as much space as 
necessary for the security object and not always 12K.
This patch is based on the 1.4.1 version.
For some unknown reason my 1st patch didn't make it into the CVS and 
stable releases.

Hartmut
-----------------------------------------------------------------
Hartmut Reuter                           e-mail reuter@rzg.mpg.de
					   phone +49-89-3299-1328
RZG (Rechenzentrum Garching)               fax   +49-89-3299-1301
Computing Center of the Max-Planck-Gesellschaft (MPG) and the
Institut fuer Plasmaphysik (IPP)
-----------------------------------------------------------------

--------------080806090501060103060501
Content-Type: text/plain;
 name="diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="diff"

--- private_data.h.orig	2003-07-16 01:16:42.345588002 +0200
+++ private_data.h	2005-12-16 11:52:19.527178509 +0100
@@ -48,15 +48,17 @@
     afs_int32 ipAddr;		/* or an approximation to it */
 };
 
+#define PDATA_SIZE(l) (sizeof(struct rxkad_cprivate) - MAXKTCTICKETLEN + (l))
+
 /* private data in client-side security object */
 struct rxkad_cprivate {
     afs_int32 kvno;		/* key version of ticket */
-    afs_int32 ticketLen;	/* length of ticket */
+    afs_int16 ticketLen;	/* length of ticket */
+    rxkad_type type;		/* always client */
+    rxkad_level level;		/* minimum security level of client */
     fc_KeySchedule keysched;	/* the session key */
     fc_InitializationVector ivec;	/* initialization vector for cbc */
     char ticket[MAXKTCTICKETLEN];	/* the ticket for the server */
-    rxkad_type type;		/* always client */
-    rxkad_level level;		/* minimum security level of client */
 };
 
 /* Per connection client-side info */
--- rxkad_client.c.orig	2006-02-28 01:19:20.107241106 +0100
+++ rxkad_client.c	2006-04-25 09:41:37.955757683 +0200
@@ -181,7 +181,7 @@
     struct rx_securityClass *tsc;
     struct rxkad_cprivate *tcp;
     int code;
-    int size;
+    int size, psize;
 
     size = sizeof(struct rx_securityClass);
     tsc = (struct rx_securityClass *)rxi_Alloc(size);
@@ -189,15 +189,15 @@
     tsc->refCount = 1;		/* caller gets one for free */
     tsc->ops = &rxkad_client_ops;
 
-    size = sizeof(struct rxkad_cprivate);
-    tcp = (struct rxkad_cprivate *)rxi_Alloc(size);
-    memset((void *)tcp, 0, size);
+    psize = PDATA_SIZE(ticketLen);
+    tcp = (struct rxkad_cprivate *)rxi_Alloc(psize);
+    memset((void *)tcp, 0, psize);
     tsc->privateData = (char *)tcp;
     tcp->type |= rxkad_client;
     tcp->level = level;
     code = fc_keysched(sessionkey, tcp->keysched);
     if (code) {
-	rxi_Free(tcp, sizeof(struct rxkad_cprivate));
+	rxi_Free(tcp, psize);
 	rxi_Free(tsc, sizeof(struct rx_securityClass));
 	return 0;		/* bad key */
     }
@@ -205,7 +205,7 @@
     tcp->kvno = kvno;		/* key version number */
     tcp->ticketLen = ticketLen;	/* length of ticket */
     if (tcp->ticketLen > MAXKTCTICKETLEN) {
-	rxi_Free(tcp, sizeof(struct rxkad_cprivate));
+	rxi_Free(tcp, psize);
 	rxi_Free(tsc, sizeof(struct rx_securityClass));
 	return 0;		/* bad key */
     }
--- rxkad_common.c.orig	2006-02-28 01:19:20.361083608 +0100
+++ rxkad_common.c	2006-04-25 09:43:04.572665345 +0200
@@ -68,7 +68,7 @@
 #include <strings.h>
 #endif
 #endif
-
+#include <afs/afsutil.h>
 #endif /* KERNEL */
 
 #include <des/stats.h>
@@ -311,7 +311,8 @@
     tcp = (struct rxkad_cprivate *)aobj->privateData;
     rxi_Free(aobj, sizeof(struct rx_securityClass));
     if (tcp->type & rxkad_client) {
-	rxi_Free(tcp, sizeof(struct rxkad_cprivate));
+	afs_int32 psize = PDATA_SIZE(tcp->ticketLen);
+	rxi_Free(tcp, psize);
     } else if (tcp->type & rxkad_server) {
 	rxi_Free(tcp, sizeof(struct rxkad_sprivate));
     } else {

--------------080806090501060103060501--