Blame SOURCES/libvirt-cim-0.6.3-2e9c18d6.patch

9c78f5
From 2e9c18d6dc04f79fab9ce46e16d69635d2ace48f Mon Sep 17 00:00:00 2001
9c78f5
From: Thilo Boehm <tboehm@linux.vnet.ibm.com>
9c78f5
Date: Wed, 13 Nov 2013 19:07:10 +0100
9c78f5
Subject: [PATCH 37/60] FilterEntry: Fix endianness issues
9c78f5
9c78f5
A number of CIM properties was set in an endianness-unsafe manner
9c78f5
leading to failures on big endian systems.
9c78f5
9c78f5
Signed-off-by: Thilo Boehm <tboehm@linux.vnet.ibm.com>
9c78f5
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
9c78f5
Signed-off-by: John Ferlan <jferlan@redhat.com>
9c78f5
---
9c78f5
 src/Virt_FilterEntry.c | 53 ++++++++++++++++++++++++++------------------------
9c78f5
 src/Virt_FilterEntry.h |  2 +-
9c78f5
 src/Virt_FilterList.c  |  3 ++-
9c78f5
 3 files changed, 31 insertions(+), 27 deletions(-)
9c78f5
9c78f5
diff --git a/src/Virt_FilterEntry.c b/src/Virt_FilterEntry.c
9c78f5
index b7042da..ab4a512 100644
9c78f5
--- a/src/Virt_FilterEntry.c
9c78f5
+++ b/src/Virt_FilterEntry.c
9c78f5
@@ -59,8 +59,8 @@ struct rule_data_t {
9c78f5
         const char *dstportend;
9c78f5
 };
9c78f5
 
