Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Sep 2004 19:57:32 +0200
From:      des@des.no (=?iso-8859-1?q?Dag-Erling_Sm=F8rgrav?=)
To:        Brooks Davis <brooks@one-eyed-alien.net>
Cc:        current@FreeBSD.org
Subject:   Re: 5.3-RELEASE TODO
Message-ID:  <xzpu0twn5gz.fsf@dwp.des.no>
In-Reply-To: <20040917162535.GA5750@odin.ac.hmc.edu> (Brooks Davis's message of "Fri, 17 Sep 2004 09:25:35 -0700")
References:  <200409170741.i8H7fGV3011078@pooker.samsco.org> <20040917162535.GA5750@odin.ac.hmc.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
Brooks Davis <brooks@one-eyed-alien.net> writes:
> I've got a patch for this one.  If someone will review it, I will commit
> it to HEAD for further testing.

you shouldn't call malloc() with M_NOWAIT unless you absolutely must,
and in this case you don't.

there's nothing to prevent the ifconf data from growing between the
first and second pass, since you're not holding the lock.  you'd end
up overflowing ifrbuf.

what I suggest you do is:

    struct sbuf *sb =3D sbuf_new(NULL, NULL, size, ifc->ifc_len + 1);
    acquire(lock);
    sbuf_bcat(sb, foo, foo_len);
    sbuf_bcat(sb, bar, bar_len);
    sbuf_bcat(sb, baz, baz_len);
    release(lock);
    sbuf_finish(sb);
    ifc->ifc_len =3D sbuf_len();
    copyout(sbuf_data(), ifc->ifc_req, ifc->ifc_len);
    sbuf_delete(sb);

DES
--=20
Dag-Erling Sm=F8rgrav - des@des.no



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