Re: 5.3-RELEASE TODO

From: Dag-Erling Smørgrav <des_at_des.no>
Date: Fri, 17 Sep 2004 21:30:19 +0200
Brooks Davis <brooks_at_one-eyed-alien.net> writes:
> On Fri, Sep 17, 2004 at 07:57:32PM +0200, Dag-Erling Smørgrav wrote:
> >     struct sbuf *sb = sbuf_new(NULL, NULL, size, ifc->ifc_len + 1);
> What are you trying to do here?  Unless my manpages are wrong, the
> fourth arg is flags.  Do you mean to set SBUF_FIXEDLEN?

I meant

     struct sbuf *sb = sbuf_new(NULL, NULL, ifc->ifc_len + 1, SBUF_FIXEDLEN);

but I'm typing over a slow link and Meta-D'ed the wrong word.

>                                                          I think you
> would have to to avoid a new LOR.

Of course.

> would have to to avoid a new LOR.  Also, it is not safe to trust
> ifc->ifc_len for allocations because it is provided by potentially
> unpriveleged users.

so just make sure before you call sbuf_new() that ifc_len is
reasonable (e.g. < MAXPHYS)

>                      Thus, so you have to know how much space you will
> need before doing any kind of allocation, hence the double loop and the
> potential race.

Using sbufs removes the need for loop and greatly simplifies how you
deal with overflows.

DES
-- 
Dag-Erling Smørgrav - des_at_des.no
Received on Fri Sep 17 2004 - 17:30:21 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:12 UTC