Subject: kern/1160: new compat_util.c:emul_find() function seems to be broken
To: None <gnats-admin@sun-lamp.pc.cs.cmu.edu>
From: Noriyuki Soda> <soda@sra.co.jp>
List: netbsd-bugs
Date: 06/26/1995 13:35:03
>Number:         1160
>Category:       kern
>Synopsis:       new compat_util.c:emul_find() function seems to be broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 26 13:35:02 1995
>Originator:     Noriyuki Soda
>Organization:
Software Research Associates, Inc., Japan
software tools and technology group
>Release:        1.0A
>Environment:
System: NetBSD james 1.0A NetBSD 1.0A (PALM) #2: Tue Jun 6 06:07:22 JST 1995 soda@james:/usr/src/sys/arch/i386/compile/PALM i386

>Description:
	old svr4_emul_find() function and linux_emul_find() function have
	a following code fragment.
		NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, 
		       (char *) svr4_emul_path, p);
		                ~~~~~~~~~~~~~~
		NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, 
		       (char *) linux_emul_path, p);
		                ~~~~~~~~~~~~~~~
	These code is replaced in sys/compat/common/compat_util.c:emul_find()
	as following.
		NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, 
		       (char *) prefix, p);
		                ^^^^^^
	But variable `prefix' doesn't point XXX_emul_path, because there is
	a following code in beginning of emul_find() function.
		for (ptr = buf; (*ptr = *prefix) != '\0'; ptr++, prefix++)
			continue;
	So `prefix' does not point "/emul/XXX", but "".

>How-To-Repeat:
>Fix:
	I think it is trivial.
>Audit-Trail:
>Unformatted: