[PATCH 5/6] dlls/nsiproxy.sys: add intermediate variable for sscanf on ULONG

Huw Davies huw at codeweavers.com
Mon Apr 25 02:31:45 CDT 2022


On Sat, Apr 23, 2022 at 09:33:05AM +0200, Eric Pouech wrote:
> Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
> 
> ---
>  dlls/nsiproxy.sys/tcp.c |    7 +++++--
>  dlls/nsiproxy.sys/udp.c |    4 +++-
>  2 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/dlls/nsiproxy.sys/tcp.c b/dlls/nsiproxy.sys/tcp.c
> index 8e2d7e749a79..0dbee8418b94 100644
> --- a/dlls/nsiproxy.sys/tcp.c
> +++ b/dlls/nsiproxy.sys/tcp.c
> @@ -534,6 +534,7 @@ static NTSTATUS tcp_conns_enumerate_all( UINT filter, struct nsi_tcp_conn_key *k
>          FILE *fp;
>          char buf[512], *ptr;
>          int inode;
> +        UINT laddr, raddr;
>  
>          if (!(fp = fopen( "/proc/net/tcp", "r" ))) return ERROR_NOT_SUPPORTED;
>  
> @@ -547,15 +548,17 @@ static NTSTATUS tcp_conns_enumerate_all( UINT filter, struct nsi_tcp_conn_key *k
>          while ((ptr = fgets( buf, sizeof(buf), fp )))
>          {
>              if (sscanf( ptr, "%*x: %x:%hx %x:%hx %x %*s %*s %*s %*s %*s %d",
> -                        &key.local.Ipv4.sin_addr.WS_s_addr, &key.local.Ipv4.sin_port,
> -                        &key.remote.Ipv4.sin_addr.WS_s_addr, &key.remote.Ipv4.sin_port,
> +                        &laddr, &key.local.Ipv4.sin_port,
> +                        &raddr, &key.remote.Ipv4.sin_port,
>                          &dyn.state, &inode ) != 6)
>                  continue;
>              dyn.state = tcp_state_to_mib_state( dyn.state );
>              if (filter && filter != dyn.state ) continue;
>  
>              key.local.Ipv4.sin_family = key.remote.Ipv4.sin_family = WS_AF_INET;
> +            key.local.Ipv4.sin_addr.WS_s_addr = laddr;
>              key.local.Ipv4.sin_port = htons( key.local.Ipv4.sin_port );
> +            key.remote.Ipv4.sin_addr.WS_s_addr = raddr;
>              key.remote.Ipv4.sin_port = htons( key.remote.Ipv4.sin_port );

Isn't this just hiding the fact that IN_ADDR contains a ULONG, so its size changes?
Likewise for SOCKADDR_IN6.

Huw.



More information about the wine-devel mailing list