netdev
[Top] [All Lists]

Re: (fwd) Re: sin_zero question

To: Arkadiusz Miskiewicz <misiek@xxxxxxxxxx>
Subject: Re: (fwd) Re: sin_zero question
From: Andi Kleen <ak@xxxxxx>
Date: Wed, 31 May 2000 18:27:08 +0200
Cc: netdev@xxxxxxxxxxx, alan@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20000531164458.A1467@xxxxxxxxxxxxxxxxxxxxxxx>; from Arkadiusz Miskiewicz on Wed, May 31, 2000 at 04:47:55PM +0200
References: <20000531164458.A1467@xxxxxxxxxxxxxxxxxxxxxxx>
Sender: owner-netdev@xxxxxxxxxxx
On Wed, May 31, 2000 at 04:47:55PM +0200, Arkadiusz Miskiewicz wrote:
> 
> ok, so I'm asking:
> 
> struct sockaddr_storage ss;
> memset(&ss, 0, sizeof(ss));
> 
> (gdb) print *(struct sockaddr_in *)&ss
> $4 = {sin_family = 0, sin_port = 0, sin_addr = {s_addr = 0},
>   sin_zero = "\000\000\000\000\000\000\000"}
> 
> getpeername(s, (struct sockaddr *)&ss, &length);
> 
> (gdb) print *(struct sockaddr_in *)&ss
> $4 = {sin_family = 2, sin_port = 5888, sin_addr = {s_addr = 16820416},
>   sin_zero = "?\221\020??C?Á"}
> 
> and kernel put's garbage into rest of ss (sin_zero) instead
> leaving it alone.
>  
> This is bad thing because we can't memcmp() two structs
> to check if adresses, families and ports are equal.
> 
> Can someone fix this ?

Here is a patch for 2.2.14/15: 

Alan, looks like a 2.2.16 candidate. 


-Andi

--- linux/net/socket.c.SA       Thu May  4 02:16:54 2000
+++ linux/net/socket.c  Wed May 31 18:23:31 2000
@@ -893,6 +893,7 @@
        int len, err;
        
        lock_kernel();
+       memset(address, 0, MAX_SOCK_ADDR); 
        sock = sockfd_lookup(fd, &err);
        if (!sock)
                goto out;
@@ -920,6 +921,7 @@
        int len, err;
 
        lock_kernel();
+       memset(address, 0, MAX_SOCK_ADDR); 
        if ((sock = sockfd_lookup(fd, &err))!=NULL)
        {
                err = sock->ops->getname(sock, (struct sockaddr *)address, 
&len, 1);



-- 
This is like TV. I don't like TV.

<Prev in Thread] Current Thread [Next in Thread>