This is sources Bugzilla
Bugzilla Version 2.17.5
Bugzilla Bug 1125
  crash in execvp() Last modified: 2005-10-17 09:07:35
     Query page      Enter new bug
Bug#: 1125   Hardware:   Reporter: Serge Belyshev <belyshev@depni.sinp.msu.ru>
Host: Target: Build:
Product:     Add CC:
Component:   Version:   CC:
Remove selected CCs
Status: RESOLVED   Priority:  
Resolution: FIXED   Severity:  
Assigned To: GOTO Masanori <gotom@debian.or.jp>   Target Milestone:  
Flags: Requestee:
  backport ()
  examined ()
  testsuite ()
Summary:
Keywords:

Attachment Description Type Created Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 1125 depends on: Show dependency tree
Show dependency graph
Bug 1125 blocks: 852

Additional Comments:


Leave as RESOLVED FIXED
Reopen bug
Mark bug as VERIFIED

View Bug Activity   |   Format For Printing


Description:   Last confirmed: 0000-00-00 00:00 Opened: 2005-07-24 18:44
This small program crashes glibc in execvp():

---------------------------------------------------
#include <unistd.h>

extern char **environ;
static char *empty[] = { 0 };

int main (void)
{
  environ = empty;
  execvp ("nothing ", empty);
  return 0;
}
---------------------------------------------------

$ ./a.out 
*** glibc detected *** free(): invalid pointer: 0x0000000000501016 ***
Aborted (core dumped)
$ 

similar effect can be achieved by executing "env -i nonexistent_program".

the problem seems to be here, posix/execvp.c:121:

      char *p = path;
      do
	{
	  char *startp;

	  path = p;                      // it changes 'path' inside loop
	  p = __strchrnul (path, ':');

          ...

	}
      while (*p++ != '\0');
      ...

      if (path_malloc)
	free (path);                     // and then frees it.

------- Additional Comment #1 From GOTO Masanori 2005-07-29 03:55 -------
Fixed in the latest cvs.

------- Additional Comment #2 From cvs-commit@gcc.gnu.org 2005-10-17 09:05 -------
Subject: Bug 1125

CVSROOT:	/cvs/glibc
Module name:	libc
Branch: 	glibc-2_3-branch
Changes by:	roland@sources.redhat.com	2005-10-17 09:05:18

Modified files:
	posix          : execvp.c 

Log message:
	2005-07-24  Jakub Jelinek  <jakub@redhat.com>
	
	[BZ #1125]
	* posix/execvp.c (execvp): Change path_malloc to
	char *, free that pointer on failure.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/posix/execvp.c.diff?cvsroot=glibc&only_with_tag=glibc-2_3-branch&r1=1.21.2.3&r2=1.21.2.4


------- Additional Comment #3 From cvs-commit@gcc.gnu.org 2005-10-17 09:05 -------
Subject: Bug 1125

CVSROOT:	/cvs/glibc
Module name:	libc
Branch: 	glibc-2_3-branch
Changes by:	roland@sources.redhat.com	2005-10-17 09:05:20

Modified files:
	posix          : Makefile 
Added files:
	posix          : tst-execvp4.c 

Log message:
	2005-07-24  Ulrich Drepper  <drepper@redhat.com>
	
	[BZ #1125]
	* posix/Makefile (tests): Add tst-execvp4.
	* posix/tst-execvp4.c: New file.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/posix/tst-execvp4.c.diff?cvsroot=glibc&only_with_tag=glibc-2_3-branch&r1=NONE&r2=1.1.4.1
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/posix/Makefile.diff?cvsroot=glibc&only_with_tag=glibc-2_3-branch&r1=1.179.2.3&r2=1.179.2.4


     Query page      Enter new bug
Actions: New | Query | bug # | Reports | Requests   New Account | Log In