Alexandre Julliard : loader: Make sure the new stack is 16-byte aligned in the preloader.

Alexandre Julliard julliard at winehq.org
Thu Apr 7 07:36:45 CDT 2011


Module: wine
Branch: stable
Commit: 177e15df4bb1c4e926df17a0847fd2d3c85ca461
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=177e15df4bb1c4e926df17a0847fd2d3c85ca461

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Dec 16 16:52:02 2010 +0100

loader: Make sure the new stack is 16-byte aligned in the preloader.
(cherry picked from commit 144cb78dbaeedcc36946907c5ccf391ecb011f04)

---

 loader/preloader.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/loader/preloader.c b/loader/preloader.c
index 2dc2872..8524ba5 100644
--- a/loader/preloader.c
+++ b/loader/preloader.c
@@ -512,18 +512,19 @@ static void set_auxiliary_values( ElfW(auxv_t) *av, const ElfW(auxv_t) *new_av,
 
     src = (char *)*stack;
     dst = src - (new_count - delete_count) * sizeof(*av);
-    if (new_count > delete_count)   /* need to make room for the extra values */
+    dst = (char *)((unsigned long)dst & ~15);
+    if (dst < src)   /* need to make room for the extra values */
     {
         int len = (char *)(av + av_count + 1) - src;
         for (i = 0; i < len; i++) dst[i] = src[i];
     }
-    else if (new_count < delete_count)  /* get rid of unused values */
+    else if (dst > src)  /* get rid of unused values */
     {
         int len = (char *)(av + av_count + 1) - src;
         for (i = len - 1; i >= 0; i--) dst[i] = src[i];
     }
     *stack = dst;
-    av -= (new_count - delete_count);
+    av = (ElfW(auxv_t) *)((char *)av + (dst - src));
 
     /* now set the values */
     for (j = 0; new_av[j].a_type != AT_NULL; j++)




More information about the wine-cvs mailing list