Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Feb 2015 01:51:21 +0000
From:      Anuranjan Shukla <anshukla@juniper.net>
To:        "freebsd-arch@freebsd.org" <freebsd-arch@freebsd.org>
Cc:        Simon Gerraty <sjg@juniper.net>
Subject:   Buggy sbspace() on 64bit builds?
Message-ID:  <D0F95E21.2489D%anshukla@juniper.net>

next in thread | raw e-mail | index | archive | help
Hi,
The way sbspace() is done today, it stores the result of subtraction of
socket buffer variables (u_int) in longs, and returns a long. If one of
the subtractions results in a -ve result (the other being positive), it's
seen as a large +ve and sbspace() ends up returning the wrong value.
    I'm not sure if this is enough of a corner case for consumers at large
to experience it, but at Juniper some of our implementation uses sbspace
directly and trips up on this for amd64 builds. Any thoughts on what a fix
should be for this?

Thanks
Anu

---------------------------
long
sbspace(struct sockbuf *sb)
{
        long bleft;
        long mleft;

        if (sb->sb_flags & SB_STOP)
                return(0);
        bleft =3D sb->sb_hiwat - sb->sb_cc;
        mleft =3D sb->sb_mbmax - sb->sb_mbcnt;
        return((bleft < mleft) ? bleft : mleft);

}




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?D0F95E21.2489D%anshukla>