Subject: Re: kern/22038: Fix to linux emulation to handle trailing slashes
To: None <netbsd-bugs@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: netbsd-bugs
Date: 07/03/2003 09:26:10
> >Synopsis:       Fix to linux emulation to handle trailing slashes

> +       if (SCARG(uap, path)[pathlen] == '/')   {
> +               strncpy(correctedpath, SCARG(uap, path), pathlen);
> +               correctedpath[pathlen] = '\0';
> +               SCARG(&bla, path) = correctedpath;
> +       } else {
> +               SCARG(&bla, path) = SCARG(uap, path);
> +       }
> +       SCARG(&bla, mode) = SCARG(uap, mode);

You can't do that - you need to use copyin (et al)....
(it is a shame that the userspace accesses don't fault..)

However I'd look at emul_find() in sys/compat/common/compat_util.c
which already has the infrastructure for modifying the filename.

You might need to add a CHECK_ALT_FL_MKDIR? then

	switch (sflag) {
+	case CHECK_ALT_FL_MKDIR:
+		while (len != 0 && ptr[len - 1] == '/')
+			ptr[--len] = 0;
+		/* FALLTHROUGH */
	case check_ALT_FL_CREATE:

	David

-- 
David Laight: david@l8s.co.uk