[nanomsg] Re: example of a bad assert

  • From: Garrett D'Amore <garrett@xxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Sun, 23 Mar 2014 22:56:12 -0700

On Mar 23, 2014, at 10:03 PM, Martin Sustrik <sustrik@xxxxxxxxxx> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> On 24/03/14 02:41, Garrett D'Amore wrote:
>> static void nn_xpub_in (NN_UNUSED struct nn_sockbase *self,
>> NN_UNUSED struct nn_pipe *pipe) { /*  We shouldn't get any messages
>> from subscribers. */ nn_assert (0); }
>> 
>> 
>> That’s just evil, because a bad peer could cause a DoS by simply 
>> sending a message over a sub socket that the publisher doesn’t
>> like.
>> 
>> It would be better to just silently drop.  Or possibly log it.
>> But asserting failure over events that can occur outside of the
>> program’s control (like bad network packets) is IMO terribly bad
>> practice.
>> 
>> (Yes, I’m implementing PUB/SUB even now, which is why I noticed
>> this (in code, I didn’t actually trigger it.)
> 
> Would you like to make a patch for this?

If you’d like me to.  I’ll just remove the call to nn_assert. :-)

        - Garrett

> 
> Martin
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
> 
> iQEcBAEBAgAGBQJTL7ymAAoJENTpVjxCNN9YV70H/378A9VLwL2HwoFnOi0VnVDF
> xRPb66yrj81NYz/v2llodIzgjoWDEQ4e3YMdCeSa1hwY4YCd4OvOHII2czHRHPkO
> 9tnle5hlDmuzhZP05n3s0rZnB/T6nKFIjOiuF6SD3Lc3jYMcKJBnV3WWaIvXpvl7
> gSAarPAg6neZiyrQoIJTk78IukkEnCwFYj6osLk1Vninimk1fsMfCvng5OBfn+tA
> RD+0pPl8QFBuk5edghPhmeUu+A9MtecFhglqzYdFvUZ2n3IJYW6dX+HdciyzFxUh
> ANkFNaiAyDk2j1nV4pScdAxTXHoCUiUDP3D30VaXn+GUWWW0vDEp+jL0+76PCQI=
> =BVCS
> -----END PGP SIGNATURE-----

Other related posts: