]> git.eshelyaron.com Git - emacs.git/commitdiff
Port dumping better to WSL
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 21 Dec 2016 17:52:28 +0000 (09:52 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 21 Dec 2016 17:57:05 +0000 (09:57 -0800)
Problem reported by Angelo Graziosi in:
http://lists.gnu.org/archive/html/emacs-devel/2016-12/msg00822.html
* src/sysdep.c (disable_address_randomization):
Detect buggy platforms where 'personality' always returns 0.

src/sysdep.c

index 96c9e5384096298160b179ee06e49826a4a94ccf..86d420f66c4250e0ddde4f389e8cc4d567a90d68 100644 (file)
@@ -144,11 +144,16 @@ static const int baud_convert[] =
 bool
 disable_address_randomization (void)
 {
-  bool disabled = false;
   int pers = personality (0xffffffff);
-  disabled = (! (pers & ADDR_NO_RANDOMIZE)
-             && 0 <= personality (pers | ADDR_NO_RANDOMIZE));
-  return disabled;
+  if (pers < 0)
+    return false;
+  int desired_pers = pers | ADDR_NO_RANDOMIZE;
+
+  /* Call 'personality' twice, to detect buggy platforms like WSL
+     where 'personality' always returns 0.  */
+  return (pers != desired_pers
+         && personality (desired_pers) == pers
+         && personality (0xffffffff) == desired_pers);
 }
 #endif