Date: Sun, 27 Jan 2008 10:51:17 +0000 (GMT) From: Robert Watson <rwatson@FreeBSD.org> To: Yar Tikhiy <yar@FreeBSD.org> Cc: cvs-src@FreeBSD.org, John Birrell <jb@FreeBSD.org>, cvs-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: cvs commit: src/usr.sbin/setfmac setfmac.c Message-ID: <20080127104856.P30050@fledge.watson.org> In-Reply-To: <20080127063533.GA62684@freefall.freebsd.org> References: <200801270119.m0R1JlKn096256@repoman.freebsd.org> <20080127063533.GA62684@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 27 Jan 2008, Yar Tikhiy wrote: > The format strings in question might just have a bug in them. My guess is > that the author of the format strings feared that fts_path might not be > NUL-terminated, so he explicitly specified variable precision of > fts_pathlen; but he forgot to left-justify the field as well. > > In fact, fts_path in a fresh FTSENT just returned by fts_read() is always > NUL-terminated. (See fts(3).) Tricks with fts_pathlen are necessary only > if referring to old, saved FTSENTs, but this is dangerous and unportable > anyway. setfmac seems to refer to fresh FTSENTs only, so the format can be > changed safely from "%.*s" to just "%s". It will eliminate the fts_pathlen > arguments to the printf-like functions completely. > > It was Robert Watson who committed the lines to setfmac.c, according to cvs > annotate, so I added him to Cc:. > > Robert, do you think it's OK to simplify the format strings by changing > "%.*s" to "%s" along with removing the fts_pathlen arguments? E.g.: I think Brian Feldman may have originally submitted this part of the code code, and likely it was a concern about nul-termination. I'm fine with the change, especially if the concern about nul-termination was unfounded :-). Robert N M Watson Computer Laboratory University of Cambridge > > case FTS_NS: > - err(1, "traversing %.*s", ftsent->fts_pathlen, > - ftsent->fts_path); > + err(1, "traversing %s", ftsent->fts_path); > default: > > Thanks! > > Yar >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080127104856.P30050>