-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libffi was broken on 64-bit, any c function returning a struct > 8 bytes and not a multiple of 16 will cause a segfault. This is because between 3.1 and 3.2 somebody changed (size != 1 || size != 2 || size != 4 || size != 8) into (size & (1 | 2 | 4 | 8) == 0), which is not the same.
- Loading branch information
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- src/libffi-3.2.1/src/x86/ffi.c.orig 2016-07-20 21:24:49.000771900 +0100 | ||
+++ src/libffi-3.2.1/src/x86/ffi.c 2016-07-20 21:25:09.918786700 +0100 | ||
@@ -65,7 +65,8 @@ | ||
if ((ecif->cif->flags == FFI_TYPE_STRUCT | ||
|| ecif->cif->flags == FFI_TYPE_MS_STRUCT) | ||
#ifdef X86_WIN64 | ||
- && ((ecif->cif->rtype->size & (1 | 2 | 4 | 8)) == 0) | ||
+ && (ecif->cif->rtype->size != 1 && ecif->cif->rtype->size != 2 | ||
+ && ecif->cif->rtype->size != 4 && ecif->cif->rtype->size != 8) | ||
#endif | ||
) | ||
{ | ||
@@ -108,7 +109,7 @@ | ||
#ifdef X86_WIN64 | ||
if (z > FFI_SIZEOF_ARG | ||
|| ((*p_arg)->type == FFI_TYPE_STRUCT | ||
- && (z & (1 | 2 | 4 | 8)) == 0) | ||
+ && (z != 1 && z != 2 && z != 4 && z != 8)) | ||
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE | ||
|| ((*p_arg)->type == FFI_TYPE_LONGDOUBLE) | ||
#endif | ||
@@ -360,7 +361,8 @@ | ||
#ifdef X86_WIN64 | ||
if (rvalue == NULL | ||
&& cif->flags == FFI_TYPE_STRUCT | ||
- && ((cif->rtype->size & (1 | 2 | 4 | 8)) == 0)) | ||
+ && cif->rtype->size != 1 && cif->rtype->size != 2 | ||
+ && cif->rtype->size != 4 && cif->rtype->size != 8) | ||
{ | ||
ecif.rvalue = alloca((cif->rtype->size + 0xF) & ~0xF); | ||
} | ||
@@ -545,7 +547,8 @@ | ||
if ((cif->flags == FFI_TYPE_STRUCT | ||
|| cif->flags == FFI_TYPE_MS_STRUCT) | ||
#ifdef X86_WIN64 | ||
- && ((cif->rtype->size & (1 | 2 | 4 | 8)) == 0) | ||
+ && ((cif->rtype->size != 1 && cif->rtype->size != 2 | ||
+ && cif->rtype->size != 4 && cif->rtype->size != 8)) | ||
#endif | ||
) | ||
{ | ||
@@ -608,7 +611,7 @@ | ||
#ifdef X86_WIN64 | ||
if (z > FFI_SIZEOF_ARG | ||
|| ((*p_arg)->type == FFI_TYPE_STRUCT | ||
- && (z & (1 | 2 | 4 | 8)) == 0) | ||
+ && (z != 1 && z != 2 && z != 4 && z != 8)) | ||
#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE | ||
|| ((*p_arg)->type == FFI_TYPE_LONGDOUBLE) | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,9 @@ PKG_PRIORITY=extra | |
|
||
# | ||
|
||
PKG_PATCHES=() | ||
PKG_PATCHES=( | ||
libffi/fix_return_size.patch | ||
) | ||
|
||
# | ||
|
||
|