Skip to contentSkip to conversation

Explicitly cast byte arrays when used in copy_from_guest

PATCH New Stefan Berger 1 participant 1 message Aug 6, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Explicitly cast byte arrays when used in copy_from_guest

Explicitly cast the target array type to an array of 'u8' since the number of bytes copied is calculated from the type of element in the target array times the number of elements (3rd parameter).

---
 xen-unstable.hg/xen/acm/acm_policy.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
xen-unstable.hg/xen/acm/acm_policy.c +4 -3
Index: root/xen-unstable.hg/xen/acm/acm_policy.c
===================================================================
@@ -44,6 +44,7 @@ static void acm_doms_restore_ssidref(voi
 static ssidref_t oldssid_to_newssid(const struct acm_ssid_domain *,
                                     const struct acm_sized_buffer *map);
 
+#define BYTE_ARRAY(a) ((u8 *)(a))
 
 int
 acm_set_policy(XEN_GUEST_HANDLE_64(void) buf, u32 buf_size)
@@ -710,10 +711,10 @@ acm_change_policy(struct acm_change_poli
         goto acm_chg_policy_exit;
     }
 
-    if ( copy_from_guest(dels.array,
+    if ( copy_from_guest(BYTE_ARRAY(dels.array),
                          chgpolicy->del_array,
                          chgpolicy->delarray_size) ||
-         copy_from_guest(ssidmap.array,
+         copy_from_guest(BYTE_ARRAY(ssidmap.array),
                          chgpolicy->chg_array,
                          chgpolicy->chgarray_size) ||
          copy_from_guest(binpolicy,
@@ -844,7 +845,7 @@ acm_relabel_domains(struct acm_relabel_d
         memset(errors.array, 0x0, sizeof(uint32_t) * errors.num_items);
     }
 
-    if ( copy_from_guest(relabels.array,
+    if ( copy_from_guest(BYTE_ARRAY(relabels.array),
                          relabel->relabel_map,
                          relabel->relabel_map_size) )
     {

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel