Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Quagga: Dev

ripd fails to bind when garbage in sin_zero

 

 

Quagga dev RSS feed   Index | Next | Previous | View Threaded


roamdad at sonic

Aug 18, 2012, 2:34 AM

Post #1 of 6 (464 views)
Permalink
ripd fails to bind when garbage in sin_zero

Mac OS X 10.7 is sensitive to non-zero data in sin_zero and will fail to
bind with
error 49 EADDRNOTAVAIL unless sin_zero is all zeros.

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.

in rip_create_socket:

diff -u quagga-0.99.21.orig/ripd/ripd.c quagga-0.99.21/ripd/ripd.c
--- quagga-0.99.21.orig/ripd/ripd.c 2012-04-17 06:56:26.000000000 -0700
+++ quagga-0.99.21/ripd/ripd.c 2012-08-18 00:21:07.000000000 -0700
@@ -1350,9 +1350,17 @@
addr.sin_addr.s_addr = INADDR_ANY;
#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
addr.sin_len = sizeof (struct sockaddr_in);
-#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */
+#endif
} else {
- memcpy(&addr, from, sizeof(addr));
+ /* fill individual fields so sin_zero remains zero from memset above
+ * garbage in sin_zero causes bind to fail
+ */
+#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
+ addr.sin_len = from->sin_len;
+#endif
+ addr.sin_family = from->sin_family;
+ addr.sin_port = from->sin_port;
+ addr.sin_addr = from->sin_addr;
}

/* sending port must always be the RIP port */


_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


nick at inex

Aug 18, 2012, 9:10 AM

Post #2 of 6 (416 views)
Permalink
Re: ripd fails to bind when garbage in sin_zero [In reply to]

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
Attachments: ripd-patch.diff (0.41 KB)


roamdad at sonic

Aug 18, 2012, 2:40 PM

Post #3 of 6 (418 views)
Permalink
Re: ripd fails to bind when garbage in sin_zero [In reply to]

On 8/18/12 9:10 AM, Nick Hilliard wrote:
> 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".
Great! I agree completely.
>
> 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.
Yes, it does the job. I backed out my patch and applied yours. Verified
with gdb all zeros and then recompiled with -O2.
No problem binding.

Can you get this in the distribution or do I need to go to bugzilla?
I just joined the list earlier today and don't know the ropes yet.


_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


nick at inex

Aug 18, 2012, 3:03 PM

Post #4 of 6 (418 views)
Permalink
Re: ripd fails to bind when garbage in sin_zero [In reply to]

On 18/08/2012 22:40, Doug VanLeuven wrote:
> Can you get this in the distribution or do I need to go to bugzilla?
> I just joined the list earlier today and don't know the ropes yet.

err, probably best to poke David Lamparter or Paul Jakma to get it
committed. Can you make up a one-line description and a 2 sentence
description of the bug for the commit message? Maybe a bugzilla entry
would help for auditing purposes

Nick

_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


equinox at opensourcerouting

Aug 20, 2012, 5:56 AM

Post #5 of 6 (409 views)
Permalink
Re: ripd fails to bind when garbage in sin_zero [In reply to]

On Sat, Aug 18, 2012 at 11:03:24PM +0100, Nick Hilliard wrote:
> On 18/08/2012 22:40, Doug VanLeuven wrote:
> > Can you get this in the distribution or do I need to go to bugzilla?
> > I just joined the list earlier today and don't know the ropes yet.
>
> err, probably best to poke David Lamparter or Paul Jakma to get it
> committed. Can you make up a one-line description and a 2 sentence
> description of the bug for the commit message? Maybe a bugzilla entry
> would help for auditing purposes

I've seen the thread and 'll pick it up as soon as I'm done debugging
the bgpd assert I'm hitting. Thanks for the patch!


-David
_______________________________________________
Quagga-dev mailing list
Quagga-dev [at] lists
http://lists.quagga.net/mailman/listinfo/quagga-dev


equinox at opensourcerouting

Sep 24, 2012, 9:18 PM

Post #6 of 6 (268 views)
Permalink
Re: ripd fails to bind when garbage in sin_zero [In reply to]

On Mon, Aug 20, 2012 at 02:56:39PM +0200, David Lamparter wrote:
> On Sat, Aug 18, 2012 at 11:03:24PM +0100, Nick Hilliard wrote:
> > On 18/08/2012 22:40, Doug VanLeuven wrote:
> > > Can you get this in the distribution or do I need to go to bugzilla?
> > > I just joined the list earlier today and don't know the ropes yet.
> >
> > err, probably best to poke David Lamparter or Paul Jakma to get it
> > committed. Can you make up a one-line description and a 2 sentence
> > description of the bug for the commit message? Maybe a bugzilla entry
> > would help for auditing purposes
>
> I've seen the thread and 'll pick it up as soon as I'm done debugging
> the bgpd assert I'm hitting. Thanks for the patch!

Applied.
Attachments: signature.asc (0.22 KB)

Quagga dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.