Wine-devel
Threads by month
- ----- 2026 -----
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
February 2020
- 80 participants
- 745 discussions
Hi All,
During the last WineConf it was decided that we needed a more formal
process for choosing the next WineConf host. It was also decided that we
need to help current and future hosts by by putting together a support
WineConf committee along with a checklist to help guide the host.
To that end, we have started a Organising WineConf [1] wiki page. It's
by no means complete so I encourage all past hosts to review and edit
the page to make it more helpful to potential hosts. Thanks to Henri for
providing most of the current content.
This is also a call for proposals to host the next WineConf sometime
this year. Ideally proposals would present;
Proposed dates
Proposed city
Information on potential venues and travel
We'll need to choose a host relatively quickly as it does take time to
plan and book the event. I'm hoping we can settle on a host by the end
of February but ultimately that decision goes to the Wine Committee.
Questions, comments, concerns can be posted on the mailing list.
Thanks,
-Ulrich
1. http://wiki.winehq.org/Organising_WineConf
1
0
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com>
---
v2: Minor whitespace fix
---
dlls/iphlpapi/ipstats.c | 151 +++++++++-------------------------------
1 file changed, 32 insertions(+), 119 deletions(-)
diff --git a/dlls/iphlpapi/ipstats.c b/dlls/iphlpapi/ipstats.c
index dd6a57015f..83259f4743 100644
--- a/dlls/iphlpapi/ipstats.c
+++ b/dlls/iphlpapi/ipstats.c
@@ -1326,24 +1326,24 @@ DWORD WINAPI GetUdpStatistics(PMIB_UDPSTATS stats)
return GetUdpStatisticsEx(stats, WS_AF_INET);
}
-static MIB_IPFORWARDTABLE *append_ipforward_row( HANDLE heap, DWORD flags, MIB_IPFORWARDTABLE *table,
- DWORD *count, const MIB_IPFORWARDROW *row )
+static void *append_table_row( HANDLE heap, DWORD flags, void *table, DWORD *table_size, DWORD *table_capacity,
+ const void *row, DWORD row_size )
{
- if (table->dwNumEntries >= *count)
+ DWORD *num_entries = table; /* this must be the first field */
+ if (*num_entries == *table_capacity)
{
- MIB_IPFORWARDTABLE *new_table;
- DWORD new_count = table->dwNumEntries * 2;
-
- if (!(new_table = HeapReAlloc( heap, flags, table,
- FIELD_OFFSET(MIB_IPFORWARDTABLE, table[new_count] ))))
+ void *new_table;
+ *table_size += *table_capacity * row_size;
+ if (!(new_table = HeapReAlloc( heap, flags, table, *table_size )))
{
HeapFree( heap, 0, table );
return NULL;
}
- *count = new_count;
- table = new_table;
+ num_entries = table = new_table;
+ *table_capacity *= 2;
}
- memcpy( &table->table[table->dwNumEntries++], row, sizeof(*row) );
+ memcpy( (char *)table + *table_size - (*table_capacity - *num_entries) * row_size, row, row_size );
+ (*num_entries)++;
return table;
}
@@ -1381,13 +1381,13 @@ DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *ppIpForw
{
MIB_IPFORWARDTABLE *table;
MIB_IPFORWARDROW row;
- DWORD ret = NO_ERROR, count = 16;
+ DWORD ret = NO_ERROR, count = 16, table_size = FIELD_OFFSET( MIB_IPFORWARDTABLE, table[count] );
TRACE("table %p, bOrder %d, heap %p, flags 0x%08x\n", ppIpForwardTable, bOrder, heap, flags);
if (!ppIpForwardTable) return ERROR_INVALID_PARAMETER;
- if (!(table = HeapAlloc( heap, flags, FIELD_OFFSET(MIB_IPFORWARDTABLE, table[count] ))))
+ if (!(table = HeapAlloc( heap, flags, table_size )))
return ERROR_OUTOFMEMORY;
table->dwNumEntries = 0;
@@ -1428,7 +1428,7 @@ DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *ppIpForw
* route is typically set with MIB_IPPROTO_NETMGMT instead */
row.u2.ForwardProto = MIB_IPPROTO_LOCAL;
- if (!(table = append_ipforward_row( heap, flags, table, &count, &row )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, sizeof(row) )))
break;
}
fclose(fp);
@@ -1465,7 +1465,8 @@ DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *ppIpForw
memcpy( name, entry->ipRouteIfIndex.o_bytes, namelen );
name[namelen] = 0;
getInterfaceIndexByName( name, &row.dwForwardIfIndex );
- if (!(table = append_ipforward_row( heap, flags, table, &count, &row ))) break;
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, sizeof(row) )))
+ break;
}
HeapFree( GetProcessHeap(), 0, data );
}
@@ -1573,7 +1574,7 @@ DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *ppIpForw
}
}
- if (!(table = append_ipforward_row( heap, flags, table, &count, &row )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, sizeof(row) )))
break;
}
done:
@@ -1596,27 +1597,6 @@ done:
return ret;
}
-static MIB_IPNETTABLE *append_ipnet_row( HANDLE heap, DWORD flags, MIB_IPNETTABLE *table,
- DWORD *count, const MIB_IPNETROW *row )
-{
- if (table->dwNumEntries >= *count)
- {
- MIB_IPNETTABLE *new_table;
- DWORD new_count = table->dwNumEntries * 2;
-
- if (!(new_table = HeapReAlloc( heap, flags, table,
- FIELD_OFFSET(MIB_IPNETTABLE, table[new_count] ))))
- {
- HeapFree( heap, 0, table );
- return NULL;
- }
- *count = new_count;
- table = new_table;
- }
- memcpy( &table->table[table->dwNumEntries++], row, sizeof(*row) );
- return table;
-}
-
static int compare_ipnet_rows(const void *a, const void *b)
{
const MIB_IPNETROW *rowA = a;
@@ -1648,13 +1628,13 @@ DWORD WINAPI AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE *ppIpNetTable, BO
{
MIB_IPNETTABLE *table;
MIB_IPNETROW row;
- DWORD ret = NO_ERROR, count = 16;
+ DWORD ret = NO_ERROR, count = 16, table_size = FIELD_OFFSET( MIB_IPNETTABLE, table[count] );
TRACE("table %p, bOrder %d, heap %p, flags 0x%08x\n", ppIpNetTable, bOrder, heap, flags);
if (!ppIpNetTable) return ERROR_INVALID_PARAMETER;
- if (!(table = HeapAlloc( heap, flags, FIELD_OFFSET(MIB_IPNETTABLE, table[count] ))))
+ if (!(table = HeapAlloc( heap, flags, table_size )))
return ERROR_OUTOFMEMORY;
table->dwNumEntries = 0;
@@ -1700,7 +1680,7 @@ DWORD WINAPI AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE *ppIpNetTable, BO
while (*ptr && isspace(*ptr)) ptr++;
getInterfaceIndexByName(ptr, &row.dwIndex);
- if (!(table = append_ipnet_row( heap, flags, table, &count, &row )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, sizeof(row) )))
break;
}
fclose(fp);
@@ -1728,7 +1708,8 @@ DWORD WINAPI AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE *ppIpNetTable, BO
memcpy( name, entry->ipNetToMediaIfIndex.o_bytes, namelen );
name[namelen] = 0;
getInterfaceIndexByName( name, &row.dwIndex );
- if (!(table = append_ipnet_row( heap, flags, table, &count, &row ))) break;
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, sizeof(row) )))
+ break;
}
HeapFree( GetProcessHeap(), 0, data );
}
@@ -1784,7 +1765,7 @@ DWORD WINAPI AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE *ppIpNetTable, BO
else if(rtm->rtm_rmx.rmx_expire != 0) row.u.Type = MIB_IPNET_TYPE_DYNAMIC;
else row.u.Type = MIB_IPNET_TYPE_INVALID;
- if (!(table = append_ipnet_row( heap, flags, table, &count, &row )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, sizeof(row) )))
break;
}
next += rtm->rtm_msglen;
@@ -1846,30 +1827,6 @@ static DWORD get_tcp_table_sizes( TCP_TABLE_CLASS class, DWORD row_count, DWORD
return table_size;
}
-static MIB_TCPTABLE *append_tcp_row( TCP_TABLE_CLASS class, HANDLE heap, DWORD flags,
- MIB_TCPTABLE *table, DWORD *count,
- const MIB_TCPROW_OWNER_MODULE *row, DWORD row_size )
-{
- if (table->dwNumEntries >= *count)
- {
- MIB_TCPTABLE *new_table;
- DWORD new_count = table->dwNumEntries * 2, new_table_size;
-
- new_table_size = get_tcp_table_sizes( class, new_count, NULL );
- if (!(new_table = HeapReAlloc( heap, flags, table, new_table_size )))
- {
- HeapFree( heap, 0, table );
- return NULL;
- }
- *count = new_count;
- table = new_table;
- }
- memcpy( (char *)table->table + (table->dwNumEntries * row_size), row, row_size );
- table->dwNumEntries++;
- return table;
-}
-
-
/* Why not a lookup table? Because the TCPS_* constants are different
on different platforms */
static inline MIB_TCP_STATE TCPStateToMIBState (int state)
@@ -2156,7 +2113,7 @@ DWORD build_tcp_table( TCP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
row.liCreateTimestamp.QuadPart = 0; /* FIXME */
memset( &row.OwningModuleInfo, 0, sizeof(row.OwningModuleInfo) );
}
- if (!(table = append_tcp_row( class, heap, flags, table, &count, &row, row_size )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, row_size )))
break;
}
HeapFree( GetProcessHeap(), 0, map );
@@ -2182,7 +2139,7 @@ DWORD build_tcp_table( TCP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
row.dwRemotePort = htons( entry->tcpConnRemPort );
row.dwState = entry->tcpConnState;
if (!match_class( class, row.dwState )) continue;
- if (!(table = append_tcp_row( class, heap, flags, table, &count, &row, row_size )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, row_size )))
break;
}
HeapFree( GetProcessHeap(), 0, data );
@@ -2276,7 +2233,7 @@ DWORD build_tcp_table( TCP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
row.liCreateTimestamp.QuadPart = 0; /* FIXME */
memset( &row.OwningModuleInfo, 0, sizeof(row.OwningModuleInfo) );
}
- if (!(table = append_tcp_row( class, heap, flags, table, &count, &row, row_size )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, row_size )))
break;
}
@@ -2395,29 +2352,6 @@ static DWORD get_udp_table_sizes( UDP_TABLE_CLASS class, DWORD row_count, DWORD
return table_size;
}
-static MIB_UDPTABLE *append_udp_row( UDP_TABLE_CLASS class, HANDLE heap, DWORD flags,
- MIB_UDPTABLE *table, DWORD *count,
- const MIB_UDPROW_OWNER_MODULE *row, DWORD row_size )
-{
- if (table->dwNumEntries >= *count)
- {
- MIB_UDPTABLE *new_table;
- DWORD new_count = table->dwNumEntries * 2, new_table_size;
-
- new_table_size = get_udp_table_sizes( class, new_count, NULL );
- if (!(new_table = HeapReAlloc( heap, flags, table, new_table_size )))
- {
- HeapFree( heap, 0, table );
- return NULL;
- }
- *count = new_count;
- table = new_table;
- }
- memcpy( (char *)table->table + (table->dwNumEntries * row_size), row, row_size );
- table->dwNumEntries++;
- return table;
-}
-
static int compare_udp_rows(const void *a, const void *b)
{
const MIB_UDPROW *rowA = a;
@@ -2474,7 +2408,7 @@ DWORD build_udp_table( UDP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
row.u.dwFlags = 0;
memset( &row.OwningModuleInfo, 0, sizeof(row.OwningModuleInfo) );
}
- if (!(table = append_udp_row( class, heap, flags, table, &count, &row, row_size )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, row_size )))
break;
}
HeapFree( GetProcessHeap(), 0, map );
@@ -2496,7 +2430,8 @@ DWORD build_udp_table( UDP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
{
row.dwLocalAddr = entry->udpLocalAddress;
row.dwLocalPort = htons( entry->udpLocalPort );
- if (!(table = append_udp_row( class, heap, flags, table, &count, &row, row_size ))) break;
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, row_size )))
+ break;
}
HeapFree( GetProcessHeap(), 0, data );
}
@@ -2584,7 +2519,8 @@ DWORD build_udp_table( UDP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
row.u.SpecificPortBind = !(pINData->inp_flags & INP_ANONPORT);
memset( &row.OwningModuleInfo, 0, sizeof(row.OwningModuleInfo) );
}
- if (!(table = append_udp_row( class, heap, flags, table, &count, &row, row_size ))) break;
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, row_size )))
+ break;
}
done:
@@ -2640,29 +2576,6 @@ static DWORD get_udp6_table_sizes( UDP_TABLE_CLASS class, DWORD row_count, DWORD
return table_size;
}
-static MIB_UDP6TABLE *append_udp6_row( UDP_TABLE_CLASS class, HANDLE heap, DWORD flags,
- MIB_UDP6TABLE *table, DWORD *count,
- const MIB_UDP6ROW_OWNER_MODULE *row, DWORD row_size )
-{
- if (table->dwNumEntries >= *count)
- {
- MIB_UDP6TABLE *new_table;
- DWORD new_count = table->dwNumEntries * 2, new_table_size;
-
- new_table_size = get_udp6_table_sizes( class, new_count, NULL );
- if (!(new_table = HeapReAlloc( heap, flags, table, new_table_size )))
- {
- HeapFree( heap, 0, table );
- return NULL;
- }
- *count = new_count;
- table = new_table;
- }
- memcpy( (char *)table->table + (table->dwNumEntries * row_size), row, row_size );
- table->dwNumEntries++;
- return table;
-}
-
static int compare_udp6_rows(const void *a, const void *b)
{
const MIB_UDP6ROW *rowA = a;
@@ -2824,7 +2737,7 @@ DWORD build_udp6_table( UDP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
row.u.dwFlags = 0;
memset( &row.OwningModuleInfo, 0, sizeof(row.OwningModuleInfo) );
}
- if (!(table = append_udp6_row( class, heap, flags, table, &count, &row, row_size )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, row_size )))
break;
}
HeapFree( GetProcessHeap(), 0, map );
--
2.25.0
1
0
Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com>
---
dlls/iphlpapi/ipstats.c | 151 +++++++++-------------------------------
1 file changed, 32 insertions(+), 119 deletions(-)
diff --git a/dlls/iphlpapi/ipstats.c b/dlls/iphlpapi/ipstats.c
index dd6a57015f..88e338493c 100644
--- a/dlls/iphlpapi/ipstats.c
+++ b/dlls/iphlpapi/ipstats.c
@@ -1326,24 +1326,24 @@ DWORD WINAPI GetUdpStatistics(PMIB_UDPSTATS stats)
return GetUdpStatisticsEx(stats, WS_AF_INET);
}
-static MIB_IPFORWARDTABLE *append_ipforward_row( HANDLE heap, DWORD flags, MIB_IPFORWARDTABLE *table,
- DWORD *count, const MIB_IPFORWARDROW *row )
+static void *append_table_row( HANDLE heap, DWORD flags, void *table, DWORD *table_size, DWORD *table_capacity,
+ const void *row, DWORD row_size )
{
- if (table->dwNumEntries >= *count)
+ DWORD *num_entries = table; /* this must be the first field */
+ if (*num_entries == *table_capacity)
{
- MIB_IPFORWARDTABLE *new_table;
- DWORD new_count = table->dwNumEntries * 2;
-
- if (!(new_table = HeapReAlloc( heap, flags, table,
- FIELD_OFFSET(MIB_IPFORWARDTABLE, table[new_count] ))))
+ void *new_table;
+ *table_size += *table_capacity * row_size;
+ if (!(new_table = HeapReAlloc( heap, flags, table, *table_size )))
{
HeapFree( heap, 0, table );
return NULL;
}
- *count = new_count;
- table = new_table;
+ num_entries = table = new_table;
+ *table_capacity *= 2;
}
- memcpy( &table->table[table->dwNumEntries++], row, sizeof(*row) );
+ memcpy( (char *)table + *table_size - (*table_capacity - *num_entries) * row_size, row, row_size );
+ (*num_entries)++;
return table;
}
@@ -1381,13 +1381,13 @@ DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *ppIpForw
{
MIB_IPFORWARDTABLE *table;
MIB_IPFORWARDROW row;
- DWORD ret = NO_ERROR, count = 16;
+ DWORD ret = NO_ERROR, count = 16, table_size = FIELD_OFFSET( MIB_IPFORWARDTABLE, table[count] );
TRACE("table %p, bOrder %d, heap %p, flags 0x%08x\n", ppIpForwardTable, bOrder, heap, flags);
if (!ppIpForwardTable) return ERROR_INVALID_PARAMETER;
- if (!(table = HeapAlloc( heap, flags, FIELD_OFFSET(MIB_IPFORWARDTABLE, table[count] ))))
+ if (!(table = HeapAlloc( heap, flags, table_size)))
return ERROR_OUTOFMEMORY;
table->dwNumEntries = 0;
@@ -1428,7 +1428,7 @@ DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *ppIpForw
* route is typically set with MIB_IPPROTO_NETMGMT instead */
row.u2.ForwardProto = MIB_IPPROTO_LOCAL;
- if (!(table = append_ipforward_row( heap, flags, table, &count, &row )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, sizeof(row) )))
break;
}
fclose(fp);
@@ -1465,7 +1465,8 @@ DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *ppIpForw
memcpy( name, entry->ipRouteIfIndex.o_bytes, namelen );
name[namelen] = 0;
getInterfaceIndexByName( name, &row.dwForwardIfIndex );
- if (!(table = append_ipforward_row( heap, flags, table, &count, &row ))) break;
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, sizeof(row) )))
+ break;
}
HeapFree( GetProcessHeap(), 0, data );
}
@@ -1573,7 +1574,7 @@ DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *ppIpForw
}
}
- if (!(table = append_ipforward_row( heap, flags, table, &count, &row )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, sizeof(row) )))
break;
}
done:
@@ -1596,27 +1597,6 @@ done:
return ret;
}
-static MIB_IPNETTABLE *append_ipnet_row( HANDLE heap, DWORD flags, MIB_IPNETTABLE *table,
- DWORD *count, const MIB_IPNETROW *row )
-{
- if (table->dwNumEntries >= *count)
- {
- MIB_IPNETTABLE *new_table;
- DWORD new_count = table->dwNumEntries * 2;
-
- if (!(new_table = HeapReAlloc( heap, flags, table,
- FIELD_OFFSET(MIB_IPNETTABLE, table[new_count] ))))
- {
- HeapFree( heap, 0, table );
- return NULL;
- }
- *count = new_count;
- table = new_table;
- }
- memcpy( &table->table[table->dwNumEntries++], row, sizeof(*row) );
- return table;
-}
-
static int compare_ipnet_rows(const void *a, const void *b)
{
const MIB_IPNETROW *rowA = a;
@@ -1648,13 +1628,13 @@ DWORD WINAPI AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE *ppIpNetTable, BO
{
MIB_IPNETTABLE *table;
MIB_IPNETROW row;
- DWORD ret = NO_ERROR, count = 16;
+ DWORD ret = NO_ERROR, count = 16, table_size = FIELD_OFFSET( MIB_IPNETTABLE, table[count] );
TRACE("table %p, bOrder %d, heap %p, flags 0x%08x\n", ppIpNetTable, bOrder, heap, flags);
if (!ppIpNetTable) return ERROR_INVALID_PARAMETER;
- if (!(table = HeapAlloc( heap, flags, FIELD_OFFSET(MIB_IPNETTABLE, table[count] ))))
+ if (!(table = HeapAlloc( heap, flags, table_size )))
return ERROR_OUTOFMEMORY;
table->dwNumEntries = 0;
@@ -1700,7 +1680,7 @@ DWORD WINAPI AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE *ppIpNetTable, BO
while (*ptr && isspace(*ptr)) ptr++;
getInterfaceIndexByName(ptr, &row.dwIndex);
- if (!(table = append_ipnet_row( heap, flags, table, &count, &row )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, sizeof(row) )))
break;
}
fclose(fp);
@@ -1728,7 +1708,8 @@ DWORD WINAPI AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE *ppIpNetTable, BO
memcpy( name, entry->ipNetToMediaIfIndex.o_bytes, namelen );
name[namelen] = 0;
getInterfaceIndexByName( name, &row.dwIndex );
- if (!(table = append_ipnet_row( heap, flags, table, &count, &row ))) break;
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, sizeof(row) )))
+ break;
}
HeapFree( GetProcessHeap(), 0, data );
}
@@ -1784,7 +1765,7 @@ DWORD WINAPI AllocateAndGetIpNetTableFromStack(PMIB_IPNETTABLE *ppIpNetTable, BO
else if(rtm->rtm_rmx.rmx_expire != 0) row.u.Type = MIB_IPNET_TYPE_DYNAMIC;
else row.u.Type = MIB_IPNET_TYPE_INVALID;
- if (!(table = append_ipnet_row( heap, flags, table, &count, &row )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, sizeof(row) )))
break;
}
next += rtm->rtm_msglen;
@@ -1846,30 +1827,6 @@ static DWORD get_tcp_table_sizes( TCP_TABLE_CLASS class, DWORD row_count, DWORD
return table_size;
}
-static MIB_TCPTABLE *append_tcp_row( TCP_TABLE_CLASS class, HANDLE heap, DWORD flags,
- MIB_TCPTABLE *table, DWORD *count,
- const MIB_TCPROW_OWNER_MODULE *row, DWORD row_size )
-{
- if (table->dwNumEntries >= *count)
- {
- MIB_TCPTABLE *new_table;
- DWORD new_count = table->dwNumEntries * 2, new_table_size;
-
- new_table_size = get_tcp_table_sizes( class, new_count, NULL );
- if (!(new_table = HeapReAlloc( heap, flags, table, new_table_size )))
- {
- HeapFree( heap, 0, table );
- return NULL;
- }
- *count = new_count;
- table = new_table;
- }
- memcpy( (char *)table->table + (table->dwNumEntries * row_size), row, row_size );
- table->dwNumEntries++;
- return table;
-}
-
-
/* Why not a lookup table? Because the TCPS_* constants are different
on different platforms */
static inline MIB_TCP_STATE TCPStateToMIBState (int state)
@@ -2156,7 +2113,7 @@ DWORD build_tcp_table( TCP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
row.liCreateTimestamp.QuadPart = 0; /* FIXME */
memset( &row.OwningModuleInfo, 0, sizeof(row.OwningModuleInfo) );
}
- if (!(table = append_tcp_row( class, heap, flags, table, &count, &row, row_size )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, row_size )))
break;
}
HeapFree( GetProcessHeap(), 0, map );
@@ -2182,7 +2139,7 @@ DWORD build_tcp_table( TCP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
row.dwRemotePort = htons( entry->tcpConnRemPort );
row.dwState = entry->tcpConnState;
if (!match_class( class, row.dwState )) continue;
- if (!(table = append_tcp_row( class, heap, flags, table, &count, &row, row_size )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, row_size )))
break;
}
HeapFree( GetProcessHeap(), 0, data );
@@ -2276,7 +2233,7 @@ DWORD build_tcp_table( TCP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
row.liCreateTimestamp.QuadPart = 0; /* FIXME */
memset( &row.OwningModuleInfo, 0, sizeof(row.OwningModuleInfo) );
}
- if (!(table = append_tcp_row( class, heap, flags, table, &count, &row, row_size )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, row_size )))
break;
}
@@ -2395,29 +2352,6 @@ static DWORD get_udp_table_sizes( UDP_TABLE_CLASS class, DWORD row_count, DWORD
return table_size;
}
-static MIB_UDPTABLE *append_udp_row( UDP_TABLE_CLASS class, HANDLE heap, DWORD flags,
- MIB_UDPTABLE *table, DWORD *count,
- const MIB_UDPROW_OWNER_MODULE *row, DWORD row_size )
-{
- if (table->dwNumEntries >= *count)
- {
- MIB_UDPTABLE *new_table;
- DWORD new_count = table->dwNumEntries * 2, new_table_size;
-
- new_table_size = get_udp_table_sizes( class, new_count, NULL );
- if (!(new_table = HeapReAlloc( heap, flags, table, new_table_size )))
- {
- HeapFree( heap, 0, table );
- return NULL;
- }
- *count = new_count;
- table = new_table;
- }
- memcpy( (char *)table->table + (table->dwNumEntries * row_size), row, row_size );
- table->dwNumEntries++;
- return table;
-}
-
static int compare_udp_rows(const void *a, const void *b)
{
const MIB_UDPROW *rowA = a;
@@ -2474,7 +2408,7 @@ DWORD build_udp_table( UDP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
row.u.dwFlags = 0;
memset( &row.OwningModuleInfo, 0, sizeof(row.OwningModuleInfo) );
}
- if (!(table = append_udp_row( class, heap, flags, table, &count, &row, row_size )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, row_size )))
break;
}
HeapFree( GetProcessHeap(), 0, map );
@@ -2496,7 +2430,8 @@ DWORD build_udp_table( UDP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
{
row.dwLocalAddr = entry->udpLocalAddress;
row.dwLocalPort = htons( entry->udpLocalPort );
- if (!(table = append_udp_row( class, heap, flags, table, &count, &row, row_size ))) break;
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, row_size )))
+ break;
}
HeapFree( GetProcessHeap(), 0, data );
}
@@ -2584,7 +2519,8 @@ DWORD build_udp_table( UDP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
row.u.SpecificPortBind = !(pINData->inp_flags & INP_ANONPORT);
memset( &row.OwningModuleInfo, 0, sizeof(row.OwningModuleInfo) );
}
- if (!(table = append_udp_row( class, heap, flags, table, &count, &row, row_size ))) break;
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, row_size )))
+ break;
}
done:
@@ -2640,29 +2576,6 @@ static DWORD get_udp6_table_sizes( UDP_TABLE_CLASS class, DWORD row_count, DWORD
return table_size;
}
-static MIB_UDP6TABLE *append_udp6_row( UDP_TABLE_CLASS class, HANDLE heap, DWORD flags,
- MIB_UDP6TABLE *table, DWORD *count,
- const MIB_UDP6ROW_OWNER_MODULE *row, DWORD row_size )
-{
- if (table->dwNumEntries >= *count)
- {
- MIB_UDP6TABLE *new_table;
- DWORD new_count = table->dwNumEntries * 2, new_table_size;
-
- new_table_size = get_udp6_table_sizes( class, new_count, NULL );
- if (!(new_table = HeapReAlloc( heap, flags, table, new_table_size )))
- {
- HeapFree( heap, 0, table );
- return NULL;
- }
- *count = new_count;
- table = new_table;
- }
- memcpy( (char *)table->table + (table->dwNumEntries * row_size), row, row_size );
- table->dwNumEntries++;
- return table;
-}
-
static int compare_udp6_rows(const void *a, const void *b)
{
const MIB_UDP6ROW *rowA = a;
@@ -2824,7 +2737,7 @@ DWORD build_udp6_table( UDP_TABLE_CLASS class, void **tablep, BOOL order, HANDLE
row.u.dwFlags = 0;
memset( &row.OwningModuleInfo, 0, sizeof(row.OwningModuleInfo) );
}
- if (!(table = append_udp6_row( class, heap, flags, table, &count, &row, row_size )))
+ if (!(table = append_table_row( heap, flags, table, &table_size, &count, &row, row_size )))
break;
}
HeapFree( GetProcessHeap(), 0, map );
--
2.25.0
1
0
01 Feb '20
From: Qian Hong <qhong(a)codeweavers.com>
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
I know of no application that requires this.
The patch was originally sent as part of a set in which some patches were
labeled as for Cygwin:
https://www.winehq.org/pipermail/wine-patches/2015-April/138518.html
However, Cygwin is currently too broken in Wine to test.
dlls/advapi32/security.c | 5 +++--
dlls/advapi32/tests/security.c | 4 ++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/dlls/advapi32/security.c b/dlls/advapi32/security.c
index a7707f15d39..700ee7d8eae 100644
--- a/dlls/advapi32/security.c
+++ b/dlls/advapi32/security.c
@@ -187,7 +187,7 @@ static const WCHAR Domain_Admins[] = { 'D','o','m','a','i','n',' ','A','d','m','
static const WCHAR Domain_Computers[] = { 'D','o','m','a','i','n',' ','C','o','m','p','u','t','e','r','s',0 };
static const WCHAR Domain_Controllers[] = { 'D','o','m','a','i','n',' ','C','o','n','t','r','o','l','l','e','r','s',0 };
static const WCHAR Domain_Guests[] = { 'D','o','m','a','i','n',' ','G','u','e','s','t','s',0 };
-static const WCHAR Domain_Users[] = { 'D','o','m','a','i','n',' ','U','s','e','r','s',0 };
+static const WCHAR None[] = { 'N','o','n','e',0 };
static const WCHAR Enterprise_Admins[] = { 'E','n','t','e','r','p','r','i','s','e',' ','A','d','m','i','n','s',0 };
static const WCHAR ENTERPRISE_DOMAIN_CONTROLLERS[] = { 'E','N','T','E','R','P','R','I','S','E',' ','D','O','M','A','I','N',' ','C','O','N','T','R','O','L','L','E','R','S',0 };
static const WCHAR Everyone[] = { 'E','v','e','r','y','o','n','e',0 };
@@ -1185,7 +1185,8 @@ LookupAccountSidW(
ac = Domain_Admins;
break;
case DOMAIN_GROUP_RID_USERS:
- ac = Domain_Users;
+ ac = None;
+ use = SidTypeGroup;
break;
case DOMAIN_GROUP_RID_GUESTS:
ac = Domain_Guests;
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c
index 6d73300c1d4..afcdb6328e0 100644
--- a/dlls/advapi32/tests/security.c
+++ b/dlls/advapi32/tests/security.c
@@ -2928,11 +2928,11 @@ static void test_process_security(void)
dom_size = sizeof(domain);
ret = LookupAccountSidA( NULL, UsersSid, account, &acc_size, domain, &dom_size, &use );
ok(ret, "LookupAccountSid failed with %d\n", ret);
- todo_wine ok(use == SidTypeGroup, "expect SidTypeGroup, got %d\n", use);
+ ok(use == SidTypeGroup, "expect SidTypeGroup, got %d\n", use);
if (PRIMARYLANGID(GetSystemDefaultLangID()) != LANG_ENGLISH)
skip("Non-English locale (test with hardcoded 'None')\n");
else
- todo_wine ok(!strcmp(account, "None"), "expect None, got %s\n", account);
+ ok(!strcmp(account, "None"), "expect None, got %s\n", account);
res = GetTokenInformation( token, TokenUser, NULL, 0, &size );
ok(!res, "Expected failure, got %d\n", res);
--
2.25.0
1
0
[PATCH 1/2] advapi32/tests: Clean up and expand tests for LsaLookupSids().
by Zebediah Figura 01 Feb '20
by Zebediah Figura 01 Feb '20
01 Feb '20
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/advapi32/tests/lsa.c | 83 ++++++++++++++++++++++++---------------
1 file changed, 51 insertions(+), 32 deletions(-)
diff --git a/dlls/advapi32/tests/lsa.c b/dlls/advapi32/tests/lsa.c
index 451bee92e93..7b8f6b8e849 100644
--- a/dlls/advapi32/tests/lsa.c
+++ b/dlls/advapi32/tests/lsa.c
@@ -319,74 +319,93 @@ static void test_LsaLookupNames2(void)
ok(status == STATUS_SUCCESS, "LsaClose() failed, returned 0x%08x\n", status);
}
+static void check_unicode_string_(int line, const LSA_UNICODE_STRING *string, const WCHAR *expect)
+{
+ ok_(__FILE__, line)(string->Length == wcslen(string->Buffer) * sizeof(WCHAR),
+ "expected %u, got %u\n", wcslen(string->Buffer) * sizeof(WCHAR), string->Length);
+ ok_(__FILE__, line)(string->MaximumLength == string->Length + sizeof(WCHAR),
+ "expected %u, got %u\n", string->Length + sizeof(WCHAR), string->MaximumLength);
+ ok_(__FILE__, line)(!wcsicmp(string->Buffer, expect), "expected %s, got %s\n",
+ debugstr_w(expect), debugstr_w(string->Buffer));
+}
+#define check_unicode_string(a, b) check_unicode_string_(__LINE__, a, b)
+
static void test_LsaLookupSids(void)
{
+ char user_buffer[64];
+ LSA_OBJECT_ATTRIBUTES attrs = {.Length = sizeof(attrs)};
+ TOKEN_USER *user = (TOKEN_USER *)user_buffer;
+ WCHAR computer_name[64], user_name[64];
LSA_REFERENCED_DOMAIN_LIST *list;
- LSA_OBJECT_ATTRIBUTES attrs;
LSA_TRANSLATED_NAME *names;
LSA_HANDLE policy;
- TOKEN_USER *user;
NTSTATUS status;
HANDLE token;
DWORD size;
BOOL ret;
PSID sid;
- memset(&attrs, 0, sizeof(attrs));
- attrs.Length = sizeof(attrs);
-
status = LsaOpenPolicy(NULL, &attrs, POLICY_LOOKUP_NAMES, &policy);
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
ret = OpenProcessToken(GetCurrentProcess(), MAXIMUM_ALLOWED, &token);
- ok(ret, "got %d\n", ret);
+ ok(ret, "OpenProcessToken() failed, error %u\n", GetLastError());
+
+ ret = GetTokenInformation(token, TokenUser, user, sizeof(user_buffer), &size);
+ ok(ret, "GetTokenInformation() failed, error %u\n", GetLastError());
- ret = GetTokenInformation(token, TokenUser, NULL, 0, &size);
- ok(!ret, "got %d\n", ret);
+ size = ARRAY_SIZE(computer_name);
+ ret = GetComputerNameW(computer_name, &size);
+ ok(ret, "GetComputerName() failed, error %u\n", GetLastError());
- user = HeapAlloc(GetProcessHeap(), 0, size);
- ret = GetTokenInformation(token, TokenUser, user, size, &size);
- ok(ret, "got %d\n", ret);
+ size = ARRAY_SIZE(user_name);
+ ret = GetUserNameW(user_name, &size);
+ ok(ret, "GetUserName() failed, error %u\n", GetLastError());
status = LsaLookupSids(policy, 1, &user->User.Sid, &list, &names);
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
- ok(list->Entries > 0, "got %d\n", list->Entries);
- if (list->Entries)
- {
- ok((char*)list->Domains - (char*)list > 0, "%p, %p\n", list, list->Domains);
- ok((char*)list->Domains[0].Sid - (char*)list->Domains > 0, "%p, %p\n", list->Domains, list->Domains[0].Sid);
- ok(list->Domains[0].Name.MaximumLength > list->Domains[0].Name.Length, "got %d, %d\n", list->Domains[0].Name.MaximumLength,
- list->Domains[0].Name.Length);
- }
+ ok(list->Entries == 1, "got %d\n", list->Entries);
+ check_unicode_string(&list->Domains[0].Name, computer_name);
+
+ ok(names[0].Use == SidTypeUser, "got type %u\n", names[0].Use);
+ ok(!names[0].DomainIndex, "got index %u\n", names[0].DomainIndex);
+ check_unicode_string(&names[0].Name, user_name);
LsaFreeMemory(names);
LsaFreeMemory(list);
-
- HeapFree(GetProcessHeap(), 0, user);
-
CloseHandle(token);
ret = ConvertStringSidToSidA("S-1-1-0", &sid);
- ok(ret == TRUE, "ConvertStringSidToSidA returned false\n");
+ ok(ret, "ConvertStringSidToSidA() failed, error %u\n", GetLastError());
status = LsaLookupSids(policy, 1, &sid, &list, &names);
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
- ok(list->Entries > 0, "got %d\n", list->Entries);
+ ok(list->Entries == 1, "got %d\n", list->Entries);
+ check_unicode_string(&list->Domains[0].Name, L"");
- if (list->Entries)
- {
- ok((char*)list->Domains - (char*)list > 0, "%p, %p\n", list, list->Domains);
- ok((char*)list->Domains[0].Sid - (char*)list->Domains > 0, "%p, %p\n", list->Domains, list->Domains[0].Sid);
- ok(list->Domains[0].Name.MaximumLength > list->Domains[0].Name.Length, "got %d, %d\n", list->Domains[0].Name.MaximumLength,
- list->Domains[0].Name.Length);
- ok(list->Domains[0].Name.Buffer != NULL, "domain[0] name buffer is null\n");
- }
+ ok(names[0].Use == SidTypeWellKnownGroup, "got type %u\n", names[0].Use);
+ ok(!names[0].DomainIndex, "got index %u\n", names[0].DomainIndex);
+ check_unicode_string(&names[0].Name, L"Everyone");
LsaFreeMemory(names);
LsaFreeMemory(list);
+ FreeSid(sid);
+
+ ret = ConvertStringSidToSidA("S-1-1234-5678-1234-5678", &sid);
+ ok(ret, "ConvertStringSidToSidA() failed, error %u\n", GetLastError());
+ status = LsaLookupSids(policy, 1, &sid, &list, &names);
+ ok(status == STATUS_NONE_MAPPED, "got 0x%08x\n", status);
+
+ ok(!list->Entries, "got %d\n", list->Entries);
+
+ ok(names[0].Use == SidTypeUnknown, "got type %u\n", names[0].Use);
+ ok(names[0].DomainIndex == -1, "got index %u\n", names[0].DomainIndex);
+
+ LsaFreeMemory(names);
+ LsaFreeMemory(list);
FreeSid(sid);
status = LsaClose(policy);
--
2.25.0
1
1