[quagga-dev 9674] Re: ripd fails to bind when garbage in sin_zero

Nick Hilliard nick at inex.ie
Sat Aug 18 17:10:57 BST 2012


On 18/08/2012 10:34, Doug VanLeuven wrote:
> For me the simplest and most generic method to fix this was to copy the 
> individual fields into the structure after the structure was initialized
> with all zeros.

"from" is passed from another area of the code, so if it doesn't work for
rip_create_socket(), then it may potentially cause problems in other code
too.  It would probably be better to create the from struct carefully
rather than fixing it up later on.  "Be conservative in what you send".

Does the attached patch work for you?  This sanitizes the from struct
before it's passed into rip_create_socket(). nb: completely untested,
haven't even attempted compiling it.

Nick

-------------- next part --------------
--- ripd.c~	2012-04-17 14:56:26.000000000 +0100
+++ ripd.c	2012-08-18 16:59:41.000000000 +0100
@@ -1475,6 +1475,7 @@
       sin.sin_addr.s_addr = htonl (INADDR_RIP_GROUP);
       
       /* multicast send should bind to local interface address */
+      memset (&from, 0, sizeof (from));
       from.sin_family = AF_INET;
       from.sin_port = htons (RIP_PORT_DEFAULT);
       from.sin_addr = ifc->address->u.prefix4;


More information about the Quagga-dev mailing list