Index: src/lib/radius.c
===================================================================
RCS file: /source/radiusd/src/lib/radius.c,v
retrieving revision 1.125.2.5
diff -u -r1.125.2.5 radius.c
--- src/lib/radius.c	19 Aug 2005 19:43:46 -0000	1.125.2.5
+++ src/lib/radius.c	13 Sep 2005 17:08:39 -0000
@@ -388,12 +388,50 @@
 				   *	Ascend binary attributes are
 				   *	stored internally in binary form.
 				   */
+			  case PW_TYPE_INTEGER:
+			  case PW_TYPE_IPADDR:
+
+				  if (reply->type == PW_TYPE_INTEGER ) {
+				          /*  If tagged, the tag becomes the MSB of the value */
+				          if(reply->flags.has_tag) {
+					         /*  Tag must be ( 0x01 -> 0x1F ) OR 0x00  */
+					         if(!TAG_VALID(reply->flags.tag)) {
+						       reply->flags.tag = 0x00;
+						 }
+					         lvalue = htonl((reply->lvalue & 0xffffff) |
+								((reply->flags.tag & 0xff) << 24));
+					  } else {
+					         lvalue = htonl(reply->lvalue);
+					  }
+				  } else {
+					  /*
+					   *  IP address is already in
+					   *  network byte order.
+					   */
+					  lvalue = reply->lvalue;
+				  }
+				  len = 4;
+
+				  if (reply->flags.encrypt == 0) {
+					  memcpy(ptr, &lvalue, len);
+					  *length_ptr += len;
+					  if (vsa_length_ptr) *vsa_length_ptr += len;
+					  ptr += len;
+					  total_length += len;
+					  break;
+				  } else {
+					  memcpy(reply->strvalue, &lvalue, len); /* NOTE: destroys the original text attribute */
+					  reply->length = len;
+					  /* FALL-THROUGH */
+				  }
+				  
 			  case PW_TYPE_IFID:
 			  case PW_TYPE_IPV6ADDR:
 			  case PW_TYPE_IPV6PREFIX:
 			  case PW_TYPE_ABINARY:
 			  case PW_TYPE_STRING:
 			  case PW_TYPE_OCTETS:
+
 				  /*
 				   *  Encrypt the various password styles
 				   */
@@ -486,35 +524,6 @@
 				  total_length += len;
 				  break;
 
-			  case PW_TYPE_INTEGER:
-			  case PW_TYPE_IPADDR:
-				  *length_ptr += 4;
-				  if (vsa_length_ptr) *vsa_length_ptr += 4;
-
-				  if (reply->type == PW_TYPE_INTEGER ) {
-				          /*  If tagged, the tag becomes the MSB of the value */
-				          if(reply->flags.has_tag) {
-					         /*  Tag must be ( 0x01 -> 0x1F ) OR 0x00  */
-					         if(!TAG_VALID(reply->flags.tag)) {
-						       reply->flags.tag = 0x00;
-						 }
-					         lvalue = htonl((reply->lvalue & 0xffffff) |
-								((reply->flags.tag & 0xff) << 24));
-					  } else {
-					         lvalue = htonl(reply->lvalue);
-					  }
-				  } else {
-					  /*
-					   *  IP address is already in
-					   *  network byte order.
-					   */
-					  lvalue = reply->lvalue;
-				  }
-				  memcpy(ptr, &lvalue, 4);
-				  ptr += 4;
-				  total_length += 4;
-				  break;
-
 				  /*
 				   *  There are no tagged date attributes.
 				   */
