Browse code

be fixes - bb#2151

aCaB authored on 2010/08/03 00:17:46
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Mon Aug  2 17:16:24 CEST 2010 (acab)
2
+------------------------------------
3
+ * libclamav/pe_icons.c: BE fixes (bb#2151)
4
+
1 5
 Mon Aug  2 16:08:04 CEST 2010 (tk)
2 6
 ----------------------------------
3 7
  * freshclam/manager.c: don't call cli_bytecode_prepare() when Bytecode is
... ...
@@ -30,6 +30,7 @@
30 30
 
31 31
 
32 32
 #define EC32(x) le32_to_host(x)
33
+#define EC16(x) le16_to_host(x)
33 34
 #define USE_FLOATS
34 35
 #ifdef USE_FLOATS
35 36
 #define LABDIFF(x) labdiff(x)
... ...
@@ -111,8 +112,8 @@ int cli_scanicon(icon_groupset *set, uint32_t resdir_rva, cli_ctx *ctx, struct c
111 111
 
112 112
 		    while(icnt && gsz >= 14) {
113 113
 			dir = (struct icondir *)grp;
114
-			cli_dbgmsg("cli_scanicon: Icongrp @%x - %ux%ux%u - (id=%x, rsvd=%u, planes=%u, palcnt=%u, sz=%x)\n", gicons.rvas[curicon], dir->w, dir->h, dir->depth, dir->id, dir->planes, dir->palcnt, dir->rsvd, dir->sz);
115
-			findres(3, dir->id, resdir_rva, map, exe_sections, nsections, hdr_size, icon_cb, &icons);
114
+			cli_dbgmsg("cli_scanicon: Icongrp @%x - %ux%ux%u - (id=%x, rsvd=%u, planes=%u, palcnt=%u, sz=%x)\n", gicons.rvas[curicon], dir->w, dir->h, cli_readint16(&dir->depth), cli_readint16(&dir->id), cli_readint16(&dir->planes), dir->palcnt, dir->rsvd, cli_readint32(&dir->sz));
115
+			findres(3, cli_readint16(&dir->id), resdir_rva, map, exe_sections, nsections, hdr_size, icon_cb, &icons);
116 116
 			grp += 14;
117 117
 			gsz -= 14;
118 118
 		    }
... ...
@@ -1230,7 +1231,7 @@ static int parseicon(icon_groupset *set, uint32_t rva, cli_ctx *ctx, struct cli_
1230 1230
 	    
1231 1231
     width = EC32(bmphdr.w);
1232 1232
     height = EC32(bmphdr.h) / 2;
1233
-    depth = EC32(bmphdr.depth);
1233
+    depth = EC16(bmphdr.depth);
1234 1234
     if(width > 256 || height > 256 || width < 16 || height < 16) {
1235 1235
 	cli_dbgmsg("parseicon: Image too small or too big (%ux%u)\n", width, height);
1236 1236
 	return CL_SUCCESS;
... ...
@@ -1306,7 +1307,7 @@ static int parseicon(icon_groupset *set, uint32_t rva, cli_ctx *ctx, struct cli_
1306 1306
 		    have = 8;
1307 1307
 		}
1308 1308
 		have -= depth;
1309
-		imagedata[(height - 1 - y) * width + x] = palette[(c >> have) & ((1<<depth)-1)];
1309
+		imagedata[(height - 1 - y) * width + x] = EC32(palette[(c >> have) & ((1<<depth)-1)]);
1310 1310
 	    }
1311 1311
 	    break;
1312 1312
 	}