Browse code

bb#2695

aCaB authored on 2011/04/10 00:21:22
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Sat Apr  9 17:20:35 CEST 2011 (acab)
2
+------------------------------------
3
+ * libclamav/pe_icons.c: don't sigbus on sparc (bb#2695)
4
+
1 5
 Sat Apr  9 03:56:17 CEST 2011 (acab)
2 6
 ------------------------------------
3 7
  * libclamav/pe.c: reset corrupted status before bytecode hooks (bb#2544)
... ...
@@ -29,8 +29,8 @@
29 29
 #include "others.h"
30 30
 
31 31
 
32
-#define EC32(x) le32_to_host(x)
33
-#define EC16(x) le16_to_host(x)
32
+#define READ32(x) cli_readint32(&(x))
33
+#define READ16(x) cli_readint16(&(x))
34 34
 #define USE_FLOATS
35 35
 #ifdef USE_FLOATS
36 36
 #define LABDIFF(x) labdiff(x)
... ...
@@ -1222,17 +1222,17 @@ static int parseicon(icon_groupset *set, uint32_t rva, cli_ctx *ctx, struct cli_
1222 1222
 	return CL_SUCCESS;
1223 1223
     }
1224 1224
 
1225
-    if(EC32(bmphdr.sz) < sizeof(bmphdr)) {
1225
+    if(READ32(bmphdr.sz) < sizeof(bmphdr)) {
1226 1226
 	cli_dbgmsg("parseicon: BMP header too small\n");
1227 1227
 	return CL_SUCCESS;
1228 1228
     }
1229 1229
 
1230 1230
     /* seek to the end of v4/v5 header */
1231
-    icoff += EC32(bmphdr.sz);
1231
+    icoff += READ32(bmphdr.sz);
1232 1232
 
1233
-    width = EC32(bmphdr.w);
1234
-    height = EC32(bmphdr.h) / 2;
1235
-    depth = EC16(bmphdr.depth);
1233
+    width = READ32(bmphdr.w);
1234
+    height = READ32(bmphdr.h) / 2;
1235
+    depth = READ16(bmphdr.depth);
1236 1236
     if(width > 256 || height > 256 || width < 16 || height < 16) {
1237 1237
 	cli_dbgmsg("parseicon: Image too small or too big (%ux%u)\n", width, height);
1238 1238
 	return CL_SUCCESS;
... ...
@@ -1308,7 +1308,7 @@ static int parseicon(icon_groupset *set, uint32_t rva, cli_ctx *ctx, struct cli_
1308 1308
 		    have = 8;
1309 1309
 		}
1310 1310
 		have -= depth;
1311
-		imagedata[(height - 1 - y) * width + x] = EC32(palette[(c >> have) & ((1<<depth)-1)]);
1311
+		imagedata[(height - 1 - y) * width + x] = READ32(palette[(c >> have) & ((1<<depth)-1)]);
1312 1312
 	    }
1313 1313
 	    break;
1314 1314
 	}