Date: Mon, 15 Jul 1996 13:33:08 +0200 (IST) From: Eli Zaretskii To: Oberhumer Markus Cc: djgpp-workers Subject: Re: gdb crashes if environment too big In-Reply-To: <199607141656.SAA27063@c210.edvz.uni-linz.ac.at> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sun, 14 Jul 1996, Oberhumer Markus wrote: > Yes, you are right. It works fine with stubbed executables. > The size of the environment is computed anyway, so the > bug in v2load.c should be easy to fix. Indeed. On second thought, it probably is just a typo: the source uses si.minkeep instead of si.env_size, but I also took the opportunity to fix another suspicious constant and bump up the transfer buffer size. Here: *** src/debug/common/v2load.c~0 Thu Jan 11 04:45:10 1996 --- src/debug/common/v2load.c Fri Jul 12 20:36:18 1996 *************** int v2loadimage(const char *program, con *** 60,66 **** unsigned client_cs, client_ds, my_ds; __dpmi_meminfo memblock; unsigned new_env_selector; ! char true_name[200]; _truename(program, true_name); --- 60,66 ---- unsigned client_cs, client_ds, my_ds; __dpmi_meminfo memblock; unsigned new_env_selector; ! char true_name[FILENAME_MAX]; _truename(program, true_name); *************** int v2loadimage(const char *program, con *** 88,94 **** strcpy(si.magic, "go32stub, V 2.00"); si.size = 0x44; si.minstack = 0x40000; ! si.minkeep = 4096; /* transfer buffer size */ memset(&si.basename, 0, 24); /* Asciiz strings */ } if (header[0] != 0x014c) { /* COFF? */ --- 88,94 ---- strcpy(si.magic, "go32stub, V 2.00"); si.size = 0x44; si.minstack = 0x40000; ! si.minkeep = 16384; /* transfer buffer size */ memset(&si.basename, 0, 24); /* Asciiz strings */ } if (header[0] != 0x014c) { /* COFF? */ *************** int v2loadimage(const char *program, con *** 134,140 **** si.env_size += 4 + strlen(true_name); /* Allocate the dos memory for the environment and command line. */ ! i = __dpmi_allocate_dos_memory((si.minkeep + 256) / 16, (int *)&new_env_selector); if(i == -1) return -1; --- 134,140 ---- si.env_size += 4 + strlen(true_name); /* Allocate the dos memory for the environment and command line. */ ! i = __dpmi_allocate_dos_memory((si.env_size + 256) / 16, (int *)&new_env_selector); if(i == -1) return -1; > BTW, did your recent patch for dosexec.c include a test for > a possible environment overflow ? Looks like we should add a > test for talloc(). Yes, I thought about this; I'll submit the necessary changes soon.