Browse code

bb #4324

memcpy() crashes because GCC sees 'struct cli_exe_section*'
and assumes that section is aligned to at least 4 bytes.
But it isn't, so change the parameter to just 'void*'.

(Casting doesn't help, as GCC sees through it).

Also fixes part 1 of bb #3789.

Török Edvin authored on 2012/03/01 00:01:56
Showing 4 changed files
... ...
@@ -1,3 +1,7 @@
1
+Wed Feb 29 17:02:18 EET 2012 (edwin)
2
+------------------------------------
3
+ * libclamav/bytecode_api*: Fix Sparc crash (bb #4324)
4
+
1 5
 Tue Feb  7 23:23:48 CET 2012 (tk)
2 6
 ---------------------------------
3 7
  * libclamav: fix bytecode whitelisting
... ...
@@ -439,10 +439,10 @@ uint8_t* cli_bcapi_malloc(struct cli_bc_ctx *ctx, uint32_t size)
439 439
     return v;
440 440
 }
441 441
 
442
-int32_t cli_bcapi_get_pe_section(struct cli_bc_ctx *ctx, struct cli_exe_section* section, uint32_t num)
442
+int32_t cli_bcapi_get_pe_section(struct cli_bc_ctx *ctx, void* section, uint32_t num)
443 443
 {
444 444
     if (num < ctx->hooks.pedata->nsections) {
445
-	memcpy(section, &ctx->sections[num], sizeof(*section));
445
+	memcpy(section, &ctx->sections[num], sizeof(struct cli_exe_section));
446 446
 	return 0;
447 447
     }
448 448
     return -1;
... ...
@@ -52,7 +52,7 @@ int32_t cli_bcapi_file_find(struct cli_bc_ctx *ctx , const uint8_t*, uint32_t);
52 52
 int32_t cli_bcapi_file_byteat(struct cli_bc_ctx *ctx , uint32_t);
53 53
 uint8_t* cli_bcapi_malloc(struct cli_bc_ctx *ctx , uint32_t);
54 54
 uint32_t cli_bcapi_test2(struct cli_bc_ctx *ctx , uint32_t);
55
-int32_t cli_bcapi_get_pe_section(struct cli_bc_ctx *ctx , struct cli_exe_section*, uint32_t);
55
+int32_t cli_bcapi_get_pe_section(struct cli_bc_ctx *ctx , void*, uint32_t);
56 56
 int32_t cli_bcapi_fill_buffer(struct cli_bc_ctx *ctx , uint8_t*, uint32_t, uint32_t, uint32_t, uint32_t);
57 57
 int32_t cli_bcapi_extract_new(struct cli_bc_ctx *ctx , int32_t);
58 58
 int32_t cli_bcapi_read_number(struct cli_bc_ctx *ctx , uint32_t);
... ...
@@ -50,7 +50,7 @@ int32_t cli_bcapi_file_find(struct cli_bc_ctx *ctx , const uint8_t*, uint32_t);
50 50
 int32_t cli_bcapi_file_byteat(struct cli_bc_ctx *ctx , uint32_t);
51 51
 uint8_t* cli_bcapi_malloc(struct cli_bc_ctx *ctx , uint32_t);
52 52
 uint32_t cli_bcapi_test2(struct cli_bc_ctx *ctx , uint32_t);
53
-int32_t cli_bcapi_get_pe_section(struct cli_bc_ctx *ctx , struct cli_exe_section*, uint32_t);
53
+int32_t cli_bcapi_get_pe_section(struct cli_bc_ctx *ctx , void*, uint32_t);
54 54
 int32_t cli_bcapi_fill_buffer(struct cli_bc_ctx *ctx , uint8_t*, uint32_t, uint32_t, uint32_t, uint32_t);
55 55
 int32_t cli_bcapi_extract_new(struct cli_bc_ctx *ctx , int32_t);
56 56
 int32_t cli_bcapi_read_number(struct cli_bc_ctx *ctx , uint32_t);