summaryrefslogtreecommitdiff
path: root/src/arm
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2017-10-24 13:53:56 -0700
committerSaleem Abdulrasool <compnerd@compnerd.org>2017-10-24 16:44:54 -0700
commit3c372c384a94db23fdaf9fe64a4beb86159cf6d3 (patch)
tree254c543711d4cb781203e5c5d63be1eb1a64603c /src/arm
parent8d26e8c6da23b10331181a4bbf837f479ce5d7d2 (diff)
downloadlibffi-3c372c384a94db23fdaf9fe64a4beb86159cf6d3.tar.gz
arm: fix a level of indirection issue
Rather than relying on the stack being 0'ed out always, do it manually. The stack generally happened to be zero, and because the compiler realizes that the tests are dealing with chars truncates the read value. However, the top 3 nibbles of the value are undefined and may be non-zero. The indirection level caused a null-pointer dereference. Explicitly scribbling on the stack during the allocation causes test failures without the original zexting behaviour.
Diffstat (limited to 'src/arm')
-rw-r--r--src/arm/ffi.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/arm/ffi.c b/src/arm/ffi.c
index 12ce04a..d838271 100644
--- a/src/arm/ffi.c
+++ b/src/arm/ffi.c
@@ -31,6 +31,7 @@
#include <fficonfig.h>
#include <ffi.h>
#include <ffi_common.h>
+#include <stdint.h>
#include <stdlib.h>
#include "internal.h"
@@ -422,7 +423,7 @@ ffi_prep_incoming_args_SYSV (ffi_cif *cif, void *rvalue,
else
{
if (cif->rtype->size && cif->rtype->size < 4)
- **(int32_t **) rvalue = 0;
+ *(uint32_t *) rvalue = 0;
}
for (i = 0, n = cif->nargs; i < n; i++)