--- hurd/exec/exec.c	2004-10-22 19:38:55.000000000 -0700
+++ hurd/exec/exec.c	2006-10-18 22:11:30.970886304 -0700
@@ -1009,7 +1009,10 @@
       fclose (&e->stream);
 #else
       if (e->file_data != NULL)
-	free (e->file_data);
+        {
+          free (e->file_data);
+          e->file_data = NULL;
+        }
       else if (map_buffer (e) != NULL)
 	munmap (map_buffer (e), map_vsize (e));
 #endif
@@ -1202,14 +1205,20 @@
   /* The output is complete.  Clean up the stream and store its resultant
      buffer and size in the execdata as the file contents.  */
   fclose (zipout);
-  e->file_data = zipdata;
-  e->file_size = zipdatasz;
-
   /* Clean up the old exec file stream's state.
      Now that we have the contents all in memory (in E->file_data),
      nothing will in fact ever try to use E->stream again.  */
   finish (e, 0);
 
+  /* Copy the zipdata over to an aligned memory region */
+  char *zipdata_aligned = valloc (zipdatasz);
+  memcpy (zipdata_aligned, zipdata, zipdatasz);
+
+  e->file_data = zipdata_aligned;
+  e->file_size = zipdatasz;
+  e->map_buffer = mmap (0, zipdatasz, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
+  memcpy(e->map_buffer, zipdata, zipdatasz);
+
   /* Prepare the stream state to use the file contents already in memory.  */
   prepare_in_memory (e);
 }
@@ -1297,14 +1306,21 @@
   /* The output is complete.  Clean up the stream and store its resultant
      buffer and size in the execdata as the file contents.  */
   fclose (zipout);
-  e->file_data = zipdata;
-  e->file_size = zipdatasz;
 
   /* Clean up the old exec file stream's state.
      Now that we have the contents all in memory (in E->file_data),
      nothing will in fact ever try to use E->stream again.  */
   finish (e, 0);
 
+  /* Copy the zipdata over to an aligned memory region */
+  char *zipdata_aligned = valloc (zipdatasz);
+  memcpy (zipdata_aligned, zipdata, zipdatasz);
+
+  e->file_data = zipdata_aligned;
+  e->file_size = zipdatasz;
+  e->map_buffer = mmap (0, zipdatasz, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
+  memcpy(e->map_buffer, zipdata, zipdatasz);
+
   /* Prepare the stream state to use the file contents already in memory.  */
   prepare_in_memory (e);
 }
