qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] slirp: Don't crash on packets from 0.0.0.0/8.


From: Jan Kiszka
Subject: Re: [Qemu-devel] [PATCH] slirp: Don't crash on packets from 0.0.0.0/8.
Date: Mon, 12 Nov 2012 10:37:26 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

On 2012-11-12 01:59, Nickolai Zeldovich wrote:
> LWIP can generate packets with a source of 0.0.0.0, which triggers an
> assertion failure in arp_table_add().  Instead of crashing, simply return
> to avoid adding an invalid ARP table entry.

I would prefer to filter out such invalid packets at a different level.
Did you analyzed which path it takes through the stack?

> 
> Signed-off-by: Nickolai Zeldovich <address@hidden>
> ---
>  slirp/arp_table.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/slirp/arp_table.c b/slirp/arp_table.c
> index 5d7b8ac..3318ce9 100644
> --- a/slirp/arp_table.c
> +++ b/slirp/arp_table.c
> @@ -38,7 +38,8 @@ void arp_table_add(Slirp *slirp, uint32_t ip_addr, uint8_t 
> ethaddr[ETH_ALEN])
>                  ethaddr[3], ethaddr[4], ethaddr[5]));
>  
>      /* Check 0.0.0.0/8 invalid source-only addresses */
> -    assert((ip_addr & htonl(~(0xf << 28))) != 0);
> +    if ((ip_addr & htonl(~(0xf << 28))) == 0)
> +        return;

Please follow our coding style. There is also checkpatch.pl to help you.

>  
>      if (ip_addr == 0xffffffff || ip_addr == broadcast_addr) {
>          /* Do not register broadcast addresses */
> 

Jan

-- 
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux



reply via email to

[Prev in Thread] Current Thread [Next in Thread]