des at des.no
Fri Sep 17 10:57:34 PDT 2004
Brooks Davis <brooks at 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 = sbuf_new(NULL, NULL, size, ifc->ifc_len + 1);
sbuf_bcat(sb, foo, foo_len);
sbuf_bcat(sb, bar, bar_len);
sbuf_bcat(sb, baz, baz_len);
ifc->ifc_len = sbuf_len();
copyout(sbuf_data(), ifc->ifc_req, ifc->ifc_len);
Dag-Erling Smørgrav - des at des.no
More information about the freebsd-current