From 4886ff454e3b6d42727fe266557eccd68d728c78 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 8 Aug 2013 16:48:04 +0200 Subject: [PATCH 1/1] Only take process id of localhost client connection entries. This patch makes sure, that the process id is fetched only from localhost client address connections fetched from the tcp table. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66060 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-win.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index aa0f97e..14fbf13 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -208,7 +208,8 @@ _dbus_get_peer_pid_from_tcp_handle (int handle) for (dwSize = 0; dwSize < lpBuffer->dwNumEntries; dwSize++) { int local_port = ntohs (lpBuffer->table[dwSize].dwLocalPort); - if (local_port == peer_port) + int local_address = ntohl (lpBuffer->table[dwSize].dwLocalAddr); + if (local_address == INADDR_LOOPBACK && local_port == peer_port) { result = lpBuffer->table[dwSize].dwOwningPid; break; @@ -244,8 +245,10 @@ _dbus_get_peer_pid_from_tcp_handle (int handle) for (i = 0; i < tcp_table->dwNumEntries; i++) { MIB_TCPROW_OWNER_PID *p = &tcp_table->table[i]; + int local_address = ntohl (p->dwLocalAddr); int local_port = ntohs (p->dwLocalPort); - if (p->dwState == MIB_TCP_STATE_ESTAB && local_port == peer_port) + if (p->dwState == MIB_TCP_STATE_ESTAB + && local_address == INADDR_LOOPBACK && local_port == peer_port) result = p->dwOwningPid; } -- 2.7.4