On 2016-02-19 05:56:27 [+0000], Adam D. Barratt wrote: > The sparc build has now failed three times, across two different builds.
And why did mips pass? Isn't mips the difficult one? The patch attached is a simplified version of what I had on smetana during testing. I would give it another try to make sure it works before the final upload. Speaking of which: does this count as a wheezy-pu bug for clamav/0.99+dfsg-0+deb7u2? Do you want to see this change in unstable before it hits wheezy? I have a tiny testcase which fails on my armel box but succeeds on the armel porterbox. I guess the HW on the porterbox is new enough to work with this (mine is ARMv5 and the porterbox is ARMv7 which is enough for armhf). My testcase does not fail on the mips/mipsel porter boxes. > Regards, > > Adam Sebastian
diff --git a/libclamav/yara_exec.c b/libclamav/yara_exec.c index dbd7ae8..eb06fbb 100644 --- a/libclamav/yara_exec.c +++ b/libclamav/yara_exec.c @@ -54,6 +54,16 @@ typedef struct _YR_MATCH #include "yara_exec.h" #endif +#define __packed __attribute__((packed)) + +struct __una_u64 { uint64_t x; } __packed; + +static inline uint64_t get_unaligned_64(const void *p) +{ + const struct __una_u64 *ptr = (const struct __una_u64 *)p; + return ptr->x; +} + #define STACK_SIZE 16384 #define MEM_SIZE MAX_LOOP_NESTING * LOOP_LOCAL_VARS @@ -184,7 +194,7 @@ int yr_execute_code( #endif case OP_PUSH: - r1 = *(uint64_t*)(ip + 1); + r1 = get_unaligned_64(ip + 1); ip += sizeof(uint64_t); push(r1); break; @@ -194,38 +204,38 @@ int yr_execute_code( break; case OP_CLEAR_M: - r1 = *(uint64_t*)(ip + 1); + r1 = get_unaligned_64(ip + 1); ip += sizeof(uint64_t); mem[r1] = 0; break; case OP_ADD_M: - r1 = *(uint64_t*)(ip + 1); + r1 = get_unaligned_64(ip + 1); ip += sizeof(uint64_t); pop(r2); mem[r1] += r2; break; case OP_INCR_M: - r1 = *(uint64_t*)(ip + 1); + r1 = get_unaligned_64(ip + 1); ip += sizeof(uint64_t); mem[r1]++; break; case OP_PUSH_M: - r1 = *(uint64_t*)(ip + 1); + r1 = get_unaligned_64(ip + 1); ip += sizeof(uint64_t); push(mem[r1]); break; case OP_POP_M: - r1 = *(uint64_t*)(ip + 1); + r1 = get_unaligned_64(ip + 1); ip += sizeof(uint64_t); pop(mem[r1]); break; case OP_SWAPUNDEF: - r1 = *(uint64_t*)(ip + 1); + r1 = get_unaligned_64(ip + 1); ip += sizeof(uint64_t); pop(r2); if (r2 != UNDEFINED) @@ -540,7 +550,7 @@ int yr_execute_code( // r1 = number of arguments - r1 = *(uint64_t*)(ip + 1); + r1 = get_unaligned_64(ip + 1); ip += sizeof(uint64_t); // pop arguments from stack and copy them to args array @@ -854,7 +864,7 @@ int yr_execute_code( #if REAL_YARA //not supported ClamAV case OP_IMPORT: - r1 = *(uint64_t*)(ip + 1); + r1 = get_unaligned_64(ip + 1); ip += sizeof(uint64_t); FAIL_ON_ERROR(yr_modules_load(