git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1309 77e5149b-7576-45b1-b177-96237e5ba77b
Trog authored on 2005/02/05 18:41:35... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Sat Feb 5 09:39:48 GMT 2005 (trog) |
|
2 |
+----------------------------------- |
|
3 |
+ * libclamav/special.c: support for big-endian system in RIFF code. |
|
4 |
+ |
|
1 | 5 |
Fri Feb 4 10:02:08 GMT 2005 (trog) |
2 | 6 |
----------------------------------- |
3 | 7 |
* libclamav/special.c: check RIFF files for MS05-002. Not yet activated. |
... | ... |
@@ -22,6 +22,7 @@ |
22 | 22 |
#include <unistd.h> |
23 | 23 |
#include <netinet/in.h> |
24 | 24 |
|
25 |
+#include "clamav-config.h" |
|
25 | 26 |
#include "clamav.h" |
26 | 27 |
#include "others.h" |
27 | 28 |
|
... | ... |
@@ -117,15 +118,24 @@ int cli_check_jpeg_exploit(int fd) |
117 | 117 |
} |
118 | 118 |
} |
119 | 119 |
|
120 |
+static uint32_t riff_endian_convert_32(uint32_t value, int big_endian) |
|
121 |
+{ |
|
122 |
+ if (big_endian) { |
|
120 | 123 |
#if WORDS_BIGENDIAN == 0 |
121 |
-#define riff_endian_convert_32(v) (v) |
|
124 |
+ return ((value >> 24) | ((value & 0x00FF0000) >> 8) | |
|
125 |
+ ((value & 0x0000FF00) << 8) | (value << 24)); |
|
122 | 126 |
#else |
123 |
-static uint32_t riff_endian_convert_32(uint32_t v) |
|
124 |
-{ |
|
125 |
- return ((v >> 24) | ((v & 0x00FF0000) >> 8) | |
|
126 |
- ((v & 0x0000FF00) << 8) | (v << 24)); |
|
127 |
-} |
|
127 |
+ return value; |
|
128 | 128 |
#endif |
129 |
+ } else { |
|
130 |
+#if WORDS_BIGENDIAN == 0 |
|
131 |
+ return value; |
|
132 |
+#else |
|
133 |
+ return ((value >> 24) | ((value & 0x00FF0000) >> 8) | |
|
134 |
+ ((value & 0x0000FF00) << 8) | (value << 24)); |
|
135 |
+#endif |
|
136 |
+ } |
|
137 |
+} |
|
129 | 138 |
|
130 | 139 |
static int riff_read_chunk(int fd, int big_endian, int rec_level) |
131 | 140 |
{ |
... | ... |
@@ -147,9 +157,7 @@ static int riff_read_chunk(int fd, int big_endian, int rec_level) |
147 | 147 |
if (cli_readn(fd, &chunk_size, length) != length) { |
148 | 148 |
return 0; |
149 | 149 |
} |
150 |
- if (big_endian) { |
|
151 |
- chunk_size = riff_endian_convert_32(chunk_size); |
|
152 |
- } |
|
150 |
+ chunk_size = riff_endian_convert_32(chunk_size, big_endian); |
|
153 | 151 |
|
154 | 152 |
if (memcmp(&chunk_id, "RIFF", 4) == 0) { |
155 | 153 |
return 0; |
... | ... |
@@ -213,9 +221,7 @@ int cli_check_riff_exploit(int fd) |
213 | 213 |
return 0; |
214 | 214 |
} |
215 | 215 |
|
216 |
- if (big_endian) { |
|
217 |
- chunk_size = riff_endian_convert_32(chunk_size); |
|
218 |
- } |
|
216 |
+ chunk_size = riff_endian_convert_32(chunk_size, big_endian); |
|
219 | 217 |
|
220 | 218 |
do { |
221 | 219 |
retval = riff_read_chunk(fd, big_endian, 1); |