[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] upcoming 2.1.4-alpha Libevent release



Hi Nick,

You might be able to quicken this test a bit, if interested:

        if (sscanf(src, "%d.%d.%d.%d%c", &a,&b,&c,&d,&more) != 4)
            return 0;
        if (a < 0 || a > 255) return 0;
        if (b < 0 || b > 255) return 0;
        if (c < 0 || c > 255) return 0;
        if (d < 0 || d > 255) return 0;

int x = a | b | c | d;
if(x >> 8) return 0;

That's 4 OR's, 1 shift an 1 compare versus 8 compares.

To remove the undefined behavior, cast a,b,c,d to unsigned before the
shift. The unsigned will allow the high bit to be set without a sign
change. Then, cast back to signed before calling htonl.

Gotta love C rules and undefined behavior ;)

Jeff

On Mon, Mar 17, 2014 at 1:31 PM, Nick Mathewson <nickm@xxxxxxxxxxxxx> wrote:
> Hi, all!
>
> There's been a lot of activity on Libevent recently, so I'm hoping to
> put out a Libevent 2.1.4-alpha in the next day or two.  It will not
> have every bugfix that I've been told about, or every feature that I'm
> hoping to include in 2.1.x, but it's been long enough without an alpha
> that it's probably wise to put a
>
> If you want to try it out before the release, have a look at
>
> http://www.wangafu.net/~nickm/volatile/libevent-2.1.4-alpha-candidate.tar.gz
>
> Please let me know about any total showstopper bugs here.  (Like,
> major regressions against 2.1.3-alpha)
>
> THIS IS NOT THE ACTUAL RELEASE.  Do not upload this to package
> repositories, etc.
>
> I've attached a signed sha256sum.
>
> --
> Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.