[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Locking of serial devices and devfs



On Thursday 21 June 2001 15:36, Itai Zukerman wrote:
> Je Thu, 21 Jun 2001 13:08:51 +0200,
>
> Russell Coker <russell@coker.com.au> scribis:
> > if (( p = strstr(dev, "dev/")) != NULL)
> >     dev = p + 4; /* point to first byte after "dev/" */
> > slprintf(lock_file, sizeof(lock_file), "%s/LCK..%s", LOCK_DIR, dev);
> > if(strchr(dev, '/'))
> > {
> >   char *dir = strdup(dev);
> >   *(strchr(dir, '/')) = '\0';
> >   mkdir(dir);
> >}
>
> (I think you mean lock_file instead of dev in the mkdir block.)

You are correct.

> I'm worried that this code lets the user put directories anywhere on
> the filesystem.  First run it with dev as "/dev/tts/0" (to create the
> lockfile directory), then run it with dev as "tts/../../../foo/bar"
> (to create a root directory, "foo").

Good point, there would have to be a check to abort on any instance of 
"..".

> Why not just remove the leading "/dev/" and convert "/"s to something
> harmless like ","?

Sounds reasonable.  I'm happy to do it that way or almost any other way 
in my code.  The hard part is getting something we can agree on so that 
pppd, minicom, etc can all use the same scheme.

-- 
http://www.coker.com.au/bonnie++/     Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/       Postal SMTP/POP benchmark
http://www.coker.com.au/projects.html Projects I am working on
http://www.coker.com.au/~russell/     My home page



Reply to: