[PATCH] minor size optimization for dd.c

Rob Landley rob at landley.net
Sun Mar 19 19:09:32 PST 2006


On Sunday 19 March 2006 9:08 pm, Rob Landley wrote:

> > >See at http://195.66.192.167/linux/bbox/bb_xopen3.patch
> >
> > landley disliked this the bb_xopen3 idea, iirc.
> >
> > Rob, care to elaborate on why you don't want it, please?
>
> More I decided it wasn't something to worry about for 1.1.1 and I put it in
> my "to revisit" pile.

While dusting off Tito's rewrite of passwd.c in an attempt to get passwd using 
salt for 1.1.1, I see this:

    if ((out_fp = bb_wfopen(dest, "w"))
        && chmod(dest, ENABLE_FEATURE_SHADOWPASSWDS ? 0600 : 0644) == 0
        && chown(dest, 0, 0) == 0)
    {

And that's a big race condition if wfopen is creating the sucker with 777 and 
then chmoding it.

So, question about bb_xopen3(): it seems that any use of O_CREAT with 
bb_xopen() is an error.  Probably we should have debug code that #undefs 
O_CREAT in libbb.h and #defines O_CREAT to DO_NOT_USE_O_CREAT_WITH_BB_XOPEN, 
or some such...

Grepping the tree, we do this in a lot of places.  How many of those O_CREAT 
calls should have O_EXCL with them, but don't?

For 1.1.1 I'll live with it.  (Although not in passwd.c.)  We need to fix this 
everywhere for 1.1.2.

Rob
-- 
Never bet against the cheap plastic solution.


More information about the busybox mailing list