setmode patches

Liam J. Foy liamfoy at sepulcrum.org
Sun Jun 5 19:12:50 GMT 2005


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 at sepulcrum.org


More information about the freebsd-standards mailing list