From: Tristan Gingold Subject: PATCH (ACM): keep binary stream aligned Date: Mon, 4 Sep 2006 17:02:54 +0200 Message-ID: <200609041702.54492.Tristan.Gingold@bull.net> Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_eAE/ETly4nZ8irf" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com, Keir Fraser Cc: xen-ia64-devel List-Id: xen-devel@lists.xenproject.org --Boundary-00=_eAE/ETly4nZ8irf Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, I am currently porting ACM to xen/ia64. Because ia64 can't handle unaligned accesses, the binary policy file should be aligned. This patch fixes this issue. (There is the same issue within xen/acm for dumping feature. A patch will follow). Tested on xen/ia64. Tristan. --Boundary-00=_eAE/ETly4nZ8irf Content-Type: text/x-diff; charset="us-ascii"; name="xen-acm1.diffs" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xen-acm1.diffs" # HG changeset patch # User gingold@virtu10 # Node ID a0507fa13cc774afd707153477af10081e42cedb # Parent afe74d7dcd8b7be768b0ffdb16ccca3b90e26463 Keep stream aligned. Signed-off-by: Tristan Gingold diff -r afe74d7dcd8b -r a0507fa13cc7 tools/security/secpol_xml2bin.c --- a/tools/security/secpol_xml2bin.c Mon Sep 04 14:06:23 2006 +0200 +++ b/tools/security/secpol_xml2bin.c Mon Sep 04 14:51:09 2006 +0200 @@ -979,13 +979,15 @@ unsigned char *write_policy_reference_bi unsigned char *buf, *ptr; struct acm_policy_reference_buffer *pr_header; u_int32_t len; + u_int32_t name_len; if (policy_reference_name == NULL) { printf("ERROR: No policy reference name found.\n"); exit(EXIT_FAILURE); } - len = (sizeof(struct acm_policy_reference_buffer) + - strlen(policy_reference_name) + 1); + name_len = strlen(policy_reference_name) + 1; /* strend '\0' */ + len = sizeof(struct acm_policy_reference_buffer) + name_len; + len = (len + 7) & ~7; /* Alignment. */ buf = malloc(len); ptr = buf; @@ -994,9 +996,9 @@ unsigned char *write_policy_reference_bi ("ERROR: out of memory allocating label reference buffer.\n"); exit(EXIT_FAILURE); } + memset (buf, 0, len); pr_header = (struct acm_policy_reference_buffer *) buf; - pr_header->len = - htonl(strlen(policy_reference_name) + 1 /* strend \'0' */ ); + pr_header->len = htonl(name_len); ptr += sizeof(struct acm_policy_reference_buffer); strcpy((char *) ptr, policy_reference_name); --Boundary-00=_eAE/ETly4nZ8irf Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_eAE/ETly4nZ8irf--