Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Jun 2005 20:12:41 +0100
From:      "Liam J. Foy" <liamfoy@sepulcrum.org>
To:        freebsd-standards@freebsd.org
Subject:   setmode patches
Message-ID:  <20050605191241.GA14672@anarion>

next in thread | raw e-mail | index | archive | help
Hey guys,

	I want to show you all some patches:

http://metawire.org/~liamfoy/setmode.c.diff.f
http://metawire.org/~liamfoy/setmode.3.diff.f

This will allow errno to be set in all cases to ERANGE. We can then check this
in applications which use setmode(3). Most usage of setmode(3) assumes that that
setmode will fail due to an invalid file mode. Example:

This snip is from chmod.c:

[snip]
        if (hflag)
                change_mode = lchmod;
        else
                change_mode = chmod;

        mode = *argv;
        if ((set = setmode(mode)) == NULL)
                errx(1, "invalid file mode: %s", mode);

        if ((ftsp = fts_open(++argv, fts_options, 0)) == NULL)
                err(1, "fts_open");
        for (rval = 0; (p = fts_read(ftsp)) != NULL;) {
[snip]

However, setmode(3) can fail due to malloc. With the following patch, we can
show whether it was actually a bad file mode or something else (malloc):

http://metawire.org/~liamfoy/chmod.c.diff.f

Anyone have any comments/suggestions? There are also many other instances where
setmode is assumed to fail due to a invalid file mode only (I can also create
these patches).

Cheers,
-- 
		- Liam J. Foy
		liamfoy@sepulcrum.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050605191241.GA14672>