ia64/xen-unstable

changeset 11880:7b99b8bdbc85

[ACM] Keep stream aligned.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author kfraser@localhost.localdomain
date Wed Oct 18 17:17:15 2006 +0100 (2006-10-18)
parents 3409c35a0b0e
children 8190a4a7ea4d
files tools/security/secpol_xml2bin.c
line diff
     1.1 --- a/tools/security/secpol_xml2bin.c	Wed Oct 18 17:08:09 2006 +0100
     1.2 +++ b/tools/security/secpol_xml2bin.c	Wed Oct 18 17:17:15 2006 +0100
     1.3 @@ -979,13 +979,15 @@ unsigned char *write_policy_reference_bi
     1.4      unsigned char *buf, *ptr;
     1.5      struct acm_policy_reference_buffer *pr_header;
     1.6      u_int32_t len;
     1.7 +    u_int32_t name_len;
     1.8  
     1.9      if (policy_reference_name == NULL) {
    1.10          printf("ERROR: No policy reference name found.\n");
    1.11          exit(EXIT_FAILURE);
    1.12      }
    1.13 -    len = (sizeof(struct acm_policy_reference_buffer) +
    1.14 -           strlen(policy_reference_name) + 1);
    1.15 +    name_len = strlen(policy_reference_name) + 1; /* strend '\0' */
    1.16 +    len = sizeof(struct acm_policy_reference_buffer) + name_len;
    1.17 +    len = (len + 7) & ~7; /* Alignment.  */
    1.18      buf = malloc(len);
    1.19      ptr = buf;
    1.20  
    1.21 @@ -994,9 +996,9 @@ unsigned char *write_policy_reference_bi
    1.22              ("ERROR: out of memory allocating label reference buffer.\n");
    1.23          exit(EXIT_FAILURE);
    1.24      }
    1.25 +    memset (buf, 0, len);
    1.26      pr_header = (struct acm_policy_reference_buffer *) buf;
    1.27 -    pr_header->len =
    1.28 -        htonl(strlen(policy_reference_name) + 1 /* strend \'0' */ );
    1.29 +    pr_header->len = htonl(name_len);
    1.30      ptr += sizeof(struct acm_policy_reference_buffer);
    1.31      strcpy((char *) ptr, policy_reference_name);
    1.32