Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 gcl (2.6.9-12) unstable; urgency=high
 .
   * 2.6.10pre test 13
Author: Camm Maguire <camm@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- gcl-2.6.9.orig/configure
+++ gcl-2.6.9/configure
@@ -6736,7 +6736,6 @@ else
 	        #include <stdio.h>
 	        #include <stdlib.h>
 		void gprof_cleanup() {};
-		int *cs_org;
  		int main(int argc,char **argv,char **envp) {
 		#include "h/unrandomize.h"
 		return 0;}
@@ -6766,7 +6765,6 @@ else
 #include <stdio.h>
 	            #include <stdlib.h>
 		    void gprof_cleanup() {};
-		    int *cs_org;
 		    int main(int argc,char * argv[],char * envp[]) {
 			FILE *f;
 			#ifdef CAN_UNRANDOMIZE_SBRK
@@ -6798,7 +6796,6 @@ else
 #include <stdio.h>
 	            #include <stdlib.h>
 		    void gprof_cleanup() {};
-		    int *cs_org;
 		    int main(int argc,char * argv[],char * envp[]) {
 			FILE *f;
 			#ifdef CAN_UNRANDOMIZE_SBRK
@@ -6866,7 +6863,6 @@ else
         }
 
 	void gprof_cleanup() {};
-	int *cs_org;
 	int main(int argc,char **argv,char **envp) {
 	void *v ;
 	FILE *fp = fopen("conftest1","w");
@@ -6925,7 +6921,6 @@ else
         }
 
 	void gprof_cleanup() {};
-	int *cs_org;
 	int main(int argc,char **argv,char **envp) {
 	void *v ;
 	FILE *fp = fopen("conftest1","w");
@@ -6979,7 +6974,6 @@ else
 	#include <stdio.h>
 	#include <stdlib.h>
 	void gprof_cleanup() {};
-	int *cs_org;
 	int main(int argc,char **argv,char **envp) {
 	#ifdef CAN_UNRANDOMIZE_SBRK
 	#include "h/unrandomize.h"
@@ -7019,7 +7013,6 @@ else
 	#include <stdio.h>
 	#include <stdlib.h>
 	void gprof_cleanup() {};
-	int *cs_org;
 	int main(int argc,char **argv,char **envp) {
 	void *b,*c;
 	FILE *fp = fopen("conftest1","w");
@@ -7073,7 +7066,6 @@ else
 	}
 
 	void gprof_cleanup() {};
-	int *cs_org;
 	int main(int argc,char **argv,char **envp) {
 	char *b;
 	FILE *fp = fopen("conftest1","w");
--- gcl-2.6.9.orig/configure.in
+++ gcl-2.6.9/configure.in
@@ -1377,7 +1377,6 @@ if test "$HAVE_SBRK" = "1" ; then
 	        #include <stdio.h>
 	        #include <stdlib.h>
 		void gprof_cleanup() {};
-		int *cs_org;
  		int main(int argc,char **argv,char **envp) {
 		#include "h/unrandomize.h"
 		return 0;}]])],
@@ -1389,7 +1388,6 @@ if test "$HAVE_SBRK" = "1" ; then
 	AC_TRY_RUN([#include <stdio.h>
 	            #include <stdlib.h>
 		    void gprof_cleanup() {};
-		    int *cs_org;
 		    int main(int argc,char * argv[],char * envp[]) {
 			FILE *f;
 			#ifdef CAN_UNRANDOMIZE_SBRK
@@ -1405,7 +1403,6 @@ if test "$HAVE_SBRK" = "1" ; then
 	AC_TRY_RUN([#include <stdio.h>
 	            #include <stdlib.h>
 		    void gprof_cleanup() {};
-		    int *cs_org;
 		    int main(int argc,char * argv[],char * envp[]) {
 			FILE *f;
 			#ifdef CAN_UNRANDOMIZE_SBRK
@@ -1490,7 +1487,6 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[
         }
 
 	void gprof_cleanup() {};
-	int *cs_org;
 	int main(int argc,char **argv,char **envp) {
 	void *v ;
 	FILE *fp = fopen("conftest1","w");
@@ -1525,7 +1521,6 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[
         }
 
 	void gprof_cleanup() {};
-	int *cs_org;
 	int main(int argc,char **argv,char **envp) {
 	void *v ;
 	FILE *fp = fopen("conftest1","w");
@@ -1555,7 +1550,6 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[
 	#include <stdio.h>
 	#include <stdlib.h>
 	void gprof_cleanup() {};
-	int *cs_org;
 	int main(int argc,char **argv,char **envp) {
 	#ifdef CAN_UNRANDOMIZE_SBRK
 	#include "h/unrandomize.h"
@@ -1573,7 +1567,6 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[
 	#include <stdio.h>
 	#include <stdlib.h>
 	void gprof_cleanup() {};
-	int *cs_org;
 	int main(int argc,char **argv,char **envp) {
 	void *b,*c;
 	FILE *fp = fopen("conftest1","w");
@@ -1603,7 +1596,6 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[
 	}
 
 	void gprof_cleanup() {};
-	int *cs_org;
 	int main(int argc,char **argv,char **envp) {
 	char *b;
 	FILE *fp = fopen("conftest1","w");
--- gcl-2.6.9.orig/h/unrandomize.h
+++ gcl-2.6.9/h/unrandomize.h
@@ -5,7 +5,6 @@
 #include <alloca.h>
 #include <errno.h>
 
-
 {
   errno=0;
 
@@ -20,20 +19,38 @@
     if ((pers & flag)!=flag && !getenv("GCL_UNRANDOMIZE")) {
       errno=0;
       if (personality(pers | flag) != -1 && (personality(0xffffffffUL) & flag)==flag) {
-	int i;
+	int i,j,k;
 	char **n,**a;
-	extern int *cs_org;
-	cs_org=(void *)&flag;/*get right stack for potential gc in malloc*/
-	for (i=0;envp[i];i++);
-	n=malloc((i+2)*sizeof(*n));
-	n[i+1]=0;
-	n[i--]="GCL_UNRANDOMIZE=t";
-	for (;i>=0;i--)
-	  n[i]=strdup(envp[i]);
+	void *v;
+	for (i=j=0;argv[i];i++)
+	  j+=strlen(argv[i])+1;
+	for (k=0;envp[k];k++)
+	  j+=strlen(envp[k])+1;
+	j+=(i+k+3)*sizeof(char *);
+	if ((v=sbrk(j))==(void *)-1) {
+	  printf("Cannot brk environment space\n");
+	  exit(-1);
+	}
+	a=v;
+	v=a+i+1;
+	n=v;
+	v=n+k+2;
+	for (i=0;argv[i];i++) {
+	  a[i]=v;
+	  strcpy(v,argv[i]);
+	  v+=strlen(v)+1;
+	}
+	a[i]=0;
+	for (k=0;envp[k];k++) {
+	  n[k]=v;
+	  strcpy(v,envp[k]);
+	  v+=strlen(v)+1;
+	}
+	n[k]="GCL_UNRANDOMIZE=t";
+	n[k+1]=0;
 #ifdef GCL_GPROF
 	gprof_cleanup();
 #endif
-	for (i=0;argv[i];i++);a=malloc((i+1)*sizeof(*argv));for (i=0;argv[i];i++) a[i]=strdup(argv[i]);a[i]=0;
 	errno=0;
 	execve(*a,a,n);
 	printf("execve failure %d\n",errno);
