Bug 77008 - getExtendedTcpTable() returns ERROR_INVALID_PARAMETER under windows
Summary: getExtendedTcpTable() returns ERROR_INVALID_PARAMETER under windows
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: 1.8
Hardware: All All
: medium major
Assignee: D-Bus Maintainers
QA Contact: D-Bus Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-03 14:52 UTC by dha
Modified: 2014-12-23 10:07 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Patch fix for this bug (812 bytes, patch)
2014-12-23 09:06 UTC, Ilya Tkachenko
Details | Splinter Review

Description dha 2014-04-03 14:52:42 UTC
file: dbus-sysdeps-win.c
dbus version: 1.8.0

The dbus-daemon.exe is started as follows:
dbus-daemon.exe --system --address=tcp:host=localhost,port=8888
It starts without problems
After connecting with my program to it, an error is thrown:
unexpected error returned from GetExtendedTcpTable: Unknown error code 87 or FormatMessage failed

This is because of line 149:
DWORD ... size ...
The size is not initialized, so GetExtendedTcpTable can work or not, dependent by chance. In my case it has not worked.

Set size=0 because size is an in and out parameter. GetExtendedTcpTable calculates the correct size if size=0.
This is testet on Windows XP SP3
Comment 1 Simon McVittie 2014-04-28 14:54:09 UTC
(In reply to comment #0)
> This is testet on Windows XP SP3

Windows XP is no longer security-supported by Microsoft. Our rule of thumb in dbus is that if an OS's vendor no longer supports an operating system, neither do we.

Having said that, this sounds like it might be an easy fix for someone who can test it on Windows (I can't). Ralf?
Comment 2 Ilya Tkachenko 2014-12-23 09:05:27 UTC
file: dbus-sysdeps-win.c
dbus version: 1.8.12

I have same issue on Windows Vista SP0. Our application crashes on first call 'GetExtendedTcpTable'. With size=0 it works fine.

Simple test for this problem:
  DWORD size = 0;
  std::cout << "Work normally.";
  GetExtendedTcpTable(NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0);
  std::cout << "Size = " << size << std::endl;

  std::cout << "Will crash soon.";
  size = 0xCCCCCCCC; // Undefined value.
  GetExtendedTcpTable(NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0);
Comment 3 Ilya Tkachenko 2014-12-23 09:06:27 UTC
Created attachment 111214 [details] [review]
Patch fix for this bug
Comment 4 Nikolay Bondarenko 2014-12-23 09:14:03 UTC
Simon, we have tested this patch win dbus 1.8.12 and 1.8.6 with WinXP SP3, Vista (SP0, SP1, SP2), Win7, Win8 (and 8.1). It does not any regression and fix crash on Vista SP0.
Comment 5 Ralf Habacker 2014-12-23 10:00:39 UTC
Comment on attachment 111214 [details] [review]
Patch fix for this bug

Review of attachment 111214 [details] [review]:
-----------------------------------------------------------------

::: dbus/dbus-sysdeps-win.c
@@ +146,4 @@
>  get_pid_from_extended_tcp_table(int peer_port)
>  {
>    dbus_pid_t result;
> +  DWORD errorCode, size = 0, i;

looks good.
Comment 6 Ralf Habacker 2014-12-23 10:07:14 UTC
Comment on attachment 111214 [details] [review]
Patch fix for this bug

applied to dbus-1.8 and master branch


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.