File 0001-libcmpiutil-Fix-endianness-issues-in-embedded-object.patch of Package libcmpiutil (Revision 297e6c09957c676d330d280dbb00edd7)
Currently displaying revision 297e6c09957c676d330d280dbb00edd7 , Show latest
xxxxxxxxxx
1
From 8c25b49b05065ce90c83b2102bd8462a7bb18d69 Mon Sep 17 00:00:00 2001
2
From: Thilo Boehm <tboehm@linux.vnet.ibm.com>
3
Date: Thu, 8 Aug 2013 15:27:53 +0200
4
Subject: [PATCH] libcmpiutil: Fix endianness issues in embedded object parsing
5
6
The auxiliary functions _set_int_prop/parse_int_property only
7
worked on little-endian archs as they performed an incorrect
8
reinterpretation of 64bit integers. Fixed by using the proper
9
CMPIValue union fields.
10
11
Signed-off-by: Thilo Boehm <tboehm@linux.vnet.ibm.com>
12
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
13
---
14
eo_parser.c | 35 ++++++++++++++++++++++-------------
15
eo_parser_xml.c | 49 +++++++++++++++++++++++++++++++++++++++----------
16
2 files changed, 61 insertions(+), 23 deletions(-)
17
18
diff --git a/eo_parser.c b/eo_parser.c
19
index 36106fddc99d..4c5b0ee229dd 100644
20
--- a/eo_parser.c
21
+++ b/eo_parser.c
22
23
CMPIInstance *inst)
24
{
25
CMPIStatus s;
26
- uint64_t unsigned_val = 0;
27
- int64_t signed_val = 0;
28
+ CMPIValue val;
29
30
- switch(type) {
31
+ switch (type) {
32
case CMPI_uint64:
33
+ val.uint64 = (uint64_t) value;
34
+ break;
35
case CMPI_uint32:
36
+ val.uint32 = (uint32_t) value;
37
+ break;
38
case CMPI_uint16:
39
+ val.uint16 = (uint16_t) value;
40
+ break;
41
case CMPI_uint8:
42
- unsigned_val = (uint64_t) value;
43
- s = CMSetProperty(inst,
44
- prop,
45
- (CMPIValue *) &(unsigned_val),
46
- type);
47
+ val.uint8 = (uint8_t) value;
48
break;
49
case CMPI_sint64:
50
+ val.sint64 = (int64_t) value;
51
+ break;
52
case CMPI_sint32:
53
+ val.sint32 = (int32_t) value;
54
+ break;
55
case CMPI_sint16:
56
+ val.sint16 = (int16_t) value;
57
+ break;
58
case CMPI_sint8:
59
+ val.sint8 = (int8_t) value;
60
+ break;
61
default:
62
- signed_val = (int64_t) value;
63
- s = CMSetProperty(inst,
64
- prop,
65
- (CMPIValue *) &(signed_val),
66
- type);
67
+ return 0;
68
}
69
+ s = CMSetProperty(inst,
70
+ prop,
71
+ &val,
72
+ type);
73
74
if (s.rc == CMPI_RC_OK)
75
return 1;
76
diff --git a/eo_parser_xml.c b/eo_parser_xml.c
77
index c8b28cc63289..551a87be8a8d 100644
78
--- a/eo_parser_xml.c
79
+++ b/eo_parser_xml.c
80
81
if (sign) {
82
int64_t _val;
83
ret = sscanf(string, "%" SCNi64, &_val);
84
- val->sint64 = _val;
85
+ switch (size) {
86
+ case 8:
87
+ t = CMPI_sint8;
88
+ val->sint8 = (int8_t) _val;
89
+ break;
90
+ case 16:
91
+ t = CMPI_sint16;
92
+ val->sint16 = (int16_t) _val;
93
+ break;
94
+ case 32:
95
+ t = CMPI_sint32;
96
+ val->sint32 = (int32_t) _val;
97
+ break;
98
+ default:
99
+ case 64:
100
+ t = CMPI_sint64;
101
+ val->sint64 = (int64_t) _val;
102
+ break;
103
+ };
104
} else {
105
uint64_t _val;
106
ret = sscanf(string, "%" SCNu64, &_val);
107
- val->uint64 = _val;
108
+ switch (size) {
109
+ case 8:
110
+ t = CMPI_uint8;
111
+ val->uint8 = (uint8_t) _val;
112
+ break;
113
+ case 16:
114
+ t = CMPI_uint16;
115
+ val->uint16 = (uint16_t) _val;
116
+ break;
117
+ case 32:
118
+ t = CMPI_uint32;
119
+ val->uint32 = (uint32_t) _val;
120
+ break;
121
+ default:
122
+ case 64:
123
+ t = CMPI_uint64;
124
+ val->uint64 = (uint64_t) _val;
125
+ break;
126
+
127
+ };
128
}
129
130
if (ret != 1) {
131
132
return CMPI_null;
133
}
134
135
- switch (size) {
136
- case 8: t = sign ? CMPI_sint8 : CMPI_uint8; break;
137
- case 16: t = sign ? CMPI_sint16 : CMPI_uint16; break;
138
- case 32: t = sign ? CMPI_sint32 : CMPI_uint32; break;
139
- default:
140
- case 64: t = sign ? CMPI_sint64 : CMPI_uint64; break;
141
- };
142
-
143
return t;
144
}
145
146
--
147
1.8.4.5
148
149