PERFORCE change 98761 for review

Wayne Salamon wsalamon at FreeBSD.org
Wed Jun 7 22:28:37 PDT 2006


http://perforce.freebsd.org/chv.cgi?CH=98761

Change 98761 by wsalamon at vh1 on 2006/06/07 21:59:50

	Generate subject32_ex and process32_ex tokens to be of minimal
	length necessary to contain the IP address. This follows the
	Solaris BSM record format.

Affected files ...

.. //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#48 edit

Differences ...

==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#48 (text+ko) ====

@@ -30,7 +30,7 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  *
- * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#47 $
+ * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#48 $
  */
 
 #include <sys/types.h>
@@ -691,7 +691,16 @@
 	token_t *t;
 	u_char *dptr = NULL;
 
-	GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 13 * sizeof(u_int32_t));
+	if (tid->at_type == AU_IPv4)
+		GET_TOKEN_AREA(t, dptr, sizeof(u_char) +
+		    10 * sizeof(u_int32_t));
+	else if (tid->at_type == AU_IPv6)
+		GET_TOKEN_AREA(t, dptr, sizeof(u_char) +
+		    13 * sizeof(u_int32_t));
+	else {
+		errno = EINVAL;
+		return (NULL);
+	}
 	if (t == NULL)
 		return (NULL);
 
@@ -706,9 +715,11 @@
 	ADD_U_INT32(dptr, tid->at_port);
 	ADD_U_INT32(dptr, tid->at_type);
 	ADD_U_INT32(dptr, tid->at_addr[0]);
-	ADD_U_INT32(dptr, tid->at_addr[1]);
-	ADD_U_INT32(dptr, tid->at_addr[2]);
-	ADD_U_INT32(dptr, tid->at_addr[3]);
+	if (tid->at_type == AU_IPv6) {
+		ADD_U_INT32(dptr, tid->at_addr[1]);
+		ADD_U_INT32(dptr, tid->at_addr[2]);
+		ADD_U_INT32(dptr, tid->at_addr[3]);
+	}
 
 	return (t);
 }
@@ -969,7 +980,16 @@
 	token_t *t;
 	u_char *dptr = NULL;
 
-	GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 13 * sizeof(u_int32_t));
+	if (tid->at_type == AU_IPv4)
+		GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 10 *
+		    sizeof(u_int32_t));
+	else if (tid->at_type == AU_IPv6)
+		GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 13 *
+		    sizeof(u_int32_t));
+	else {
+		errno = EINVAL;
+		return (NULL);
+	}
 	if (t == NULL)
 		return (NULL);
 
@@ -984,9 +1004,11 @@
 	ADD_U_INT32(dptr, tid->at_port);
 	ADD_U_INT32(dptr, tid->at_type);
 	ADD_U_INT32(dptr, tid->at_addr[0]);
-	ADD_U_INT32(dptr, tid->at_addr[1]);
-	ADD_U_INT32(dptr, tid->at_addr[2]);
-	ADD_U_INT32(dptr, tid->at_addr[3]);
+	if (tid->at_type == AU_IPv6) {
+		ADD_U_INT32(dptr, tid->at_addr[1]);
+		ADD_U_INT32(dptr, tid->at_addr[2]);
+		ADD_U_INT32(dptr, tid->at_addr[3]);
+	}
 
 	return (t);
 }


More information about the trustedbsd-cvs mailing list