9c78f5
-static int octets_from_mac(const char * s, unsigned int *buffer,
9c78f5
-                                unsigned int size)
9c78f5
+static int octets_from_mac(const char * s, uint8_t *buffer,
9c78f5
+                           unsigned int size)
9c78f5
 {
9c78f5
         unsigned int _buffer[6];
9c78f5
         unsigned int i, n = 0;
9c78f5
@@ -86,8 +86,8 @@ static int octets_from_mac(const char * s, unsigned int *buffer,
9c78f5
         return n;
9c78f5
 }
9c78f5
 
9c78f5
-static int octets_from_ip(const char * s, unsigned int *buffer,
9c78f5
-                                unsigned int size)
9c78f5
+static int octets_from_ip(const char * s, uint8_t *buffer,
9c78f5
+                          unsigned int size)
9c78f5
 {
9c78f5
         struct in6_addr addr;
9c78f5
         unsigned int family = 0;
9c78f5
@@ -116,7 +116,8 @@ static int octets_from_ip(const char * s, unsigned int *buffer,
9c78f5
         return n;
9c78f5
 }
9c78f5
 
9c78f5
-static CMPIArray *octets_to_cmpi(const CMPIBroker *broker, unsigned int *bytes, int size)
9c78f5
+static CMPIArray *octets_to_cmpi(const CMPIBroker *broker, uint8_t *bytes,
9c78f5
+                                 int size)
9c78f5
 {
9c78f5
         CMPIStatus s = {CMPI_RC_OK, NULL};
9c78f5
         CMPIArray *array = NULL;
9c78f5
@@ -173,7 +174,7 @@ static char *cidr_to_str(const char *cidr)
9c78f5
         return ret;
9c78f5
 }
9c78f5
 
9c78f5
-static int convert_direction(const char *s)
9c78f5
+static uint16_t convert_direction(const char *s)
9c78f5
 {
9c78f5
         enum {NOT_APPLICABLE, INPUT, OUTPUT, BOTH} direction = NOT_APPLICABLE;
9c78f5
 
9c78f5
@@ -189,7 +190,7 @@ static int convert_direction(const char *s)
9c78f5
         return direction;
9c78f5
 }
9c78f5
 
9c78f5
-int convert_priority(const char *s)
9c78f5
+int16_t convert_priority(const char *s)
9c78f5
 {
9c78f5
         if (s == NULL)
9c78f5
                 return 0;
9c78f5
@@ -197,7 +198,7 @@ int convert_priority(const char *s)
9c78f5
         return atoi(s);
9c78f5
 }
9c78f5
 
9c78f5
-static int convert_action(const char *s)
9c78f5
+static uint16_t convert_action(const char *s)
9c78f5
 {
9c78f5
         enum {NONE=0, ACCEPT, DENY, REJECT, RETURN, CONTINUE} action = NONE;
9c78f5
 
9c78f5
@@ -216,7 +217,7 @@ static int convert_action(const char *s)
9c78f5
         return action;
9c78f5
 }
9c78f5
 
9c78f5
-static unsigned long convert_protocol_id(const char *s)
9c78f5
+static uint16_t convert_protocol_id(const char *s)
9c78f5
 {
9c78f5
         enum {NONE = 0, IPV4 = 2048, ARP = 2054, RARP = 32821, IPV6 = 34525} id = NONE;
9c78f5
 
9c78f5
@@ -239,7 +240,7 @@ static void convert_mac_rule_to_instance(
9c78f5
         CMPIInstance *inst,
9c78f5
         const CMPIBroker *broker)
9c78f5
 {
9c78f5
-        unsigned int bytes[48];
9c78f5
+        uint8_t bytes[48];
9c78f5
         unsigned int size = 0;
9c78f5
         CMPIArray *array = NULL;
9c78f5
 
9c78f5
@@ -280,7 +281,7 @@ static void convert_mac_rule_to_instance(
9c78f5
                         (CMPIValue *)&array, CMPI_uint8A);
9c78f5
 
9c78f5
         if (rule->var.mac.protocol_id != NULL) {
9c78f5
-                unsigned long n = convert_protocol_id(rule->var.mac.protocol_id);
9c78f5
+                uint16_t n = convert_protocol_id(rule->var.mac.protocol_id);
9c78f5
 
9c78f5
                 /* Unknown protocolid string. Try converting from hexadecimal value */
9c78f5
                 if (n == 0)
9c78f5
@@ -366,18 +367,19 @@ static void convert_ip_rule_to_instance(
9c78f5
         CMPIInstance *inst,
9c78f5
         const CMPIBroker *broker)
9c78f5
 {
9c78f5
-        unsigned int bytes[48];
9c78f5
+        uint8_t bytes[48];
9c78f5
         unsigned int size = 0;
9c78f5
-        unsigned int n = 0;
9c78f5
+        uint8_t ipver_num = 0;
9c78f5
+        uint16_t port_num = 0;
9c78f5
         CMPIArray *array = NULL;
9c78f5
         struct rule_data_t rule_data;
9c78f5
 
9c78f5
         if (strstr(rule->protocol_id, "v6"))
9c78f5
-                n = 6;
9c78f5
+                ipver_num = 6;
9c78f5
         else
9c78f5
-                n = 4;
9c78f5
+                ipver_num = 4;
9c78f5
 
9c78f5
-        CMSetProperty(inst, "HdrIPVersion",(CMPIValue *)&n, CMPI_uint8);
9c78f5
+        CMSetProperty(inst, "HdrIPVersion",(CMPIValue *)&ipver_num, CMPI_uint8);
9c78f5
 
9c78f5
         fill_rule_data(rule, &rule_data);
9c78f5
 
9c78f5
@@ -480,27 +482,27 @@ static void convert_ip_rule_to_instance(
9c78f5
         }
9c78f5
 
9c78f5
         if (rule_data.srcportstart) {
9c78f5
-                n = atoi(rule_data.srcportstart);
9c78f5
+                port_num = atoi(rule_data.srcportstart);
9c78f5
                 CMSetProperty(inst, "HdrSrcPortStart",
9c78f5
-                        (CMPIValue *)&n, CMPI_uint16);
9c78f5
+                        (CMPIValue *)&port_num, CMPI_uint16);
9c78f5
         }
9c78f5
 
9c78f5
         if (rule_data.srcportend) {
9c78f5
-                n = atoi(rule_data.srcportend);
9c78f5
+                port_num = atoi(rule_data.srcportend);
9c78f5
                 CMSetProperty(inst, "HdrSrcPortEnd",
9c78f5
-                        (CMPIValue *)&n, CMPI_uint16);
9c78f5
+                        (CMPIValue *)&port_num, CMPI_uint16);
9c78f5
         }
9c78f5
 
9c78f5
         if (rule_data.dstportstart) {
9c78f5
-                n = atoi(rule_data.dstportstart);
9c78f5
+                port_num = atoi(rule_data.dstportstart);
9c78f5
                 CMSetProperty(inst, "HdrDestPortStart",
9c78f5
-                        (CMPIValue *)&n, CMPI_uint16);
9c78f5
+                        (CMPIValue *)&port_num, CMPI_uint16);
9c78f5
         }
9c78f5
 
9c78f5
         if (rule_data.dstportend) {
9c78f5
-                n = atoi(rule_data.dstportend);
9c78f5
+                port_num = atoi(rule_data.dstportend);
9c78f5
                 CMSetProperty(inst, "HdrDestPortEnd",
9c78f5
-                        (CMPIValue *)&n, CMPI_uint16);
9c78f5
+                        (CMPIValue *)&port_num, CMPI_uint16);
9c78f5
         }
9c78f5
 }
9c78f5
 
9c78f5
@@ -515,7 +517,8 @@ static CMPIInstance *convert_rule_to_instance(
9c78f5
         const char *sys_name = NULL;
9c78f5
         const char *sys_ccname = NULL;
9c78f5
         const char *basename = NULL;
9c78f5
-        int action, direction, priority = 0;
9c78f5
+        uint16_t action, direction;
9c78f5
+        int16_t priority;
9c78f5
 
9c78f5
         void (*convert_f)(struct acl_rule*, CMPIInstance*, const CMPIBroker*);
9c78f5
 
9c78f5
diff --git a/src/Virt_FilterEntry.h b/src/Virt_FilterEntry.h
9c78f5
index 5057fb0..0589aa0 100644
9c78f5
--- a/src/Virt_FilterEntry.h
9c78f5
+++ b/src/Virt_FilterEntry.h
9c78f5
@@ -77,7 +77,7 @@ CMPIStatus instance_from_rule(
9c78f5
  *
9c78f5
  * @param s A pointer to a string representing the priority
9c78f5
  */
9c78f5
-int convert_priority(const char *s);
9c78f5
+int16_t convert_priority(const char *s);
9c78f5
 #endif
9c78f5
 
9c78f5
 /*
9c78f5
diff --git a/src/Virt_FilterList.c b/src/Virt_FilterList.c
9c78f5
index 7026d8b..b248004 100644
9c78f5
--- a/src/Virt_FilterList.c
9c78f5
+++ b/src/Virt_FilterList.c
9c78f5
@@ -45,7 +45,8 @@ static CMPIInstance *convert_filter_to_instance(
9c78f5
         CMPIInstance *inst = NULL;
9c78f5
         const char *sys_name = NULL;
9c78f5
         const char *sys_ccname = NULL;
9c78f5
-        int direction = 0, priority;
9c78f5
+        uint16_t direction = 0;
9c78f5
+        int16_t priority;
9c78f5
 
9c78f5
         inst = get_typed_instance(broker,
9c78f5
                                   CLASSNAME(reference),
9c78f5
-- 
9c78f5
2.1.0
9c78f5