--- src/login-common/integrity-proxy-gssapi.c~	2004-07-12 11:39:35.872148016 -0400
+++ src/login-common/integrity-proxy-gssapi.c	2004-07-12 11:37:02.432474392 -0400
@@ -167,7 +167,6 @@
 
 	qop = context[0];
 	max_client_bufsize = (context[1] << 16) + (context[2] << 8) + context[3];
-	i_info("qop %d max_client_bufsize %d", qop, max_client_bufsize);
 	/* Sanity. */
 	if (max_client_bufsize == 0)
 		max_client_bufsize = 1024;
@@ -200,8 +199,6 @@
 		gss->max_plain_input_size = 1024;
 	}
 
-	i_info("created new integrity proxy");
-
 	hash_insert(gssapi_integrity_proxies, gss, gss);
 
 	gss->secure_size_bytes_to_read = 4;
@@ -281,7 +278,6 @@
 	OM_uint32 min_stat, maj_stat;
 	gss_buffer_desc inbuf, outbuf;
 
-	i_info("plain read");
 
 	proxy->refcount++;
 
@@ -306,9 +302,8 @@
 
 	inbuf.value = (void*) buffer_get_data(tmp_buf, &buflen);
 	inbuf.length = buflen;
-	i_info("read %d plain bytes", buflen);
 
-	if (buflen > 0) {
+	if (buflen > 0 && !proxy->destroyed) {
 		maj_stat = gss_wrap(&min_stat,
 				    proxy->context, 
 				    1,
@@ -325,16 +320,15 @@
 
 		/* Store the size in network byte order */
 		buffer_append_c(proxy->secure_output_buf,
-				outbuf.length & (0xFF000000));
+				(outbuf.length & (0xFF000000)) >> 24);
 		buffer_append_c(proxy->secure_output_buf,
-				outbuf.length & (0x00FF0000));
+				(outbuf.length & (0x00FF0000)) >> 16);
 		buffer_append_c(proxy->secure_output_buf,
-				outbuf.length & (0x0000FF00));
+				(outbuf.length & (0x0000FF00)) >> 8);
 		buffer_append_c(proxy->secure_output_buf,
 				outbuf.length & (0x000000FF));
 		buffer_append(proxy->secure_output_buf,
 			      outbuf.value, outbuf.length);
-		i_info("transformed plain bytes to %d encrypted bytes", outbuf.length);
 		maj_stat = gss_release_buffer(&min_stat, &outbuf);
 		if (GSS_ERROR(maj_stat)) {
 			log_gssapi_error(proxy->context, "gss_release_buffer",
@@ -353,8 +347,6 @@
 	const unsigned char *bufdata;
 	size_t bufsize;
 
-	i_info("plain write");
-
 	proxy->refcount++;
 
 	bufdata = buffer_get_data(proxy->plain_output_buf, &bufsize);
@@ -364,7 +356,6 @@
 		integrity_proxy_gssapi_destroy(proxy);
 	} else if (ret > 0) {
 		buffer_delete(proxy->plain_output_buf, 0, ret);
-		i_info("wrote %d plain bytes", ret);
 
 		if (buffer_get_used_size(proxy->plain_output_buf) > 0) {
 			if (proxy->io_plain_write == NULL) {
@@ -403,7 +394,6 @@
 		integrity_proxy_gssapi_destroy(proxy);
 		return;
 	}
-	i_info("token complete, unwrapped to %d plain bytes", outbuf.length);
 	buffer_delete(proxy->secure_input_buf, 0, bufsize);
 
 	buffer_append(proxy->plain_output_buf, outbuf.value, outbuf.length);
@@ -459,8 +449,6 @@
 			+ (proxy->size_bytes[1] << 16)
 			+ (proxy->size_bytes[2] << 8)
 			+ (proxy->size_bytes[3]);
-		i_info("reading secure token of length %d bytes",
-		       proxy->secure_msg_bytes_to_read);
 	}
 
 	while (proxy->secure_size_bytes_to_read == 0
@@ -485,7 +473,6 @@
 			buffer_append(proxy->secure_input_buf,
 				      tmp_secure_input_buf,
 				      ret);
-			i_info("read %d secure bytes", ret);
 			proxy->secure_msg_bytes_to_read -= ret;
 			if (proxy->secure_msg_bytes_to_read == 0)
 				handle_msg_completion(proxy);
@@ -502,8 +489,6 @@
 	const unsigned char *bufdata;
 	size_t bufsize;
 
-	i_info("secure write");
-	
 	bufdata = (void*) buffer_get_data(proxy->secure_output_buf, &bufsize);
 	
 	ret = net_transmit(proxy->fd_secure, bufdata, bufsize);
@@ -511,7 +496,6 @@
 		integrity_proxy_gssapi_destroy(proxy);
 		i_warning("net_transmit failed: %m");
 	} else {
-		i_info("wrote %d secure bytes", ret);
 		buffer_delete(proxy->secure_output_buf, 0, ret);
 		secure_block_output(proxy, (bufsize - ret) <= 0);
 		plain_block_input(proxy, FALSE);
@@ -534,8 +518,6 @@
 {
 	OM_uint32 min_stat, maj_stat;
 
-	i_info("destroying integrity proxy");
-
 	hash_remove(gssapi_integrity_proxies, proxy);
 
 	(void)net_disconnect(proxy->fd_secure);
@@ -562,6 +544,8 @@
 	buffer_free(proxy->plain_output_buf);
 	buffer_free(proxy->secure_input_buf);
 	buffer_free(proxy->secure_output_buf);
+
+	proxy->destroyed = 1;
 }
 
 struct integrity_proxy_factory integrity_proxy_factory_gssapi = {
