execve-leak.diff

corecode, 07/30/2007 02:15 PM

Download (2.04 KB)

View differences:

emulation/linux/i386/linux_machdep.c 30 Jul 2007 13:09:52 -0000
135 135

  
136 136
	exec_free_args(&exec_args);
137 137
	linux_free_path(&path);
138

  
139
	if (error < 0) {
140
		/* We hit a leathal error condition.  Let's die now. */
141
		exit1(W_EXITCODE(0, SIGABRT));
142
		/* NOTREACHED */
143
	}
144

  
138 145
	return(error);
139 146
}
140 147

  
kern/kern_exec.c 30 Jul 2007 13:22:14 -0000
160 160
 */
161 161
static const struct execsw **execsw;
162 162

  
163
/*
164
 * Replace current vmspace with a new binary.
165
 * Returns 0 on success, > 0 on recoverable error (use as errno).
166
 * Returns -1 on leathal error which demands killing of the current
167
 * process!
168
 */
163 169
int
164 170
kern_execve(struct nlookupdata *nd, struct image_args *args)
165 171
{
......
501 507
	if (imgp->vmspace_destroyed & 2)
502 508
		p->p_flag &= ~P_INEXEC;
503 509
	if (imgp->vmspace_destroyed) {
504
		/* sorry, no more process anymore. exit gracefully */
505
		exit1(W_EXITCODE(0, SIGABRT));
506
		/* NOT REACHED */
507
		return(0);
510
		/*
511
		 * Sorry, no more process anymore. exit gracefully.
512
		 * However we can't die right here, because our
513
		 * caller might have to clean up, so indicate a
514
		 * leathal error by returning -1.
515
		 */
516
		return(-1);
508 517
	} else {
509 518
		return(error);
510 519
	}
......
530 539
	nlookup_done(&nd);
531 540
	exec_free_args(&args);
532 541

  
542
	if (error < 0) {
543
		/* We hit a leathal error condition.  Let's die now. */
544
		exit1(W_EXITCODE(0, SIGABRT));
545
		/* NOTREACHED */
546
	}
547

  
533 548
	/*
534 549
	 * The syscall result is returned in registers to the new program.
535 550
	 * Linux will register %edx as an atexit function and we must be