Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- 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
June 2018
- 68 participants
- 1149 messages
[PATCH v2] user32: Always release menu item in EnableMenuItem
by Fabian Maurer
The menu must be release on all code-paths,
else the underlying lock will never be released.
Fixes bug 45355.
Signed-off-by: Fabian Maurer <dark.shadow4(a)web.de>
---
dlls/user32/menu.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 8c541cc4f91..570c6992cc9 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -3751,9 +3751,11 @@ BOOL WINAPI EnableMenuItem( HMENU hMenu, UINT id, UINT wFlags )
/* Get the parent menu to access*/
parentMenu = grab_menu_ptr(menu->hSysMenuOwner);
- release_menu_ptr(menu);
if (!parentMenu)
+ {
+ release_menu_ptr(menu);
return (UINT)-1;
+ }
hwnd = parentMenu->hWnd;
release_menu_ptr(parentMenu);
@@ -3764,8 +3766,7 @@ BOOL WINAPI EnableMenuItem( HMENU hMenu, UINT id, UINT wFlags )
RedrawWindow(hwnd, &rc, 0, RDW_FRAME | RDW_INVALIDATE | RDW_NOCHILDREN);
}
}
- else
- release_menu_ptr(menu);
+ release_menu_ptr(menu);
return oldflags;
}
--
2.17.1
June 20, 2018
Re: [PATCH] user32: Always release menu item in EnableMenuItem
by Nikolay Sivov
On 6/20/2018 11:46 PM, Fabian Maurer wrote:
> The menu must be release on all code-paths,
> else the underlying lock will never be released.
>
> Fixes bug 45355.
>
> Signed-off-by: Fabian Maurer <dark.shadow4(a)web.de>
> ---
> dlls/user32/menu.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
> index 8c541cc4f91..0b1133bbc41 100644
> --- a/dlls/user32/menu.c
> +++ b/dlls/user32/menu.c
> @@ -590,6 +590,7 @@ static POPUPMENU *find_menu_item(HMENU hmenu, UINT id, UINT flags, UINT *pos)
> POPUPMENU *menu;
>
> menu = grab_menu_ptr(hmenu);
> +
> if (!menu)
> return NULL;
>
> @@ -3763,6 +3764,8 @@ BOOL WINAPI EnableMenuItem( HMENU hMenu, UINT id, UINT wFlags )
> rc.bottom = 0;
> RedrawWindow(hwnd, &rc, 0, RDW_FRAME | RDW_INVALIDATE | RDW_NOCHILDREN);
> }
> + else
> + release_menu_ptr(menu);
> }
> else
> release_menu_ptr(menu);
>
It looks like it's enough to merge conditions to avoid such repetition.
June 20, 2018
Re: [PATCH v7 4/8] ntdll: Return BIOS info from NtQuerySystemInformation on Linux
by Alexandre Julliard
Alex Henrie <alexhenrie24(a)gmail.com> writes:
> The helper function doesn't need to support more than one buffer size,
> so passing the buffer size is redundant.
>
> I'd want to hear at least one more Wine developer's opinion before
> making a change.
It's indeed ugly to make that sort of assumption in the helper
function. Also you could return the resulting length instead of having
an out variable.
--
Alexandre Julliard
julliard(a)winehq.org
June 20, 2018
[PATCH] user32: Always release menu item in EnableMenuItem
by Fabian Maurer
The menu must be release on all code-paths,
else the underlying lock will never be released.
Fixes bug 45355.
Signed-off-by: Fabian Maurer <dark.shadow4(a)web.de>
---
dlls/user32/menu.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c
index 8c541cc4f91..0b1133bbc41 100644
--- a/dlls/user32/menu.c
+++ b/dlls/user32/menu.c
@@ -590,6 +590,7 @@ static POPUPMENU *find_menu_item(HMENU hmenu, UINT id, UINT flags, UINT *pos)
POPUPMENU *menu;
menu = grab_menu_ptr(hmenu);
+
if (!menu)
return NULL;
@@ -3763,6 +3764,8 @@ BOOL WINAPI EnableMenuItem( HMENU hMenu, UINT id, UINT wFlags )
rc.bottom = 0;
RedrawWindow(hwnd, &rc, 0, RDW_FRAME | RDW_INVALIDATE | RDW_NOCHILDREN);
}
+ else
+ release_menu_ptr(menu);
}
else
release_menu_ptr(menu);
--
2.17.1
June 20, 2018
Re: [PATCH v3 2/2] gdiplus: Avoid calling GdipFillPath() with an empty path.
by Vincent Povirk
Signed-off-by: Vincent Povirk <vincent(a)codeweavers.com>
June 20, 2018
Re: [PATCH v3 1/2] gdiplus: Report error for brush_fill_path().
by Vincent Povirk
Signed-off-by: Vincent Povirk <vincent(a)codeweavers.com>
June 20, 2018
[PATCH 5/5] webservices: Send incremental string table updates with messages in the same session.
by Hans Leidekker
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/webservices/channel.c | 31 +++++++++++++++++--------------
dlls/webservices/string.c | 18 +++++++++++++++++-
dlls/webservices/webservices_private.h | 3 +++
dlls/webservices/writer.c | 19 +++++++++++++++++++
4 files changed, 56 insertions(+), 15 deletions(-)
diff --git a/dlls/webservices/channel.c b/dlls/webservices/channel.c
index 79d431f279..5963faf00d 100644
--- a/dlls/webservices/channel.c
+++ b/dlls/webservices/channel.c
@@ -1009,22 +1009,26 @@ static inline ULONG size_length( ULONG size )
return 5;
}
-static ULONG string_table_size( const WS_XML_DICTIONARY *dict )
+static ULONG string_table_size( const struct dictionary *dict )
{
ULONG i, size = 0;
- for (i = 0; i < dict->stringCount; i++)
- size += size_length( dict->strings[i].length ) + dict->strings[i].length;
+ for (i = 0; i < dict->dict.stringCount; i++)
+ {
+ if (dict->sequence[i] == dict->current_sequence)
+ size += size_length( dict->dict.strings[i].length ) + dict->dict.strings[i].length;
+ }
return size;
}
-static HRESULT send_string_table( SOCKET socket, const WS_XML_DICTIONARY *dict )
+static HRESULT send_string_table( SOCKET socket, const struct dictionary *dict )
{
ULONG i;
HRESULT hr;
- for (i = 0; i < dict->stringCount; i++)
+ for (i = 0; i < dict->dict.stringCount; i++)
{
- if ((hr = send_size( socket, dict->strings[i].length )) != S_OK) return hr;
- if ((hr = send_bytes( socket, dict->strings[i].bytes, dict->strings[i].length )) != S_OK) return hr;
+ if (dict->sequence[i] != dict->current_sequence) continue;
+ if ((hr = send_size( socket, dict->dict.strings[i].length )) != S_OK) return hr;
+ if ((hr = send_bytes( socket, dict->dict.strings[i].bytes, dict->dict.strings[i].length )) != S_OK) return hr;
}
return S_OK;
}
@@ -1154,13 +1158,13 @@ static HRESULT receive_preamble_ack( struct channel *channel )
static HRESULT send_sized_envelope( struct channel *channel, BYTE *data, ULONG len )
{
- ULONG table_size = string_table_size( &channel->dict_send.dict );
+ ULONG table_size = string_table_size( &channel->dict_send );
HRESULT hr;
if ((hr = send_byte( channel->u.tcp.socket, FRAME_RECORD_TYPE_SIZED_ENVELOPE )) != S_OK) return hr;
if ((hr = send_size( channel->u.tcp.socket, size_length(table_size) + table_size + len )) != S_OK) return hr;
if ((hr = send_size( channel->u.tcp.socket, table_size )) != S_OK) return hr;
- if ((hr = send_string_table( channel->u.tcp.socket, &channel->dict_send.dict )) != S_OK) return hr;
+ if ((hr = send_string_table( channel->u.tcp.socket, &channel->dict_send )) != S_OK) return hr;
return send_bytes( channel->u.tcp.socket, data, len );
}
@@ -1285,11 +1289,8 @@ static HRESULT init_writer( struct channel *channel )
return WsSetOutput( channel->writer, &text.encoding, &buf.output, NULL, 0, NULL );
case WS_ENCODING_XML_BINARY_SESSION_1:
- clear_dict( &channel->dict_send );
- bin.staticDictionary = (WS_XML_DICTIONARY *)&dict_builtin_static.dict;
- bin.dynamicStringCallback = dict_cb;
- bin.dynamicStringCallbackState = &channel->dict_send;
- return WsSetOutput( channel->writer, &bin.encoding, &buf.output, NULL, 0, NULL );
+ bin.staticDictionary = (WS_XML_DICTIONARY *)&dict_builtin_static.dict;
+ /* fall through */
case WS_ENCODING_XML_BINARY_1:
return WsSetOutput( channel->writer, &bin.encoding, &buf.output, NULL, 0, NULL );
@@ -1307,6 +1308,8 @@ static HRESULT write_message( struct channel *channel, WS_MESSAGE *msg, const WS
if ((hr = writer_set_lookup( channel->writer, TRUE )) != S_OK) return hr;
if ((hr = WsWriteEnvelopeStart( msg, channel->writer, NULL, NULL, NULL )) != S_OK) return hr;
if ((hr = writer_set_lookup( channel->writer, FALSE )) != S_OK) return hr;
+ channel->dict_send.current_sequence++;
+ if ((hr = writer_set_dict_callback( channel->writer, dict_cb, &channel->dict_send )) != S_OK) return hr;
if ((hr = WsWriteBody( msg, desc, option, body, size, NULL )) != S_OK) return hr;
return WsWriteEnvelopeEnd( msg, NULL );
}
diff --git a/dlls/webservices/string.c b/dlls/webservices/string.c
index 18c55e3833..0bb77df946 100644
--- a/dlls/webservices/string.c
+++ b/dlls/webservices/string.c
@@ -91,7 +91,7 @@ int find_string( const struct dictionary *dict, const unsigned char *data, ULONG
static HRESULT grow_dict( struct dictionary *dict, ULONG size )
{
WS_XML_STRING *tmp;
- ULONG new_size, *tmp_sorted;
+ ULONG new_size, *tmp_sorted, *tmp_sequence;
assert( !dict->dict.isConst );
if (dict->size >= dict->dict.stringCount + size) return S_OK;
@@ -107,6 +107,14 @@ static HRESULT grow_dict( struct dictionary *dict, ULONG size )
dict->dict.strings = NULL;
return E_OUTOFMEMORY;
}
+ if (!(dict->sequence = heap_alloc( new_size * sizeof(*dict->sequence) )))
+ {
+ heap_free( dict->dict.strings );
+ dict->dict.strings = NULL;
+ heap_free( dict->sorted );
+ dict->sorted = NULL;
+ return E_OUTOFMEMORY;
+ }
dict->size = new_size;
return S_OK;
}
@@ -116,6 +124,8 @@ static HRESULT grow_dict( struct dictionary *dict, ULONG size )
dict->dict.strings = tmp;
if (!(tmp_sorted = heap_realloc( dict->sorted, new_size * sizeof(*tmp_sorted) ))) return E_OUTOFMEMORY;
dict->sorted = tmp_sorted;
+ if (!(tmp_sequence = heap_realloc( dict->sequence, new_size * sizeof(*tmp_sequence) ))) return E_OUTOFMEMORY;
+ dict->sequence = tmp_sequence;
dict->size = new_size;
return S_OK;
@@ -131,6 +141,9 @@ void clear_dict( struct dictionary *dict )
dict->dict.stringCount = 0;
heap_free( dict->sorted );
dict->sorted = NULL;
+ heap_free( dict->sequence );
+ dict->sequence = NULL;
+ dict->current_sequence = 0;
dict->size = 0;
}
@@ -149,6 +162,9 @@ HRESULT insert_string( struct dictionary *dict, unsigned char *data, ULONG len,
dict->dict.strings[id].dictionary = &dict->dict;
dict->dict.strings[id].id = id;
dict->dict.stringCount++;
+
+ dict->sequence[id] = dict->current_sequence;
+
if (ret_id) *ret_id = id;
return S_OK;
}
diff --git a/dlls/webservices/webservices_private.h b/dlls/webservices/webservices_private.h
index bfc3202a64..d981527bb2 100644
--- a/dlls/webservices/webservices_private.h
+++ b/dlls/webservices/webservices_private.h
@@ -43,6 +43,8 @@ struct dictionary
WS_XML_DICTIONARY dict;
ULONG *sorted;
ULONG size;
+ ULONG current_sequence;
+ ULONG *sequence;
};
struct dictionary dict_builtin DECLSPEC_HIDDEN;
const struct dictionary dict_builtin_static DECLSPEC_HIDDEN;
@@ -51,6 +53,7 @@ int find_string( const struct dictionary *, const unsigned char *, ULONG, ULONG
HRESULT insert_string( struct dictionary *, unsigned char *, ULONG, int, ULONG * ) DECLSPEC_HIDDEN;
void clear_dict( struct dictionary * ) DECLSPEC_HIDDEN;
HRESULT writer_set_lookup( WS_XML_WRITER *, BOOL ) DECLSPEC_HIDDEN;
+HRESULT writer_set_dict_callback( WS_XML_WRITER *, WS_DYNAMIC_STRING_CALLBACK, void * ) DECLSPEC_HIDDEN;
const char *debugstr_xmlstr( const WS_XML_STRING * ) DECLSPEC_HIDDEN;
WS_XML_STRING *alloc_xml_string( const unsigned char *, ULONG ) DECLSPEC_HIDDEN;
diff --git a/dlls/webservices/writer.c b/dlls/webservices/writer.c
index b3d130a52c..95d4caddb9 100644
--- a/dlls/webservices/writer.c
+++ b/dlls/webservices/writer.c
@@ -4866,3 +4866,22 @@ HRESULT writer_set_lookup( WS_XML_WRITER *handle, BOOL enable )
LeaveCriticalSection( &writer->cs );
return S_OK;
}
+
+HRESULT writer_set_dict_callback( WS_XML_WRITER *handle, WS_DYNAMIC_STRING_CALLBACK cb, void *state )
+{
+ struct writer *writer = (struct writer *)handle;
+
+ EnterCriticalSection( &writer->cs );
+
+ if (writer->magic != WRITER_MAGIC)
+ {
+ LeaveCriticalSection( &writer->cs );
+ return E_INVALIDARG;
+ }
+
+ writer->dict_cb = cb;
+ writer->dict_cb_state = state;
+
+ LeaveCriticalSection( &writer->cs );
+ return S_OK;
+}
--
2.11.0
June 20, 2018
[PATCH 4/5] webservices: Use the static dictionary only while writing the message header.
by Hans Leidekker
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/webservices/channel.c | 30 ++++++++++++++----------------
dlls/webservices/webservices_private.h | 2 +-
dlls/webservices/writer.c | 4 ++--
3 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/dlls/webservices/channel.c b/dlls/webservices/channel.c
index 6c7c8affa3..79d431f279 100644
--- a/dlls/webservices/channel.c
+++ b/dlls/webservices/channel.c
@@ -967,15 +967,6 @@ static HRESULT connect_channel( struct channel *channel )
}
}
-static HRESULT write_message( WS_MESSAGE *handle, WS_XML_WRITER *writer, const WS_ELEMENT_DESCRIPTION *desc,
- WS_WRITE_OPTION option, const void *body, ULONG size )
-{
- HRESULT hr;
- if ((hr = WsWriteEnvelopeStart( handle, writer, NULL, NULL, NULL )) != S_OK) return hr;
- if ((hr = WsWriteBody( handle, desc, option, body, size, NULL )) != S_OK) return hr;
- return WsWriteEnvelopeEnd( handle, NULL );
-}
-
static HRESULT send_message_http( HINTERNET request, BYTE *data, ULONG len )
{
if (!WinHttpSendRequest( request, NULL, 0, data, len, len, 0 ))
@@ -1298,8 +1289,7 @@ static HRESULT init_writer( struct channel *channel )
bin.staticDictionary = (WS_XML_DICTIONARY *)&dict_builtin_static.dict;
bin.dynamicStringCallback = dict_cb;
bin.dynamicStringCallbackState = &channel->dict_send;
- if ((hr = WsSetOutput( channel->writer, &bin.encoding, &buf.output, NULL, 0, NULL )) != S_OK) return hr;
- return writer_enable_lookup( channel->writer );
+ return WsSetOutput( channel->writer, &bin.encoding, &buf.output, NULL, 0, NULL );
case WS_ENCODING_XML_BINARY_1:
return WsSetOutput( channel->writer, &bin.encoding, &buf.output, NULL, 0, NULL );
@@ -1310,6 +1300,17 @@ static HRESULT init_writer( struct channel *channel )
}
}
+static HRESULT write_message( struct channel *channel, WS_MESSAGE *msg, const WS_ELEMENT_DESCRIPTION *desc,
+ WS_WRITE_OPTION option, const void *body, ULONG size )
+{
+ HRESULT hr;
+ if ((hr = writer_set_lookup( channel->writer, TRUE )) != S_OK) return hr;
+ if ((hr = WsWriteEnvelopeStart( msg, channel->writer, NULL, NULL, NULL )) != S_OK) return hr;
+ if ((hr = writer_set_lookup( channel->writer, FALSE )) != S_OK) return hr;
+ if ((hr = WsWriteBody( msg, desc, option, body, size, NULL )) != S_OK) return hr;
+ return WsWriteEnvelopeEnd( msg, NULL );
+}
+
/**************************************************************************
* WsSendMessage [webservices.@]
*/
@@ -1339,8 +1340,7 @@ HRESULT WINAPI WsSendMessage( WS_CHANNEL *handle, WS_MESSAGE *msg, const WS_MESS
if ((hr = message_set_action( msg, desc->action )) != S_OK) goto done;
if ((hr = init_writer( channel )) != S_OK) goto done;
- if ((hr = write_message( msg, channel->writer, desc->bodyElementDescription, option, body, size )) != S_OK)
- goto done;
+ if ((hr = write_message( channel, msg, desc->bodyElementDescription, option, body, size )) != S_OK) goto done;
hr = send_message( channel, msg );
done:
@@ -1380,13 +1380,11 @@ HRESULT WINAPI WsSendReplyMessage( WS_CHANNEL *handle, WS_MESSAGE *msg, const WS
if ((hr = message_set_request_id( msg, &req_id )) != S_OK) goto done;
if ((hr = init_writer( channel )) != S_OK) goto done;
- if ((hr = write_message( msg, channel->writer, desc->bodyElementDescription, option, body, size )) != S_OK)
- goto done;
+ if ((hr = write_message( channel, msg, desc->bodyElementDescription, option, body, size )) != S_OK) goto done;
hr = send_message( channel, msg );
done:
LeaveCriticalSection( &channel->cs );
- FIXME( "returning %08x\n", hr );
return hr;
}
diff --git a/dlls/webservices/webservices_private.h b/dlls/webservices/webservices_private.h
index cce49cce14..bfc3202a64 100644
--- a/dlls/webservices/webservices_private.h
+++ b/dlls/webservices/webservices_private.h
@@ -50,7 +50,7 @@ const struct dictionary dict_builtin_static DECLSPEC_HIDDEN;
int find_string( const struct dictionary *, const unsigned char *, ULONG, ULONG * ) DECLSPEC_HIDDEN;
HRESULT insert_string( struct dictionary *, unsigned char *, ULONG, int, ULONG * ) DECLSPEC_HIDDEN;
void clear_dict( struct dictionary * ) DECLSPEC_HIDDEN;
-HRESULT writer_enable_lookup( WS_XML_WRITER * ) DECLSPEC_HIDDEN;
+HRESULT writer_set_lookup( WS_XML_WRITER *, BOOL ) DECLSPEC_HIDDEN;
const char *debugstr_xmlstr( const WS_XML_STRING * ) DECLSPEC_HIDDEN;
WS_XML_STRING *alloc_xml_string( const unsigned char *, ULONG ) DECLSPEC_HIDDEN;
diff --git a/dlls/webservices/writer.c b/dlls/webservices/writer.c
index 33c1be70b5..b3d130a52c 100644
--- a/dlls/webservices/writer.c
+++ b/dlls/webservices/writer.c
@@ -4849,7 +4849,7 @@ done:
return hr;
}
-HRESULT writer_enable_lookup( WS_XML_WRITER *handle )
+HRESULT writer_set_lookup( WS_XML_WRITER *handle, BOOL enable )
{
struct writer *writer = (struct writer *)handle;
@@ -4861,7 +4861,7 @@ HRESULT writer_enable_lookup( WS_XML_WRITER *handle )
return E_INVALIDARG;
}
- writer->dict_do_lookup = TRUE;
+ writer->dict_do_lookup = enable;
LeaveCriticalSection( &writer->cs );
return S_OK;
--
2.11.0
June 20, 2018
[PATCH 3/5] webservices: Implement WsShutdownSessionChannel.
by Hans Leidekker
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/webservices/channel.c | 98 +++++++++++++++++++++++++++++----------
dlls/webservices/tests/channel.c | 12 +++++
dlls/webservices/webservices.spec | 2 +-
include/webservices.h | 1 +
4 files changed, 87 insertions(+), 26 deletions(-)
diff --git a/dlls/webservices/channel.c b/dlls/webservices/channel.c
index 685e13d99d..6c7c8affa3 100644
--- a/dlls/webservices/channel.c
+++ b/dlls/webservices/channel.c
@@ -193,6 +193,7 @@ enum session_state
{
SESSION_STATE_UNINITIALIZED,
SESSION_STATE_SETUP_COMPLETE,
+ SESSION_STATE_SHUTDOWN,
};
struct channel
@@ -664,6 +665,78 @@ HRESULT WINAPI WsOpenChannel( WS_CHANNEL *handle, const WS_ENDPOINT_ADDRESS *end
return hr;
}
+enum frame_record_type
+{
+ FRAME_RECORD_TYPE_VERSION,
+ FRAME_RECORD_TYPE_MODE,
+ FRAME_RECORD_TYPE_VIA,
+ FRAME_RECORD_TYPE_KNOWN_ENCODING,
+ FRAME_RECORD_TYPE_EXTENSIBLE_ENCODING,
+ FRAME_RECORD_TYPE_UNSIZED_ENVELOPE,
+ FRAME_RECORD_TYPE_SIZED_ENVELOPE,
+ FRAME_RECORD_TYPE_END,
+ FRAME_RECORD_TYPE_FAULT,
+ FRAME_RECORD_TYPE_UPGRADE_REQUEST,
+ FRAME_RECORD_TYPE_UPGRADE_RESPONSE,
+ FRAME_RECORD_TYPE_PREAMBLE_ACK,
+ FRAME_RECORD_TYPE_PREAMBLE_END,
+};
+
+static HRESULT send_byte( SOCKET socket, BYTE byte )
+{
+ int count = send( socket, (char *)&byte, 1, 0 );
+ if (count < 0) return HRESULT_FROM_WIN32( WSAGetLastError() );
+ if (count != 1) return WS_E_OTHER;
+ return S_OK;
+}
+
+static HRESULT shutdown_session( struct channel *channel )
+{
+ HRESULT hr;
+
+ if (channel->state != WS_CHANNEL_STATE_OPEN ||
+ (channel->type != WS_CHANNEL_TYPE_OUTPUT_SESSION &&
+ channel->type != WS_CHANNEL_TYPE_DUPLEX_SESSION) ||
+ channel->session_state >= SESSION_STATE_SHUTDOWN) return WS_E_INVALID_OPERATION;
+
+ switch (channel->binding)
+ {
+ case WS_TCP_CHANNEL_BINDING:
+ if ((hr = send_byte( channel->u.tcp.socket, FRAME_RECORD_TYPE_END )) != S_OK) return hr;
+ channel->session_state = SESSION_STATE_SHUTDOWN;
+ return S_OK;
+
+ default:
+ FIXME( "unhandled binding %u\n", channel->binding );
+ return E_NOTIMPL;
+ }
+}
+
+HRESULT WINAPI WsShutdownSessionChannel( WS_CHANNEL *handle, const WS_ASYNC_CONTEXT *ctx, WS_ERROR *error )
+{
+ struct channel *channel = (struct channel *)handle;
+ HRESULT hr;
+
+ TRACE( "%p %p %p\n", handle, ctx, error );
+ if (error) FIXME( "ignoring error parameter\n" );
+ if (ctx) FIXME( "ignoring ctx parameter\n" );
+
+ if (!channel) return E_INVALIDARG;
+
+ EnterCriticalSection( &channel->cs );
+
+ if (channel->magic != CHANNEL_MAGIC)
+ {
+ LeaveCriticalSection( &channel->cs );
+ return E_INVALIDARG;
+ }
+
+ hr = shutdown_session( channel );
+
+ LeaveCriticalSection( &channel->cs );
+ return hr;
+}
+
static void close_channel( struct channel *channel )
{
reset_channel( channel );
@@ -913,14 +986,6 @@ static HRESULT send_message_http( HINTERNET request, BYTE *data, ULONG len )
return S_OK;
}
-static HRESULT send_byte( SOCKET socket, BYTE byte )
-{
- int count = send( socket, (char *)&byte, 1, 0 );
- if (count < 0) return HRESULT_FROM_WIN32( WSAGetLastError() );
- if (count != 1) return WS_E_OTHER;
- return S_OK;
-}
-
static HRESULT send_bytes( SOCKET socket, BYTE *bytes, int len )
{
int count = send( socket, (char *)bytes, len, 0 );
@@ -944,23 +1009,6 @@ static HRESULT send_size( SOCKET socket, ULONG size )
return E_INVALIDARG;
}
-enum frame_record_type
-{
- FRAME_RECORD_TYPE_VERSION,
- FRAME_RECORD_TYPE_MODE,
- FRAME_RECORD_TYPE_VIA,
- FRAME_RECORD_TYPE_KNOWN_ENCODING,
- FRAME_RECORD_TYPE_EXTENSIBLE_ENCODING,
- FRAME_RECORD_TYPE_UNSIZED_ENVELOPE,
- FRAME_RECORD_TYPE_SIZED_ENVELOPE,
- FRAME_RECORD_TYPE_END,
- FRAME_RECORD_TYPE_FAULT,
- FRAME_RECORD_TYPE_UPGRADE_REQUEST,
- FRAME_RECORD_TYPE_UPGRADE_RESPONSE,
- FRAME_RECORD_TYPE_PREAMBLE_ACK,
- FRAME_RECORD_TYPE_PREAMBLE_END,
-};
-
static inline ULONG size_length( ULONG size )
{
if (size < 0x80) return 1;
diff --git a/dlls/webservices/tests/channel.c b/dlls/webservices/tests/channel.c
index c995a08829..db17893138 100644
--- a/dlls/webservices/tests/channel.c
+++ b/dlls/webservices/tests/channel.c
@@ -496,6 +496,9 @@ static void test_message_read_write( const struct listener_info *info )
hr = WsOpenChannel( channel, &addr, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
+ hr = WsShutdownSessionChannel( channel, NULL, NULL );
+ ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
+
hr = WsCreateMessageForChannel( channel, NULL, 0, &msg, NULL );
ok( hr == S_OK, "got %08x\n", hr );
@@ -627,6 +630,9 @@ static void test_duplex_session( const struct listener_info *info )
hr = WsCreateChannel( info->type, info->binding, NULL, 0, NULL, &channel, NULL );
ok( hr == S_OK, "got %08x\n", hr );
+ hr = WsShutdownSessionChannel( channel, NULL, NULL );
+ ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
+
memset( &addr, 0, sizeof(addr) );
addr.url.length = wsprintfW( buf, fmt, info->port );
addr.url.chars = buf;
@@ -655,6 +661,12 @@ static void test_duplex_session( const struct listener_info *info )
err = WaitForSingleObject( info->wait, 3000 );
ok( err == WAIT_OBJECT_0, "wait failed %u\n", err );
+ hr = WsShutdownSessionChannel( channel, NULL, NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+
+ hr = WsShutdownSessionChannel( channel, NULL, NULL );
+ ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
+
hr = WsCloseChannel( channel, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
diff --git a/dlls/webservices/webservices.spec b/dlls/webservices/webservices.spec
index 55f3e2eaac..8ba34b4209 100644
--- a/dlls/webservices/webservices.spec
+++ b/dlls/webservices/webservices.spec
@@ -158,7 +158,7 @@
@ stdcall WsSetOutputToBuffer(ptr ptr ptr long ptr)
@ stdcall WsSetReaderPosition(ptr ptr ptr)
@ stdcall WsSetWriterPosition(ptr ptr ptr)
-@ stub WsShutdownSessionChannel
+@ stdcall WsShutdownSessionChannel(ptr ptr ptr)
@ stdcall WsSkipNode(ptr ptr)
@ stub WsStartReaderCanonicalization
@ stub WsStartWriterCanonicalization
diff --git a/include/webservices.h b/include/webservices.h
index 1f823ddc27..928819fc3d 100644
--- a/include/webservices.h
+++ b/include/webservices.h
@@ -1732,6 +1732,7 @@ HRESULT WINAPI WsSetOutputToBuffer(WS_XML_WRITER*, WS_XML_BUFFER*, const WS_XML_
ULONG, WS_ERROR*);
HRESULT WINAPI WsSetReaderPosition(WS_XML_READER*, const WS_XML_NODE_POSITION*, WS_ERROR*);
HRESULT WINAPI WsSetWriterPosition(WS_XML_WRITER*, const WS_XML_NODE_POSITION*, WS_ERROR*);
+HRESULT WINAPI WsShutdownSessionChannel(WS_CHANNEL*, const WS_ASYNC_CONTEXT*, WS_ERROR*);
HRESULT WINAPI WsSkipNode(WS_XML_READER*, WS_ERROR*);
HRESULT WINAPI WsWriteArray(WS_XML_WRITER*, const WS_XML_STRING*, const WS_XML_STRING*, WS_VALUE_TYPE,
const void*, ULONG, ULONG, ULONG, WS_ERROR*);
--
2.11.0
June 20, 2018
[PATCH 2/5] webservices: Avoid accessing the old user buffer in WsSetOutput/ToBuffer.
by Hans Leidekker
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/webservices/writer.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/webservices/writer.c b/dlls/webservices/writer.c
index 9cba4e60a2..33c1be70b5 100644
--- a/dlls/webservices/writer.c
+++ b/dlls/webservices/writer.c
@@ -39,7 +39,7 @@ static const struct prop_desc writer_props[] =
{
{ sizeof(ULONG), FALSE }, /* WS_XML_WRITER_PROPERTY_MAX_DEPTH */
{ sizeof(BOOL), FALSE }, /* WS_XML_WRITER_PROPERTY_ALLOW_FRAGMENT */
- { sizeof(ULONG), FALSE }, /* WS_XML_READER_PROPERTY_MAX_ATTRIBUTES */
+ { sizeof(ULONG), FALSE }, /* WS_XML_WRITER_PROPERTY_MAX_ATTRIBUTES */
{ sizeof(BOOL), FALSE }, /* WS_XML_WRITER_PROPERTY_WRITE_DECLARATION */
{ sizeof(ULONG), FALSE }, /* WS_XML_WRITER_PROPERTY_INDENT */
{ sizeof(ULONG), FALSE }, /* WS_XML_WRITER_PROPERTY_BUFFER_TRIM_SIZE */
@@ -85,6 +85,7 @@ struct writer
WS_CHARSET output_charset;
WS_XML_WRITER_OUTPUT_TYPE output_type;
struct xmlbuf *output_buf;
+ BOOL output_buf_user;
WS_HEAP *output_heap;
const WS_XML_DICTIONARY *dict;
BOOL dict_do_lookup;
@@ -332,7 +333,7 @@ HRESULT WINAPI WsGetWriterProperty( WS_XML_WRITER *handle, WS_XML_WRITER_PROPERT
static void set_output_buffer( struct writer *writer, struct xmlbuf *xmlbuf )
{
/* free current buffer if it's ours */
- if (writer->output_buf && writer->output_buf->heap == writer->output_heap)
+ if (writer->output_buf && !writer->output_buf_user)
{
free_xmlbuf( writer->output_buf );
}
@@ -419,6 +420,7 @@ HRESULT WINAPI WsSetOutput( WS_XML_WRITER *handle, const WS_XML_WRITER_ENCODING
goto done;
}
set_output_buffer( writer, xmlbuf );
+ writer->output_buf_user = FALSE;
break;
}
default:
@@ -472,6 +474,7 @@ HRESULT WINAPI WsSetOutputToBuffer( WS_XML_WRITER *handle, WS_XML_BUFFER *buffer
writer->output_enc = xmlbuf->encoding;
writer->output_charset = xmlbuf->charset;
set_output_buffer( writer, xmlbuf );
+ writer->output_buf_user = TRUE;
if (!(node = alloc_node( WS_XML_NODE_TYPE_BOF ))) hr = E_OUTOFMEMORY;
else write_insert_bof( writer, node );
--
2.11.0
June 20, 2018
[PATCH 1/5] webservices: Avoid a warning from HeapDestroy.
by Hans Leidekker
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
---
dlls/webservices/heap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/webservices/heap.c b/dlls/webservices/heap.c
index 5e1a273329..e44cf72e74 100644
--- a/dlls/webservices/heap.c
+++ b/dlls/webservices/heap.c
@@ -216,7 +216,7 @@ HRESULT WINAPI WsCreateHeap( SIZE_T max_size, SIZE_T trim_size, const WS_HEAP_PR
static void reset_heap( struct heap *heap )
{
- HeapDestroy( heap->handle );
+ if (heap->handle) HeapDestroy( heap->handle );
heap->handle = NULL;
heap->max_size = heap->allocated = 0;
}
--
2.11.0
June 20, 2018
Re: [PATCH 6/6] wined3d: Call wined3d_cs_emit_update_sub_resource() directly in buffer_init().
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
June 20, 2018
Re: [PATCH 5/6] wined3d: Use WINED3D_LOCATION_DISCARDED before initializing buffers with data.
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
June 20, 2018
Re: [PATCH 4/6] wined3d: Reduce nesting in texture2d_load_sysmem().
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
June 20, 2018
Re: [PATCH 2/6] wined3d: Initialize depth/stencil texture data.
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
June 20, 2018
Re: [PATCH 3/6] d3d9/tests: Add test for depth stencil initialization.
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
June 20, 2018
Re: [PATCH 1/6] d3d11: Introduce get_resource_properties() helper function.
by Henri Verbeet
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
June 20, 2018
Re: [PATCH 2/3] crypt32: Implement decoding of X509_OBJECT_IDENTIFIER.
by Nikolay Sivov
On 06/20/2018 11:10 AM, Alistair Leslie-Hughes wrote:
> Hi Nikolay,
>
> Is there a reason why you didn't include tests in this series?
>
Patch doesn't mention how test blobs were generated, I'd like to find a
reproducible way to recreated them.
>
> Alistair.
>
>
> On 20/06/18 17:37, Nikolay Sivov wrote:
>> From: Michael Müller<michael(a)fds-team.de>
>>
>> Signed-off-by: Nikolay Sivov<nsivov(a)codeweavers.com>
>> ---
>> dlls/crypt32/decode.c | 45 +++++++++++++++++++++++++++++++++++++++++++
>> include/wincrypt.h | 15 +++++++++++++++
>> 2 files changed, 60 insertions(+)
>>
>> diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c
>> index a61316016f..4f11d0d60f 100644
>> --- a/dlls/crypt32/decode.c
>> +++ b/dlls/crypt32/decode.c
>> @@ -5973,6 +5973,46 @@ BOOL CRYPT_AsnDecodePKCSEnvelopedData(const BYTE *pbEncoded, DWORD cbEncoded,
>> return ret;
>> }
>>
>> +static BOOL WINAPI CRYPT_AsnDecodeObjectIdentifier(DWORD dwCertEncodingType,
>> + LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
>> + CRYPT_DECODE_PARA *pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo)
>> +{
>> + DWORD bytesNeeded = 0;
>> + BOOL ret;
>> +
>> + __TRY
>> + {
>> + ret = CRYPT_AsnDecodeOidInternal(pbEncoded, cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG,
>> + NULL, &bytesNeeded, NULL);
>> + if (ret)
>> + {
>> + if (!pvStructInfo)
>> + *pcbStructInfo = bytesNeeded;
>> + else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, bytesNeeded)))
>> + {
>> + LPSTR *info;
>> +
>> + if (dwFlags & CRYPT_DECODE_ALLOC_FLAG)
>> + pvStructInfo = *(BYTE **)pvStructInfo;
>> +
>> + info = pvStructInfo;
>> + *info = (void *)((BYTE *)info + sizeof(*info));
>> + ret = CRYPT_AsnDecodeOidInternal(pbEncoded, cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG,
>> + pvStructInfo, &bytesNeeded, NULL);
>> + if (!ret && (dwFlags & CRYPT_DECODE_ALLOC_FLAG))
>> + CRYPT_FreeSpace(pDecodePara, info);
>> + }
>> + }
>> + }
>> + __EXCEPT_PAGE_FAULT
>> + {
>> + SetLastError(STATUS_ACCESS_VIOLATION);
>> + ret = FALSE;
>> + }
>> + __ENDTRY
>> + return ret;
>> +}
>> +
>> static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType,
>> LPCSTR lpszStructType)
>> {
>> @@ -6112,6 +6152,9 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType,
>> case LOWORD(CMS_SIGNER_INFO):
>> decodeFunc = CRYPT_AsnDecodeCMSSignerInfo;
>> break;
>> + case LOWORD(X509_OBJECT_IDENTIFIER):
>> + decodeFunc = CRYPT_AsnDecodeObjectIdentifier;
>> + break;
>> }
>> }
>> else if (!strcmp(lpszStructType, szOID_CERT_EXTENSIONS))
>> @@ -6166,6 +6209,8 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType,
>> decodeFunc = CRYPT_AsnDecodePolicyQualifierUserNotice;
>> else if (!strcmp(lpszStructType, szOID_CTL))
>> decodeFunc = CRYPT_AsnDecodeCTL;
>> + else if (!strcmp(lpszStructType, szOID_ECC_PUBLIC_KEY))
>> + decodeFunc = CRYPT_AsnDecodeObjectIdentifier;
>> return decodeFunc;
>> }
>>
>> diff --git a/include/wincrypt.h b/include/wincrypt.h
>> index 6e71fb902e..a7c24e7831 100644
>> --- a/include/wincrypt.h
>> +++ b/include/wincrypt.h
>> @@ -288,6 +288,11 @@ typedef struct _CERT_KEY_ATTRIBUTES_INFO {
>> PCERT_PRIVATE_KEY_VALIDITY pPrivateKeyUsagePeriod;
>> } CERT_KEY_ATTRIBUTES_INFO, *PCERT_KEY_ATTRIBUTES_INFO;
>>
>> +typedef struct _CERT_ECC_SIGNATURE {
>> + CRYPT_UINT_BLOB r;
>> + CRYPT_UINT_BLOB s;
>> +} CERT_ECC_SIGNATURE, *PCERT_ECC_SIGNATURE;
>> +
>> /* byte 0 */
>> #define CERT_DIGITAL_SIGNATURE_KEY_USAGE 0x80
>> #define CERT_NON_REPUDIATION_KEY_USAGE 0x40
>> @@ -2878,6 +2883,12 @@ typedef struct _CTL_FIND_SUBJECT_PARA
>> #define szOID_X957 "1.2.840.10040"
>> #define szOID_X957_DSA "1.2.840.10040.4.1"
>> #define szOID_X957_SHA1DSA "1.2.840.10040.4.3"
>> +#define szOID_ECC_PUBLIC_KEY "1.2.840.10045.2.1"
>> +#define szOID_ECC_CURVE_P256 "1.2.840.10045.3.1.7"
>> +#define szOID_ECDSA_SPECIFIED "1.2.840.10045.4.3"
>> +#define szOID_ECDSA_SHA256 "1.2.840.10045.4.3.2"
>> +#define szOID_ECDSA_SHA384 "1.2.840.10045.4.3.3"
>> +#define szOID_ECDSA_SHA512 "1.2.840.10045.4.3.4"
>> #define szOID_DS "2.5"
>> #define szOID_DSALG "2.5.8"
>> #define szOID_DSALG_CRPT "2.5.8.1"
>> @@ -2919,6 +2930,8 @@ typedef struct _CTL_FIND_SUBJECT_PARA
>> #define szOID_OIWDIR_SIGN "1.3.14.7.2.3"
>> #define szOID_OIWDIR_md2 "1.3.14.7.2.2.1"
>> #define szOID_OIWDIR_md2RSA "1.3.14.7.2.3.1"
>> +#define szOID_ECC_CURVE_P384 "1.3.132.0.34"
>> +#define szOID_ECC_CURVE_P521 "1.3.132.0.35"
>> #define szOID_INFOSEC "2.16.840.1.101.2.1"
>> #define szOID_INFOSEC_sdnsSignature "2.16.840.1.101.2.1.1.1"
>> #define szOID_INFOSEC_mosaicSignature "2.16.840.1.101.2.1.1.2"
>> @@ -3223,6 +3236,7 @@ typedef struct _CTL_FIND_SUBJECT_PARA
>> #define X509_PKIX_POLICY_QUALIFIER_USERNOTICE ((LPCSTR)46)
>> #define X509_DH_PUBLICKEY X509_MULTI_BYTE_UINT
>> #define X509_DH_PARAMETERS ((LPCSTR)47)
>> +#define X509_ECC_SIGNATURE ((LPCSTR)47)
>> #define PKCS_ATTRIBUTES ((LPCSTR)48)
>> #define PKCS_SORTED_CTL ((LPCSTR)49)
>> #define X942_DH_PARAMETERS ((LPCSTR)50)
>> @@ -3240,6 +3254,7 @@ typedef struct _CTL_FIND_SUBJECT_PARA
>> #define CMC_ADD_EXTENSIONS ((LPCSTR)62)
>> #define CMC_ADD_ATTRIBUTES ((LPCSTR)63)
>> #define X509_CERTIFICATE_TEMPLATE ((LPCSTR)64)
>> +#define X509_OBJECT_IDENTIFIER ((LPCSTR)73)
>> #define PKCS7_SIGNER_INFO ((LPCSTR)500)
>> #define CMS_SIGNER_INFO ((LPCSTR)501)
>>
>>
>>
>
June 20, 2018
Re: [PATCH 2/3] crypt32: Implement decoding of X509_OBJECT_IDENTIFIER.
by Alistair Leslie-Hughes
Hi Nikolay,
Is there a reason why you didn't include tests in this series?
Alistair.
On 20/06/18 17:37, Nikolay Sivov wrote:
From: Michael Müller <michael(a)fds-team.de><mailto:michael(a)fds-team.de>
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com><mailto:nsivov(a)codeweavers.com>
---
dlls/crypt32/decode.c | 45 +++++++++++++++++++++++++++++++++++++++++++
include/wincrypt.h | 15 +++++++++++++++
2 files changed, 60 insertions(+)
diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c
index a61316016f..4f11d0d60f 100644
--- a/dlls/crypt32/decode.c
+++ b/dlls/crypt32/decode.c
@@ -5973,6 +5973,46 @@ BOOL CRYPT_AsnDecodePKCSEnvelopedData(const BYTE *pbEncoded, DWORD cbEncoded,
return ret;
}
+static BOOL WINAPI CRYPT_AsnDecodeObjectIdentifier(DWORD dwCertEncodingType,
+ LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
+ CRYPT_DECODE_PARA *pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo)
+{
+ DWORD bytesNeeded = 0;
+ BOOL ret;
+
+ __TRY
+ {
+ ret = CRYPT_AsnDecodeOidInternal(pbEncoded, cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG,
+ NULL, &bytesNeeded, NULL);
+ if (ret)
+ {
+ if (!pvStructInfo)
+ *pcbStructInfo = bytesNeeded;
+ else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, bytesNeeded)))
+ {
+ LPSTR *info;
+
+ if (dwFlags & CRYPT_DECODE_ALLOC_FLAG)
+ pvStructInfo = *(BYTE **)pvStructInfo;
+
+ info = pvStructInfo;
+ *info = (void *)((BYTE *)info + sizeof(*info));
+ ret = CRYPT_AsnDecodeOidInternal(pbEncoded, cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG,
+ pvStructInfo, &bytesNeeded, NULL);
+ if (!ret && (dwFlags & CRYPT_DECODE_ALLOC_FLAG))
+ CRYPT_FreeSpace(pDecodePara, info);
+ }
+ }
+ }
+ __EXCEPT_PAGE_FAULT
+ {
+ SetLastError(STATUS_ACCESS_VIOLATION);
+ ret = FALSE;
+ }
+ __ENDTRY
+ return ret;
+}
+
static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType,
LPCSTR lpszStructType)
{
@@ -6112,6 +6152,9 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType,
case LOWORD(CMS_SIGNER_INFO):
decodeFunc = CRYPT_AsnDecodeCMSSignerInfo;
break;
+ case LOWORD(X509_OBJECT_IDENTIFIER):
+ decodeFunc = CRYPT_AsnDecodeObjectIdentifier;
+ break;
}
}
else if (!strcmp(lpszStructType, szOID_CERT_EXTENSIONS))
@@ -6166,6 +6209,8 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType,
decodeFunc = CRYPT_AsnDecodePolicyQualifierUserNotice;
else if (!strcmp(lpszStructType, szOID_CTL))
decodeFunc = CRYPT_AsnDecodeCTL;
+ else if (!strcmp(lpszStructType, szOID_ECC_PUBLIC_KEY))
+ decodeFunc = CRYPT_AsnDecodeObjectIdentifier;
return decodeFunc;
}
diff --git a/include/wincrypt.h b/include/wincrypt.h
index 6e71fb902e..a7c24e7831 100644
--- a/include/wincrypt.h
+++ b/include/wincrypt.h
@@ -288,6 +288,11 @@ typedef struct _CERT_KEY_ATTRIBUTES_INFO {
PCERT_PRIVATE_KEY_VALIDITY pPrivateKeyUsagePeriod;
} CERT_KEY_ATTRIBUTES_INFO, *PCERT_KEY_ATTRIBUTES_INFO;
+typedef struct _CERT_ECC_SIGNATURE {
+ CRYPT_UINT_BLOB r;
+ CRYPT_UINT_BLOB s;
+} CERT_ECC_SIGNATURE, *PCERT_ECC_SIGNATURE;
+
/* byte 0 */
#define CERT_DIGITAL_SIGNATURE_KEY_USAGE 0x80
#define CERT_NON_REPUDIATION_KEY_USAGE 0x40
@@ -2878,6 +2883,12 @@ typedef struct _CTL_FIND_SUBJECT_PARA
#define szOID_X957 "1.2.840.10040"
#define szOID_X957_DSA "1.2.840.10040.4.1"
#define szOID_X957_SHA1DSA "1.2.840.10040.4.3"
+#define szOID_ECC_PUBLIC_KEY "1.2.840.10045.2.1"
+#define szOID_ECC_CURVE_P256 "1.2.840.10045.3.1.7"
+#define szOID_ECDSA_SPECIFIED "1.2.840.10045.4.3"
+#define szOID_ECDSA_SHA256 "1.2.840.10045.4.3.2"
+#define szOID_ECDSA_SHA384 "1.2.840.10045.4.3.3"
+#define szOID_ECDSA_SHA512 "1.2.840.10045.4.3.4"
#define szOID_DS "2.5"
#define szOID_DSALG "2.5.8"
#define szOID_DSALG_CRPT "2.5.8.1"
@@ -2919,6 +2930,8 @@ typedef struct _CTL_FIND_SUBJECT_PARA
#define szOID_OIWDIR_SIGN "1.3.14.7.2.3"
#define szOID_OIWDIR_md2 "1.3.14.7.2.2.1"
#define szOID_OIWDIR_md2RSA "1.3.14.7.2.3.1"
+#define szOID_ECC_CURVE_P384 "1.3.132.0.34"
+#define szOID_ECC_CURVE_P521 "1.3.132.0.35"
#define szOID_INFOSEC "2.16.840.1.101.2.1"
#define szOID_INFOSEC_sdnsSignature "2.16.840.1.101.2.1.1.1"
#define szOID_INFOSEC_mosaicSignature "2.16.840.1.101.2.1.1.2"
@@ -3223,6 +3236,7 @@ typedef struct _CTL_FIND_SUBJECT_PARA
#define X509_PKIX_POLICY_QUALIFIER_USERNOTICE ((LPCSTR)46)
#define X509_DH_PUBLICKEY X509_MULTI_BYTE_UINT
#define X509_DH_PARAMETERS ((LPCSTR)47)
+#define X509_ECC_SIGNATURE ((LPCSTR)47)
#define PKCS_ATTRIBUTES ((LPCSTR)48)
#define PKCS_SORTED_CTL ((LPCSTR)49)
#define X942_DH_PARAMETERS ((LPCSTR)50)
@@ -3240,6 +3254,7 @@ typedef struct _CTL_FIND_SUBJECT_PARA
#define CMC_ADD_EXTENSIONS ((LPCSTR)62)
#define CMC_ADD_ATTRIBUTES ((LPCSTR)63)
#define X509_CERTIFICATE_TEMPLATE ((LPCSTR)64)
+#define X509_OBJECT_IDENTIFIER ((LPCSTR)73)
#define PKCS7_SIGNER_INFO ((LPCSTR)500)
#define CMS_SIGNER_INFO ((LPCSTR)501)
June 20, 2018
Re: [PATCH] comctl32/imagelist: fix ImageList_Read/Write.
by Nikolay Sivov
On 06/16/2018 07:19 PM, Denis Malikov wrote:
> From: Denis Malikov <mdn40000(a)mail.ru>
> Date: Sat, 16 Jun 2018 16:35:45 +0700
> Subject: [PATCH] comctl32/imagelist: fix ImageList_Read/Write.
>
> Fix for versions x600 and x620 and pointer calculation for mixing image and mask bits.
>
> Tested on ReactOS 0.4.10 with *.reg files extracted from:
> - XP/2003 key HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify;
> - Vista/7 key HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify
>
> Signed-off-by: Denis Malikov <mdn40000(a)mail.ru>
> ---
> dlls/comctl32/imagelist.c | 59 +++++++++++++++++++++++++++--------------------
> 1 file changed, 34 insertions(+), 25 deletions(-)
>
> diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
> index a08d60752e..052d59f9e4 100644
> --- a/dlls/comctl32/imagelist.c
> +++ b/dlls/comctl32/imagelist.c
> @@ -59,7 +59,7 @@ struct _IMAGELIST
> INT cGrow; /* 0C: cGrow */
> INT cx; /* 10: cx */
> INT cy; /* 14: cy */
> - DWORD x4;
> + DWORD x4; /* hack for IL from stream. Keep version here */
> UINT flags; /* 1C: flags */
> COLORREF clrFg; /* 20: foreground color */
> COLORREF clrBk; /* 24: background color */
> @@ -83,6 +83,7 @@ struct _IMAGELIST
> };
The idea is to keep this structure binary compatible, that's why it
starts with a part with specific layout.
If you want to store source stream version, append a new field for that.
I actually like the idea of using
source stream format version to save the list back, it seems like a good
compromise.
>
> #define IMAGELIST_MAGIC 0x53414D58
> +#define IMAGELIST_VERSION 0x101
>
> /* Header used by ImageList_Read() and ImageList_Write() */
> #include "pshpack2.h"
> @@ -806,6 +807,7 @@ ImageList_Create (INT cx, INT cy, UINT flags,
> himl->clrFg = CLR_DEFAULT;
> himl->clrBk = CLR_NONE;
> himl->color_table_set = FALSE;
> + himl->x4 = 0;
>
> /* initialize overlay mask indices */
> for (nCount = 0; nCount < MAX_OVERLAYIMAGE; nCount++)
> @@ -2257,38 +2259,43 @@ HIMAGELIST WINAPI ImageList_Read(IStream *pstm)
> BITMAPINFO *image_info = (BITMAPINFO *)image_buf;
> BITMAPINFO *mask_info = (BITMAPINFO *)mask_buf;
> void *image_bits, *mask_bits = NULL;
> - ILHEAD ilHead;
> - HIMAGELIST himl;
> + ILHEAD ilHead;
> + HIMAGELIST himl;
> unsigned int i;
>
> TRACE("%p\n", pstm);
>
> if (FAILED(IStream_Read (pstm, &ilHead, sizeof(ILHEAD), NULL)))
> - return NULL;
> + return NULL;
> if (ilHead.usMagic != (('L' << 8) | 'I'))
> - return NULL;
> - if (ilHead.usVersion != 0x101) /* probably version? */
> - return NULL;
> + return NULL;
No need to reformat existing lines.
> + if (ilHead.usVersion != IMAGELIST_VERSION &&
> + ilHead.usVersion != 0x600 && /* XP/2003 version */
> + ilHead.usVersion != 0x620) /* Vista/7 version */
> + return NULL;
The question is if there's any format differences between 0x600 and
0x620, it was probably bumped for a reason.
>
> TRACE("cx %u, cy %u, flags 0x%04x, cCurImage %u, cMaxImage %u\n",
> ilHead.cx, ilHead.cy, ilHead.flags, ilHead.cCurImage, ilHead.cMaxImage);
>
> himl = ImageList_Create(ilHead.cx, ilHead.cy, ilHead.flags, ilHead.cCurImage, ilHead.cMaxImage);
> if (!himl)
> - return NULL;
> + return NULL;
> +
> + // keep version from stream
> + himl->x4 = ilHead.usVersion;
No cpp-style comments, please.
>
> @@ -3078,10 +3087,10 @@ BOOL WINAPI ImageList_Write(HIMAGELIST himl, IStream *pstm)
> TRACE("%p %p\n", himl, pstm);
>
> if (!is_valid(himl))
> - return FALSE;
> + return FALSE;
>
> ilHead.usMagic = (('L' << 8) | 'I');
> - ilHead.usVersion = 0x101;
> + ilHead.usVersion = himl->x4 > 0 ? himl->x4 : IMAGELIST_VERSION;
> ilHead.cCurImage = himl->cCurImage;
> ilHead.cMaxImage = himl->cMaxImage;
> ilHead.cGrow = himl->cGrow;
> @@ -3090,23 +3099,23 @@ BOOL WINAPI ImageList_Write(HIMAGELIST himl, IStream *pstm)
> ilHead.bkcolor = himl->clrBk;
> ilHead.flags = himl->flags;
> for(i = 0; i < 4; i++) {
> - ilHead.ovls[i] = himl->nOvlIdx[i];
> + ilHead.ovls[i] = himl->nOvlIdx[i];
> }
>
> TRACE("cx %u, cy %u, flags 0x04%x, cCurImage %u, cMaxImage %u\n",
> ilHead.cx, ilHead.cy, ilHead.flags, ilHead.cCurImage, ilHead.cMaxImage);
>
> if(FAILED(IStream_Write(pstm, &ilHead, sizeof(ILHEAD), NULL)))
> - return FALSE;
> + return FALSE;
>
> /* write the bitmap */
> if(!_write_bitmap(himl->hbmImage, pstm))
> - return FALSE;
> + return FALSE;
>
> /* write the mask if we have one */
> if(himl->flags & ILC_MASK) {
> - if(!_write_bitmap(himl->hbmMask, pstm))
> - return FALSE;
> + if(!_write_bitmap(himl->hbmMask, pstm))
> + return FALSE;
> }
Doesn't this write in old format, with mismatching version field?
June 20, 2018
[PATCH 3/3] crypt32: Implement decoding of X509_ECC_SIGNATURE.
by Nikolay Sivov
From: Michael Müller <michael(a)fds-team.de>
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/crypt32/decode.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c
index 4f11d0d60f..080feeca0a 100644
--- a/dlls/crypt32/decode.c
+++ b/dlls/crypt32/decode.c
@@ -6013,6 +6013,35 @@ static BOOL WINAPI CRYPT_AsnDecodeObjectIdentifier(DWORD dwCertEncodingType,
return ret;
}
+static BOOL WINAPI CRYPT_AsnDecodeEccSignature(DWORD dwCertEncodingType,
+ LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
+ CRYPT_DECODE_PARA *pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo)
+{
+ BOOL ret;
+ struct AsnDecodeSequenceItem items[] = {
+ { ASN_INTEGER, offsetof(CERT_ECC_SIGNATURE, r),
+ CRYPT_AsnDecodeUnsignedIntegerInternal, sizeof(CRYPT_UINT_BLOB), FALSE,
+ TRUE, offsetof(CERT_ECC_SIGNATURE, r.pbData), 0 },
+ { ASN_INTEGER, offsetof(CERT_ECC_SIGNATURE, s),
+ CRYPT_AsnDecodeUnsignedIntegerInternal, sizeof(CRYPT_UINT_BLOB), FALSE,
+ TRUE, offsetof(CERT_ECC_SIGNATURE, s.pbData), 0 },
+ };
+
+ __TRY
+ {
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
+ pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
+ pcbStructInfo, NULL, NULL);
+ }
+ __EXCEPT_PAGE_FAULT
+ {
+ SetLastError(STATUS_ACCESS_VIOLATION);
+ ret = FALSE;
+ }
+ __ENDTRY
+ return ret;
+}
+
static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType,
LPCSTR lpszStructType)
{
@@ -6155,6 +6184,9 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType,
case LOWORD(X509_OBJECT_IDENTIFIER):
decodeFunc = CRYPT_AsnDecodeObjectIdentifier;
break;
+ case LOWORD(X509_ECC_SIGNATURE):
+ decodeFunc = CRYPT_AsnDecodeEccSignature;
+ break;
}
}
else if (!strcmp(lpszStructType, szOID_CERT_EXTENSIONS))
--
2.17.1
June 20, 2018
[PATCH 2/3] crypt32: Implement decoding of X509_OBJECT_IDENTIFIER.
by Nikolay Sivov
From: Michael Müller <michael(a)fds-team.de>
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/crypt32/decode.c | 45 +++++++++++++++++++++++++++++++++++++++++++
include/wincrypt.h | 15 +++++++++++++++
2 files changed, 60 insertions(+)
diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c
index a61316016f..4f11d0d60f 100644
--- a/dlls/crypt32/decode.c
+++ b/dlls/crypt32/decode.c
@@ -5973,6 +5973,46 @@ BOOL CRYPT_AsnDecodePKCSEnvelopedData(const BYTE *pbEncoded, DWORD cbEncoded,
return ret;
}
+static BOOL WINAPI CRYPT_AsnDecodeObjectIdentifier(DWORD dwCertEncodingType,
+ LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags,
+ CRYPT_DECODE_PARA *pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo)
+{
+ DWORD bytesNeeded = 0;
+ BOOL ret;
+
+ __TRY
+ {
+ ret = CRYPT_AsnDecodeOidInternal(pbEncoded, cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG,
+ NULL, &bytesNeeded, NULL);
+ if (ret)
+ {
+ if (!pvStructInfo)
+ *pcbStructInfo = bytesNeeded;
+ else if ((ret = CRYPT_DecodeEnsureSpace(dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, bytesNeeded)))
+ {
+ LPSTR *info;
+
+ if (dwFlags & CRYPT_DECODE_ALLOC_FLAG)
+ pvStructInfo = *(BYTE **)pvStructInfo;
+
+ info = pvStructInfo;
+ *info = (void *)((BYTE *)info + sizeof(*info));
+ ret = CRYPT_AsnDecodeOidInternal(pbEncoded, cbEncoded, dwFlags & ~CRYPT_DECODE_ALLOC_FLAG,
+ pvStructInfo, &bytesNeeded, NULL);
+ if (!ret && (dwFlags & CRYPT_DECODE_ALLOC_FLAG))
+ CRYPT_FreeSpace(pDecodePara, info);
+ }
+ }
+ }
+ __EXCEPT_PAGE_FAULT
+ {
+ SetLastError(STATUS_ACCESS_VIOLATION);
+ ret = FALSE;
+ }
+ __ENDTRY
+ return ret;
+}
+
static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType,
LPCSTR lpszStructType)
{
@@ -6112,6 +6152,9 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType,
case LOWORD(CMS_SIGNER_INFO):
decodeFunc = CRYPT_AsnDecodeCMSSignerInfo;
break;
+ case LOWORD(X509_OBJECT_IDENTIFIER):
+ decodeFunc = CRYPT_AsnDecodeObjectIdentifier;
+ break;
}
}
else if (!strcmp(lpszStructType, szOID_CERT_EXTENSIONS))
@@ -6166,6 +6209,8 @@ static CryptDecodeObjectExFunc CRYPT_GetBuiltinDecoder(DWORD dwCertEncodingType,
decodeFunc = CRYPT_AsnDecodePolicyQualifierUserNotice;
else if (!strcmp(lpszStructType, szOID_CTL))
decodeFunc = CRYPT_AsnDecodeCTL;
+ else if (!strcmp(lpszStructType, szOID_ECC_PUBLIC_KEY))
+ decodeFunc = CRYPT_AsnDecodeObjectIdentifier;
return decodeFunc;
}
diff --git a/include/wincrypt.h b/include/wincrypt.h
index 6e71fb902e..a7c24e7831 100644
--- a/include/wincrypt.h
+++ b/include/wincrypt.h
@@ -288,6 +288,11 @@ typedef struct _CERT_KEY_ATTRIBUTES_INFO {
PCERT_PRIVATE_KEY_VALIDITY pPrivateKeyUsagePeriod;
} CERT_KEY_ATTRIBUTES_INFO, *PCERT_KEY_ATTRIBUTES_INFO;
+typedef struct _CERT_ECC_SIGNATURE {
+ CRYPT_UINT_BLOB r;
+ CRYPT_UINT_BLOB s;
+} CERT_ECC_SIGNATURE, *PCERT_ECC_SIGNATURE;
+
/* byte 0 */
#define CERT_DIGITAL_SIGNATURE_KEY_USAGE 0x80
#define CERT_NON_REPUDIATION_KEY_USAGE 0x40
@@ -2878,6 +2883,12 @@ typedef struct _CTL_FIND_SUBJECT_PARA
#define szOID_X957 "1.2.840.10040"
#define szOID_X957_DSA "1.2.840.10040.4.1"
#define szOID_X957_SHA1DSA "1.2.840.10040.4.3"
+#define szOID_ECC_PUBLIC_KEY "1.2.840.10045.2.1"
+#define szOID_ECC_CURVE_P256 "1.2.840.10045.3.1.7"
+#define szOID_ECDSA_SPECIFIED "1.2.840.10045.4.3"
+#define szOID_ECDSA_SHA256 "1.2.840.10045.4.3.2"
+#define szOID_ECDSA_SHA384 "1.2.840.10045.4.3.3"
+#define szOID_ECDSA_SHA512 "1.2.840.10045.4.3.4"
#define szOID_DS "2.5"
#define szOID_DSALG "2.5.8"
#define szOID_DSALG_CRPT "2.5.8.1"
@@ -2919,6 +2930,8 @@ typedef struct _CTL_FIND_SUBJECT_PARA
#define szOID_OIWDIR_SIGN "1.3.14.7.2.3"
#define szOID_OIWDIR_md2 "1.3.14.7.2.2.1"
#define szOID_OIWDIR_md2RSA "1.3.14.7.2.3.1"
+#define szOID_ECC_CURVE_P384 "1.3.132.0.34"
+#define szOID_ECC_CURVE_P521 "1.3.132.0.35"
#define szOID_INFOSEC "2.16.840.1.101.2.1"
#define szOID_INFOSEC_sdnsSignature "2.16.840.1.101.2.1.1.1"
#define szOID_INFOSEC_mosaicSignature "2.16.840.1.101.2.1.1.2"
@@ -3223,6 +3236,7 @@ typedef struct _CTL_FIND_SUBJECT_PARA
#define X509_PKIX_POLICY_QUALIFIER_USERNOTICE ((LPCSTR)46)
#define X509_DH_PUBLICKEY X509_MULTI_BYTE_UINT
#define X509_DH_PARAMETERS ((LPCSTR)47)
+#define X509_ECC_SIGNATURE ((LPCSTR)47)
#define PKCS_ATTRIBUTES ((LPCSTR)48)
#define PKCS_SORTED_CTL ((LPCSTR)49)
#define X942_DH_PARAMETERS ((LPCSTR)50)
@@ -3240,6 +3254,7 @@ typedef struct _CTL_FIND_SUBJECT_PARA
#define CMC_ADD_EXTENSIONS ((LPCSTR)62)
#define CMC_ADD_ATTRIBUTES ((LPCSTR)63)
#define X509_CERTIFICATE_TEMPLATE ((LPCSTR)64)
+#define X509_OBJECT_IDENTIFIER ((LPCSTR)73)
#define PKCS7_SIGNER_INFO ((LPCSTR)500)
#define CMS_SIGNER_INFO ((LPCSTR)501)
--
2.17.1
June 20, 2018
[PATCH 1/3] crypt32: Use ARRAY_SIZE macro.
by Nikolay Sivov
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/crypt32/cert.c | 3 +-
dlls/crypt32/chain.c | 20 ++---
dlls/crypt32/crypt32_private.h | 2 +
dlls/crypt32/decode.c | 89 +++++++++----------
dlls/crypt32/encode.c | 52 +++++------
dlls/crypt32/filestore.c | 3 +-
dlls/crypt32/msg.c | 2 +-
dlls/crypt32/object.c | 155 ++++++++++++---------------------
dlls/crypt32/oid.c | 9 +-
dlls/crypt32/regstore.c | 9 +-
dlls/crypt32/rootstore.c | 6 +-
dlls/crypt32/sip.c | 5 +-
dlls/crypt32/store.c | 7 +-
dlls/crypt32/str.c | 6 +-
14 files changed, 150 insertions(+), 218 deletions(-)
diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c
index a4b43ff155..83aac5d8f4 100644
--- a/dlls/crypt32/cert.c
+++ b/dlls/crypt32/cert.c
@@ -987,8 +987,7 @@ static BOOL container_matches_cert(PCCERT_CONTEXT pCert, LPCSTR container,
WCHAR containerW[MAX_PATH];
BOOL matches;
- MultiByteToWideChar(CP_ACP, 0, container, -1,
- containerW, sizeof(containerW) / sizeof(containerW[0]));
+ MultiByteToWideChar(CP_ACP, 0, container, -1, containerW, ARRAY_SIZE(containerW));
/* We make a copy of the CRYPT_KEY_PROV_INFO because the caller expects
* keyProvInfo->pwszContainerName to be NULL or a heap-allocated container
* name.
diff --git a/dlls/crypt32/chain.c b/dlls/crypt32/chain.c
index aab2e91583..dd3fc33db6 100644
--- a/dlls/crypt32/chain.c
+++ b/dlls/crypt32/chain.c
@@ -146,9 +146,9 @@ HCERTCHAINENGINE CRYPT_CreateChainEngine(HCERTSTORE root, DWORD system_store, co
worldStores[2] = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, system_store, myW);
worldStores[3] = CertOpenStore(CERT_STORE_PROV_SYSTEM_W, 0, 0, system_store, trustW);
- CRYPT_AddStoresToCollection(engine->hWorld, sizeof(worldStores) / sizeof(worldStores[0]), worldStores);
- CRYPT_AddStoresToCollection(engine->hWorld, config->cAdditionalStore, config->rghAdditionalStore);
- CRYPT_CloseStores(sizeof(worldStores) / sizeof(worldStores[0]), worldStores);
+ CRYPT_AddStoresToCollection(engine->hWorld, ARRAY_SIZE(worldStores), worldStores);
+ CRYPT_AddStoresToCollection(engine->hWorld, config->cAdditionalStore, config->rghAdditionalStore);
+ CRYPT_CloseStores(ARRAY_SIZE(worldStores), worldStores);
engine->dwFlags = config->dwFlags;
engine->dwUrlRetrievalTimeout = config->dwUrlRetrievalTimeout;
@@ -1688,11 +1688,9 @@ static LPCSTR filetime_to_str(const FILETIME *time)
if (!time) return "(null)";
- GetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, dateFmt,
- sizeof(dateFmt) / sizeof(dateFmt[0]));
+ GetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, dateFmt, ARRAY_SIZE(dateFmt));
FileTimeToSystemTime(time, &sysTime);
- GetDateFormatA(LOCALE_SYSTEM_DEFAULT, 0, &sysTime, dateFmt, date,
- sizeof(date) / sizeof(date[0]));
+ GetDateFormatA(LOCALE_SYSTEM_DEFAULT, 0, &sysTime, dateFmt, date, ARRAY_SIZE(date));
return wine_dbg_sprintf("%s", date);
}
@@ -3117,8 +3115,7 @@ static BOOL WINAPI verify_authenticode_policy(LPCSTR szPolicyOID,
};
/* Check whether the root is an MS test root */
- for (i = 0; !isMSTestRoot && i < sizeof(keyBlobs) / sizeof(keyBlobs[0]);
- i++)
+ for (i = 0; !isMSTestRoot && i < ARRAY_SIZE(keyBlobs); i++)
{
msPubKey.PublicKey.cbData = keyBlobs[i].cbData;
msPubKey.PublicKey.pbData = keyBlobs[i].pbData;
@@ -3408,7 +3405,7 @@ static BOOL match_dns_to_subject_dn(PCCERT_CONTEXT cert, LPCWSTR server_name)
end = dot ? dot : ptr + strlenW(ptr);
len = end - ptr;
- if (len >= sizeof(component) / sizeof(component[0]))
+ if (len >= ARRAY_SIZE(component))
{
WARN_(chain)("domain component %s too long\n",
debugstr_wn(ptr, len));
@@ -3690,8 +3687,7 @@ static BOOL WINAPI verify_ms_root_policy(LPCSTR szPolicyOID,
PCCERT_CONTEXT root =
rootChain->rgpElement[rootChain->cElement - 1]->pCertContext;
- for (i = 0; !isMSRoot && i < sizeof(keyBlobs) / sizeof(keyBlobs[0]);
- i++)
+ for (i = 0; !isMSRoot && i < ARRAY_SIZE(keyBlobs); i++)
{
msPubKey.PublicKey.cbData = keyBlobs[i].cbData;
msPubKey.PublicKey.pbData = keyBlobs[i].pbData;
diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h
index 8b1b003a12..dbf6dca411 100644
--- a/dlls/crypt32/crypt32_private.h
+++ b/dlls/crypt32/crypt32_private.h
@@ -21,6 +21,8 @@
#include "wine/list.h"
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
/* a few asn.1 tags we need */
#define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01)
#define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
diff --git a/dlls/crypt32/decode.c b/dlls/crypt32/decode.c
index 8b84388b12..a61316016f 100644
--- a/dlls/crypt32/decode.c
+++ b/dlls/crypt32/decode.c
@@ -890,7 +890,7 @@ static BOOL WINAPI CRYPT_AsnDecodeCertSignedContent(DWORD dwCertEncodingType,
if (dwFlags & CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG)
items[2].decodeFunc = CRYPT_AsnDecodeBitsInternal;
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL);
}
@@ -935,7 +935,7 @@ static BOOL CRYPT_AsnDecodeValidity(const BYTE *pbEncoded, DWORD cbEncoded,
CRYPT_AsnDecodeChoiceOfTimeInternal, sizeof(FILETIME), FALSE, FALSE, 0 },
};
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, NULL);
return ret;
@@ -1020,7 +1020,7 @@ static BOOL CRYPT_AsnDecodeCertInfo(DWORD dwCertEncodingType,
TRACE("%p, %d, %08x, %p, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, pvStructInfo, *pcbStructInfo);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo,
NULL, NULL);
if (ret && pvStructInfo)
@@ -1135,7 +1135,7 @@ static BOOL CRYPT_AsnDecodeCRLEntry(const BYTE *pbEncoded, DWORD cbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, entry,
*pcbStructInfo);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, entry, pcbStructInfo, pcbDecoded,
entry ? entry->SerialNumber.pbData : NULL);
if (ret && entry && !entry->SerialNumber.cbData)
@@ -1236,9 +1236,8 @@ static BOOL CRYPT_AsnDecodeCRLInfo(DWORD dwCertEncodingType,
TRACE("%p, %d, %08x, %p, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, pvStructInfo, *pcbStructInfo);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
- pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo,
- NULL, NULL);
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items), pbEncoded, cbEncoded, dwFlags,
+ pDecodePara, pvStructInfo, pcbStructInfo, NULL, NULL);
TRACE("Returning %d (%08x)\n", ret, GetLastError());
return ret;
@@ -1433,7 +1432,7 @@ static BOOL CRYPT_AsnDecodeExtension(const BYTE *pbEncoded, DWORD cbEncoded,
if (ext)
TRACE("ext->pszObjId is %p\n", ext->pszObjId);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, ext, pcbStructInfo,
pcbDecoded, ext ? ext->pszObjId : NULL);
if (ext)
@@ -1871,7 +1870,7 @@ static BOOL CRYPT_AsnDecodeRdnAttr(const BYTE *pbEncoded, DWORD cbEncoded,
if (attr)
TRACE("attr->pszObjId is %p\n", attr->pszObjId);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, attr, pcbStructInfo, pcbDecoded,
attr ? attr->pszObjId : NULL);
if (attr)
@@ -1968,7 +1967,7 @@ static BOOL CRYPT_AsnDecodeUnicodeRdnAttr(const BYTE *pbEncoded,
if (attr)
TRACE("attr->pszObjId is %p\n", attr->pszObjId);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, attr, pcbStructInfo, pcbDecoded,
attr ? attr->pszObjId : NULL);
if (attr)
@@ -2197,7 +2196,7 @@ static BOOL CRYPT_AsnDecodeCTLEntry(const BYTE *pbEncoded, DWORD cbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags, entry,
*pcbStructInfo);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, entry, pcbStructInfo,
pcbDecoded, entry ? entry->SubjectIdentifier.pbData : NULL);
return ret;
@@ -2300,7 +2299,7 @@ static BOOL WINAPI CRYPT_AsnDecodeCTL(DWORD dwCertEncodingType,
TRUE, TRUE, offsetof(CTL_INFO, rgExtension), 0 },
};
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL);
}
@@ -2330,7 +2329,7 @@ static BOOL CRYPT_AsnDecodeSMIMECapability(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, capability ? capability->pszObjId : NULL);
TRACE("returning %d\n", ret);
@@ -2460,7 +2459,7 @@ static BOOL CRYPT_AsnDecodeNoticeReference(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, pvStructInfo ? *pcbStructInfo : 0);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, NULL, &bytesNeeded, pcbDecoded,
NULL);
if (ret)
@@ -2496,10 +2495,8 @@ static BOOL CRYPT_AsnDecodeNoticeReference(const BYTE *pbEncoded,
*(PCERT_POLICY_QUALIFIER_NOTICE_REFERENCE *)pvStructInfo;
noticeRef->pszOrganization = (LPSTR)((LPBYTE)noticeRef +
sizeof(CERT_POLICY_QUALIFIER_NOTICE_REFERENCE));
- ret = CRYPT_AsnDecodeSequence(items,
- sizeof(items) / sizeof(items[0]), pbEncoded, cbEncoded, dwFlags,
- NULL, noticeRef, &bytesNeeded, pcbDecoded,
- noticeRef->pszOrganization);
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items), pbEncoded, cbEncoded, dwFlags,
+ NULL, noticeRef, &bytesNeeded, pcbDecoded, noticeRef->pszOrganization);
}
}
TRACE("returning %d\n", ret);
@@ -2653,7 +2650,7 @@ static BOOL CRYPT_AsnDecodePolicyQualifierUserNoticeInternal(
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, notice ? notice->pNoticeReference : NULL);
TRACE("returning %d\n", ret);
@@ -2748,7 +2745,7 @@ static BOOL CRYPT_AsnDecodePKCSAttributeInternal(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, attr ? attr->pszObjId : NULL);
TRACE("returning %d\n", ret);
@@ -2866,7 +2863,7 @@ static BOOL CRYPT_AsnDecodeAlgorithmId(const BYTE *pbEncoded, DWORD cbEncoded,
TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo, pcbDecoded);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, algo ? algo->pszObjId : NULL);
if (ret && pvStructInfo)
@@ -2893,7 +2890,7 @@ static BOOL CRYPT_AsnDecodePubKeyInfoInternal(const BYTE *pbEncoded,
};
PCERT_PUBLIC_KEY_INFO info = pvStructInfo;
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, info ? info->Algorithm.Parameters.pbData : NULL);
return ret;
@@ -3150,7 +3147,7 @@ static BOOL WINAPI CRYPT_AsnDecodeAuthorityKeyId(DWORD dwCertEncodingType,
offsetof(CERT_AUTHORITY_KEY_ID_INFO, CertSerialNumber.pbData), 0 },
};
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL);
}
@@ -3187,7 +3184,7 @@ static BOOL WINAPI CRYPT_AsnDecodeAuthorityKeyId2(DWORD dwCertEncodingType,
AuthorityCertSerialNumber.pbData), 0 },
};
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL);
}
@@ -3214,7 +3211,7 @@ static BOOL CRYPT_AsnDecodeAccessDescription(const BYTE *pbEncoded,
};
CERT_ACCESS_DESCRIPTION *descr = pvStructInfo;
- return CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ return CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, descr ? descr->pszAccessMethod : NULL);
}
@@ -3323,7 +3320,7 @@ static BOOL CRYPT_AsnDecodePKCSContentInfoInternal(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo, pcbDecoded);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, info ? info->pszObjId : NULL);
return ret;
@@ -3392,7 +3389,7 @@ BOOL CRYPT_AsnDecodePKCSDigestedData(const BYTE *pbEncoded, DWORD cbEncoded,
offsetof(CRYPT_DIGESTED_DATA, hash.pbData), 0 },
};
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, digestedData, pcbDigestedData,
NULL, NULL);
return ret;
@@ -3531,7 +3528,7 @@ static BOOL WINAPI CRYPT_AsnDecodeBasicConstraints(DWORD dwCertEncodingType,
offsetof(CERT_BASIC_CONSTRAINTS_INFO, rgSubtreesConstraint), 0 },
};
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL);
}
@@ -3560,7 +3557,7 @@ static BOOL WINAPI CRYPT_AsnDecodeBasicConstraints2(DWORD dwCertEncodingType,
sizeof(struct PATH_LEN_CONSTRAINT), TRUE, FALSE, 0, 0 },
};
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL);
}
@@ -3592,7 +3589,7 @@ static BOOL CRYPT_AsnDecodePolicyQualifier(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, pvStructInfo ? *pcbStructInfo : 0);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, qualifier ? qualifier->pszPolicyQualifierId : NULL);
return ret;
@@ -3637,7 +3634,7 @@ static BOOL CRYPT_AsnDecodeCertPolicy(const BYTE *pbEncoded, DWORD cbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, pvStructInfo ? *pcbStructInfo : 0);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, info ? info->pszPolicyIdentifier : NULL);
return ret;
@@ -3694,7 +3691,7 @@ static BOOL CRYPT_AsnDecodeCertPolicyMapping(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, pvStructInfo ? *pcbStructInfo : 0);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, mapping ? mapping->pszIssuerDomainPolicy : NULL);
return ret;
@@ -3851,7 +3848,7 @@ static BOOL WINAPI CRYPT_AsnDecodeCertPolicyConstraints(
TRUE, FALSE, 0, 0 },
};
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL);
}
@@ -3890,7 +3887,7 @@ static BOOL WINAPI CRYPT_AsnDecodeRsaPubKey(DWORD dwCertEncodingType,
struct DECODED_RSA_PUB_KEY *decodedKey = NULL;
DWORD size = 0;
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &decodedKey,
&size, NULL, NULL);
if (ret)
@@ -3998,7 +3995,7 @@ static BOOL WINAPI CRYPT_AsnDecodeRsaPrivKey(DWORD dwCertEncodingType,
struct DECODED_RSA_PRIV_KEY *decodedKey = NULL;
DWORD size = 0;
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, CRYPT_DECODE_ALLOC_FLAG, NULL, &decodedKey,
&size, NULL, NULL);
if (ret)
@@ -5242,7 +5239,7 @@ static BOOL CRYPT_AsnDecodeDistPoint(const BYTE *pbEncoded, DWORD cbEncoded,
CRL_DIST_POINT *point = pvStructInfo;
BOOL ret;
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, point ? point->DistPointName.u.FullName.rgAltEntry : NULL);
return ret;
@@ -5344,7 +5341,7 @@ static BOOL WINAPI CRYPT_AsnDecodeIssuingDistPoint(DWORD dwCertEncodingType,
fIndirectCRL), CRYPT_AsnDecodeBool, sizeof(BOOL), TRUE, FALSE, 0 },
};
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL);
}
@@ -5427,7 +5424,7 @@ static BOOL CRYPT_AsnDecodeSubtree(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo, pcbDecoded);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, subtree ? subtree->Base.u.pwszURL : NULL);
if (pcbDecoded)
@@ -5508,7 +5505,7 @@ static BOOL WINAPI CRYPT_AsnDecodeNameConstraints(DWORD dwCertEncodingType,
offsetof(CERT_NAME_CONSTRAINTS_INFO, rgExcludedSubtree), 0 },
};
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo,
pcbStructInfo, NULL, NULL);
}
@@ -5538,7 +5535,7 @@ static BOOL CRYPT_AsnDecodeIssuerSerialNumber(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo, pcbDecoded);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, issuerSerial ? issuerSerial->Issuer.pbData : NULL);
if (ret && issuerSerial && !issuerSerial->SerialNumber.cbData)
@@ -5585,7 +5582,7 @@ static BOOL CRYPT_AsnDecodePKCSSignerInfoInternal(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, info ? info->Issuer.pbData : NULL);
return ret;
@@ -5751,7 +5748,7 @@ static BOOL CRYPT_AsnDecodeCMSSignerInfoInternal(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, info ? info->SignerId.u.KeyId.pbData : NULL);
return ret;
@@ -5851,7 +5848,7 @@ BOOL CRYPT_AsnDecodeCMSSignedInfo(const BYTE *pbEncoded, DWORD cbEncoded,
TRACE("%p, %d, %08x, %p, %p, %p\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, signedInfo, pcbSignedInfo);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, signedInfo, pcbSignedInfo,
NULL, NULL);
TRACE("returning %d\n", ret);
@@ -5884,7 +5881,7 @@ static BOOL CRYPT_AsnDecodeRecipientInfo(const BYTE *pbEncoded, DWORD cbEncoded,
TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo, pcbDecoded);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, info ? info->RecipientId.u.IssuerSerialNumber.Issuer.pbData :
NULL);
@@ -5941,7 +5938,7 @@ static BOOL CRYPT_AsnDecodeEncryptedContentInfo(const BYTE *pbEncoded,
TRACE("%p, %d, %08x, %p, %d, %p\n", pbEncoded, cbEncoded, dwFlags,
pvStructInfo, *pcbStructInfo, pcbDecoded);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, NULL, pvStructInfo, pcbStructInfo,
pcbDecoded, info ? info->contentType : NULL);
TRACE("returning %d\n", ret);
@@ -5969,7 +5966,7 @@ BOOL CRYPT_AsnDecodePKCSEnvelopedData(const BYTE *pbEncoded, DWORD cbEncoded,
TRACE("%p, %d, %08x, %p, %p, %p\n", pbEncoded, cbEncoded, dwFlags,
pDecodePara, envelopedData, pcbEnvelopedData);
- ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items),
pbEncoded, cbEncoded, dwFlags, pDecodePara, envelopedData,
pcbEnvelopedData, NULL, NULL);
TRACE("returning %d\n", ret);
diff --git a/dlls/crypt32/encode.c b/dlls/crypt32/encode.c
index 6f9f595f4f..62d2bc91f7 100644
--- a/dlls/crypt32/encode.c
+++ b/dlls/crypt32/encode.c
@@ -372,7 +372,7 @@ static BOOL WINAPI CRYPT_AsnEncodeValidity(DWORD dwCertEncodingType,
};
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
+ ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded);
return ret;
}
@@ -400,7 +400,7 @@ static BOOL WINAPI CRYPT_AsnEncodeAlgorithmIdWithNullParams(
else
items[1].pvStructInfo = &nullBlob;
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
+ ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded);
return ret;
}
@@ -417,7 +417,7 @@ static BOOL WINAPI CRYPT_AsnEncodeAlgorithmId(DWORD dwCertEncodingType,
};
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
+ ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded);
return ret;
}
@@ -439,7 +439,7 @@ static BOOL WINAPI CRYPT_AsnEncodePubKeyInfo(DWORD dwCertEncodingType,
TRACE("Encoding public key with OID %s\n",
debugstr_a(info->Algorithm.pszObjId));
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
+ ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded);
}
__EXCEPT_PAGE_FAULT
@@ -469,7 +469,7 @@ static BOOL WINAPI CRYPT_AsnEncodeCert(DWORD dwCertEncodingType,
if (dwFlags & CRYPT_ENCODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG)
items[2].encodeFunc = CRYPT_AsnEncodeBits;
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
+ ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded);
}
__EXCEPT_PAGE_FAULT
@@ -495,7 +495,7 @@ BOOL WINAPI CRYPT_AsnEncodePubKeyInfoNoNull(DWORD dwCertEncodingType,
TRACE("Encoding public key with OID %s\n",
debugstr_a(info->Algorithm.pszObjId));
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
+ ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded);
return ret;
}
@@ -1530,7 +1530,7 @@ static BOOL CRYPT_AsnEncodeCTLEntry(const CTL_ENTRY *entry,
BOOL ret;
ret = CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items,
- sizeof(items) / sizeof(items[0]), 0, NULL, pbEncoded, pcbEncoded);
+ ARRAY_SIZE(items), 0, NULL, pbEncoded, pcbEncoded);
return ret;
}
@@ -1679,7 +1679,7 @@ static BOOL CRYPT_AsnEncodeSMIMECapability(DWORD dwCertEncodingType,
};
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
+ ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded);
}
}
@@ -1822,7 +1822,7 @@ static BOOL WINAPI CRYPT_AsnEncodeNoticeReference(DWORD dwCertEncodingType,
};
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
+ ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded);
return ret;
}
@@ -1887,7 +1887,7 @@ static BOOL WINAPI CRYPT_AsnEncodePKCSAttribute(DWORD dwCertEncodingType,
};
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
+ ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded,
pcbEncoded);
}
}
@@ -1960,8 +1960,7 @@ BOOL CRYPT_AsnEncodePKCSDigestedData(const CRYPT_DIGESTED_DATA *digestedData,
{ &digestedData->hash, CRYPT_AsnEncodeOctets, 0 },
};
- return CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items,
- sizeof(items) / sizeof(items[0]), 0, NULL, pvData, pcbData);
+ return CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items, ARRAY_SIZE(items), 0, NULL, pvData, pcbData);
}
static BOOL WINAPI CRYPT_AsnEncodePKCSContentInfo(DWORD dwCertEncodingType,
@@ -2708,8 +2707,7 @@ static BOOL CRYPT_AsnEncodeAccessDescription(
SetLastError(E_INVALIDARG);
return FALSE;
}
- return CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items,
- sizeof(items) / sizeof(items[0]), 0, NULL, pbEncoded, pcbEncoded);
+ return CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items, ARRAY_SIZE(items), 0, NULL, pbEncoded, pcbEncoded);
}
static BOOL WINAPI CRYPT_AsnEncodeAuthorityInfoAccess(DWORD dwCertEncodingType,
@@ -2877,8 +2875,7 @@ static BOOL WINAPI CRYPT_AsnEncodeCertPolicyQualifiers(DWORD dwCertEncodingType,
items[0].pvStructInfo =
info->rgPolicyQualifier[i].pszPolicyQualifierId;
items[1].pvStructInfo = &info->rgPolicyQualifier[i].Qualifier;
- ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items),
dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL, NULL, &size);
if (ret)
bytesNeeded += size;
@@ -2909,8 +2906,7 @@ static BOOL WINAPI CRYPT_AsnEncodeCertPolicyQualifiers(DWORD dwCertEncodingType,
items[1].pvStructInfo =
&info->rgPolicyQualifier[i].Qualifier;
size = bytesNeeded;
- ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]),
+ ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items),
dwFlags & ~CRYPT_ENCODE_ALLOC_FLAG, NULL, out, &size);
if (ret)
{
@@ -2942,8 +2938,7 @@ static BOOL CRYPT_AsnEncodeCertPolicy(DWORD dwCertEncodingType,
SetLastError(E_INVALIDARG);
return FALSE;
}
- ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]), dwFlags, NULL, pbEncoded, pcbEncoded);
+ ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items), dwFlags, NULL, pbEncoded, pcbEncoded);
return ret;
}
@@ -3026,8 +3021,7 @@ static BOOL CRYPT_AsnEncodeCertPolicyMapping(DWORD dwCertEncodingType,
SetLastError(E_INVALIDARG);
return FALSE;
}
- return CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]), dwFlags, NULL, pbEncoded, pcbEncoded);
+ return CRYPT_AsnEncodeSequence(dwCertEncodingType, items, ARRAY_SIZE(items), dwFlags, NULL, pbEncoded, pcbEncoded);
}
static BOOL WINAPI CRYPT_AsnEncodeCertPolicyMappings(DWORD dwCertEncodingType,
@@ -3169,8 +3163,7 @@ static BOOL WINAPI CRYPT_AsnEncodeRsaPubKey(DWORD dwCertEncodingType,
};
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
- pcbEncoded);
+ ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded, pcbEncoded);
}
}
__EXCEPT_PAGE_FAULT
@@ -4151,8 +4144,7 @@ static BOOL WINAPI CRYPT_AsnEncodeIssuerSerialNumber(
};
ret = CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
- pcbEncoded);
+ ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded, pcbEncoded);
return ret;
}
@@ -4402,8 +4394,7 @@ static BOOL WINAPI CRYPT_AsnEncodeRecipientInfo(DWORD dwCertEncodingType,
};
return CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
- pcbEncoded);
+ ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded, pcbEncoded);
}
static BOOL WINAPI CRYPT_AsnEncodeEncryptedContentInfo(DWORD dwCertEncodingType,
@@ -4421,8 +4412,7 @@ static BOOL WINAPI CRYPT_AsnEncodeEncryptedContentInfo(DWORD dwCertEncodingType,
};
return CRYPT_AsnEncodeSequence(dwCertEncodingType, items,
- sizeof(items) / sizeof(items[0]), dwFlags, pEncodePara, pbEncoded,
- pcbEncoded);
+ ARRAY_SIZE(items), dwFlags, pEncodePara, pbEncoded, pcbEncoded);
}
BOOL CRYPT_AsnEncodePKCSEnvelopedData(const CRYPT_ENVELOPED_DATA *envelopedData,
@@ -4439,7 +4429,7 @@ BOOL CRYPT_AsnEncodePKCSEnvelopedData(const CRYPT_ENVELOPED_DATA *envelopedData,
};
return CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items,
- sizeof(items) / sizeof(items[0]), 0, NULL, pvData, pcbData);
+ ARRAY_SIZE(items), 0, NULL, pvData, pcbData);
}
static CryptEncodeObjectExFunc CRYPT_GetBuiltinEncoder(DWORD dwCertEncodingType,
diff --git a/dlls/crypt32/filestore.c b/dlls/crypt32/filestore.c
index 0f7d8d5150..9c211e14b1 100644
--- a/dlls/crypt32/filestore.c
+++ b/dlls/crypt32/filestore.c
@@ -231,8 +231,7 @@ static WINECRYPT_CERTSTORE *CRYPT_CreateFileStore(DWORD dwFlags,
info->type = type;
info->dirty = FALSE;
provInfo.cbSize = sizeof(provInfo);
- provInfo.cStoreProvFunc = sizeof(fileProvFuncs) /
- sizeof(fileProvFuncs[0]);
+ provInfo.cStoreProvFunc = ARRAY_SIZE(fileProvFuncs);
provInfo.rgpvStoreProvFunc = fileProvFuncs;
provInfo.hStoreProv = info;
store = CRYPT_ProvCreateStore(dwFlags, memStore, &provInfo);
diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index fd43a7baeb..005fbf2c1f 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -175,7 +175,7 @@ static BOOL CRYPT_EncodeDataContentInfoHeader(const CDataEncodeMsg *msg,
};
ret = CRYPT_AsnEncodeSequence(X509_ASN_ENCODING, items,
- sizeof(items) / sizeof(items[0]), CRYPT_ENCODE_ALLOC_FLAG, NULL,
+ ARRAY_SIZE(items), CRYPT_ENCODE_ALLOC_FLAG, NULL,
(LPBYTE)&header->pbData, &header->cbData);
if (ret)
{
diff --git a/dlls/crypt32/object.c b/dlls/crypt32/object.c
index 0320cfda1b..3dc28af0e9 100644
--- a/dlls/crypt32/object.c
+++ b/dlls/crypt32/object.c
@@ -929,8 +929,7 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType,
WCHAR infoNotAvailable[MAX_STRING_RESOURCE_LEN];
DWORD bytesNeeded = sizeof(WCHAR);
- LoadStringW(hInstance, IDS_INFO_NOT_AVAILABLE, infoNotAvailable,
- sizeof(infoNotAvailable) / sizeof(infoNotAvailable[0]));
+ LoadStringW(hInstance, IDS_INFO_NOT_AVAILABLE, infoNotAvailable, ARRAY_SIZE(infoNotAvailable));
if (!bits->cbData || bits->cbData > 2)
{
bytesNeeded += strlenW(infoNotAvailable) * sizeof(WCHAR);
@@ -959,26 +958,18 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType,
if (!stringsLoaded)
{
- for (i = 0;
- i < sizeof(keyUsageByte0Map) / sizeof(keyUsageByte0Map[0]);
- i++)
- LoadStringW(hInstance, keyUsageByte0Map[i].id,
- keyUsageByte0Map[i].str, MAX_STRING_RESOURCE_LEN);
- for (i = 0;
- i < sizeof(keyUsageByte1Map) / sizeof(keyUsageByte1Map[0]);
- i++)
- LoadStringW(hInstance, keyUsageByte1Map[i].id,
- keyUsageByte1Map[i].str, MAX_STRING_RESOURCE_LEN);
+ for (i = 0; i < ARRAY_SIZE(keyUsageByte0Map); i++)
+ LoadStringW(hInstance, keyUsageByte0Map[i].id, keyUsageByte0Map[i].str, MAX_STRING_RESOURCE_LEN);
+ for (i = 0; i < ARRAY_SIZE(keyUsageByte1Map); i++)
+ LoadStringW(hInstance, keyUsageByte1Map[i].id, keyUsageByte1Map[i].str, MAX_STRING_RESOURCE_LEN);
stringsLoaded = TRUE;
}
- CRYPT_FormatBits(bits->pbData[0], keyUsageByte0Map,
- sizeof(keyUsageByte0Map) / sizeof(keyUsageByte0Map[0]),
- NULL, &bitStringLen, &first);
+ CRYPT_FormatBits(bits->pbData[0], keyUsageByte0Map, ARRAY_SIZE(keyUsageByte0Map),
+ NULL, &bitStringLen, &first);
bytesNeeded += bitStringLen;
if (bits->cbData == 2)
{
- CRYPT_FormatBits(bits->pbData[1], keyUsageByte1Map,
- sizeof(keyUsageByte1Map) / sizeof(keyUsageByte1Map[0]),
+ CRYPT_FormatBits(bits->pbData[1], keyUsageByte1Map, ARRAY_SIZE(keyUsageByte1Map),
NULL, &bitStringLen, &first);
bytesNeeded += bitStringLen;
}
@@ -1000,15 +991,13 @@ static BOOL WINAPI CRYPT_FormatKeyUsage(DWORD dwCertEncodingType,
bitStringLen = bytesNeeded;
first = TRUE;
- CRYPT_FormatBits(bits->pbData[0], keyUsageByte0Map,
- sizeof(keyUsageByte0Map) / sizeof(keyUsageByte0Map[0]),
+ CRYPT_FormatBits(bits->pbData[0], keyUsageByte0Map, ARRAY_SIZE(keyUsageByte0Map),
str, &bitStringLen, &first);
str += bitStringLen / sizeof(WCHAR) - 1;
if (bits->cbData == 2)
{
bitStringLen = bytesNeeded;
- CRYPT_FormatBits(bits->pbData[1], keyUsageByte1Map,
- sizeof(keyUsageByte1Map) / sizeof(keyUsageByte1Map[0]),
+ CRYPT_FormatBits(bits->pbData[1], keyUsageByte1Map, ARRAY_SIZE(keyUsageByte1Map),
str, &bitStringLen, &first);
str += bitStringLen / sizeof(WCHAR) - 1;
}
@@ -1070,15 +1059,10 @@ static BOOL WINAPI CRYPT_FormatBasicConstraints2(DWORD dwCertEncodingType,
if (!stringsLoaded)
{
- LoadStringW(hInstance, IDS_SUBJECT_TYPE, subjectTypeHeader,
- sizeof(subjectTypeHeader) / sizeof(subjectTypeHeader[0]));
- LoadStringW(hInstance, IDS_SUBJECT_TYPE_CA, subjectTypeCA,
- sizeof(subjectTypeCA) / sizeof(subjectTypeCA[0]));
- LoadStringW(hInstance, IDS_SUBJECT_TYPE_END_CERT,
- subjectTypeEndCert,
- sizeof(subjectTypeEndCert) / sizeof(subjectTypeEndCert[0]));
- LoadStringW(hInstance, IDS_PATH_LENGTH, pathLengthHeader,
- sizeof(pathLengthHeader) / sizeof(pathLengthHeader[0]));
+ LoadStringW(hInstance, IDS_SUBJECT_TYPE, subjectTypeHeader, ARRAY_SIZE(subjectTypeHeader));
+ LoadStringW(hInstance, IDS_SUBJECT_TYPE_CA, subjectTypeCA, ARRAY_SIZE(subjectTypeCA));
+ LoadStringW(hInstance, IDS_SUBJECT_TYPE_END_CERT, subjectTypeEndCert, ARRAY_SIZE(subjectTypeEndCert));
+ LoadStringW(hInstance, IDS_PATH_LENGTH, pathLengthHeader, ARRAY_SIZE(pathLengthHeader));
stringsLoaded = TRUE;
}
bytesNeeded += strlenW(subjectTypeHeader) * sizeof(WCHAR);
@@ -1092,8 +1076,7 @@ static BOOL WINAPI CRYPT_FormatBasicConstraints2(DWORD dwCertEncodingType,
if (info->fPathLenConstraint)
sprintfW(pathLength, pathFmt, info->dwPathLenConstraint);
else
- LoadStringW(hInstance, IDS_PATH_LENGTH_NONE, pathLength,
- sizeof(pathLength) / sizeof(pathLength[0]));
+ LoadStringW(hInstance, IDS_PATH_LENGTH_NONE, pathLength, ARRAY_SIZE(pathLength));
bytesNeeded += strlenW(pathLength) * sizeof(WCHAR);
if (!pbFormat)
*pcbFormat = bytesNeeded;
@@ -1130,7 +1113,7 @@ static BOOL CRYPT_FormatHexStringWithPrefix(const CRYPT_DATA_BLOB *blob, int id,
DWORD bytesNeeded;
BOOL ret;
- LoadStringW(hInstance, id, buf, sizeof(buf) / sizeof(buf[0]));
+ LoadStringW(hInstance, id, buf, ARRAY_SIZE(buf));
CRYPT_FormatHexString(X509_ASN_ENCODING, 0, 0, NULL, NULL,
blob->pbData, blob->cbData, NULL, &bytesNeeded);
bytesNeeded += strlenW(buf) * sizeof(WCHAR);
@@ -1189,14 +1172,12 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
switch (entry->dwAltNameChoice)
{
case CERT_ALT_NAME_RFC822_NAME:
- LoadStringW(hInstance, IDS_ALT_NAME_RFC822_NAME, buf,
- sizeof(buf) / sizeof(buf[0]));
+ LoadStringW(hInstance, IDS_ALT_NAME_RFC822_NAME, buf, ARRAY_SIZE(buf));
bytesNeeded += strlenW(entry->u.pwszRfc822Name) * sizeof(WCHAR);
ret = TRUE;
break;
case CERT_ALT_NAME_DNS_NAME:
- LoadStringW(hInstance, IDS_ALT_NAME_DNS_NAME, buf,
- sizeof(buf) / sizeof(buf[0]));
+ LoadStringW(hInstance, IDS_ALT_NAME_DNS_NAME, buf, ARRAY_SIZE(buf));
bytesNeeded += strlenW(entry->u.pwszDNSName) * sizeof(WCHAR);
ret = TRUE;
break;
@@ -1208,8 +1189,7 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
strType |= CERT_NAME_STR_CRLF_FLAG;
directoryNameLen = cert_name_to_str_with_indent(X509_ASN_ENCODING,
indentLevel + 1, &entry->u.DirectoryName, strType, NULL, 0);
- LoadStringW(hInstance, IDS_ALT_NAME_DIRECTORY_NAME, buf,
- sizeof(buf) / sizeof(buf[0]));
+ LoadStringW(hInstance, IDS_ALT_NAME_DIRECTORY_NAME, buf, ARRAY_SIZE(buf));
bytesNeeded += (directoryNameLen - 1) * sizeof(WCHAR);
if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
bytesNeeded += strlenW(colonCrlf) * sizeof(WCHAR);
@@ -1219,8 +1199,7 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
break;
}
case CERT_ALT_NAME_URL:
- LoadStringW(hInstance, IDS_ALT_NAME_URL, buf,
- sizeof(buf) / sizeof(buf[0]));
+ LoadStringW(hInstance, IDS_ALT_NAME_URL, buf, ARRAY_SIZE(buf));
bytesNeeded += strlenW(entry->u.pwszURL) * sizeof(WCHAR);
ret = TRUE;
break;
@@ -1232,14 +1211,12 @@ static BOOL CRYPT_FormatAltNameEntry(DWORD dwFormatStrType, DWORD indentLevel,
static const WCHAR ipAddrFmt[] = { '%','d','.','%','d','.','%','d',
'.','%','d',0 };
- LoadStringW(hInstance, IDS_ALT_NAME_IP_ADDRESS, buf,
- sizeof(buf) / sizeof(buf[0]));
+ LoadStringW(hInstance, IDS_ALT_NAME_IP_ADDRESS, buf, ARRAY_SIZE(buf));
if (entry->u.IPAddress.cbData == 8)
{
if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
{
- LoadStringW(hInstance, IDS_ALT_NAME_MASK, mask,
- sizeof(mask) / sizeof(mask[0]));
+ LoadStringW(hInstance, IDS_ALT_NAME_MASK, mask, ARRAY_SIZE(mask));
bytesNeeded += strlenW(mask) * sizeof(WCHAR);
sprintfW(ipAddrBuf, ipAddrFmt,
entry->u.IPAddress.pbData[0],
@@ -1448,7 +1425,7 @@ static BOOL CRYPT_FormatCertIssuer(DWORD dwFormatStrType,
LPCWSTR sep;
BOOL ret;
- LoadStringW(hInstance, IDS_CERT_ISSUER, buf, sizeof(buf) / sizeof(buf[0]));
+ LoadStringW(hInstance, IDS_CERT_ISSUER, buf, ARRAY_SIZE(buf));
ret = CRYPT_FormatAltNameInfo(dwFormatStrType, 1, issuer, NULL,
&bytesNeeded);
bytesNeeded += strlenW(buf) * sizeof(WCHAR);
@@ -1652,8 +1629,7 @@ static BOOL WINAPI CRYPT_FormatAuthorityInfoAccess(DWORD dwCertEncodingType,
{
WCHAR infoNotAvailable[MAX_STRING_RESOURCE_LEN];
- LoadStringW(hInstance, IDS_INFO_NOT_AVAILABLE, infoNotAvailable,
- sizeof(infoNotAvailable) / sizeof(infoNotAvailable[0]));
+ LoadStringW(hInstance, IDS_INFO_NOT_AVAILABLE, infoNotAvailable, ARRAY_SIZE(infoNotAvailable));
bytesNeeded += strlenW(infoNotAvailable) * sizeof(WCHAR);
if (!pbFormat)
*pcbFormat = bytesNeeded;
@@ -1680,18 +1656,12 @@ static BOOL WINAPI CRYPT_FormatAuthorityInfoAccess(DWORD dwCertEncodingType,
if (!stringsLoaded)
{
- LoadStringW(hInstance, IDS_AIA, aia,
- sizeof(aia) / sizeof(aia[0]));
- LoadStringW(hInstance, IDS_ACCESS_METHOD, accessMethod,
- sizeof(accessMethod) / sizeof(accessMethod[0]));
- LoadStringW(hInstance, IDS_ACCESS_METHOD_OCSP, ocsp,
- sizeof(ocsp) / sizeof(ocsp[0]));
- LoadStringW(hInstance, IDS_ACCESS_METHOD_CA_ISSUERS, caIssuers,
- sizeof(caIssuers) / sizeof(caIssuers[0]));
- LoadStringW(hInstance, IDS_ACCESS_METHOD_UNKNOWN, unknown,
- sizeof(unknown) / sizeof(unknown[0]));
- LoadStringW(hInstance, IDS_ACCESS_LOCATION, accessLocation,
- sizeof(accessLocation) / sizeof(accessLocation[0]));
+ LoadStringW(hInstance, IDS_AIA, aia, ARRAY_SIZE(aia));
+ LoadStringW(hInstance, IDS_ACCESS_METHOD, accessMethod, ARRAY_SIZE(accessMethod));
+ LoadStringW(hInstance, IDS_ACCESS_METHOD_OCSP, ocsp, ARRAY_SIZE(ocsp));
+ LoadStringW(hInstance, IDS_ACCESS_METHOD_CA_ISSUERS, caIssuers, ARRAY_SIZE(caIssuers));
+ LoadStringW(hInstance, IDS_ACCESS_METHOD_UNKNOWN, unknown, ARRAY_SIZE(unknown));
+ LoadStringW(hInstance, IDS_ACCESS_LOCATION, accessLocation, ARRAY_SIZE(accessLocation));
stringsLoaded = TRUE;
}
if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
@@ -1879,7 +1849,7 @@ static BOOL CRYPT_FormatReason(DWORD dwFormatStrType,
if (!stringsLoaded)
{
- for (i = 0; i < sizeof(reason_map) / sizeof(reason_map[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(reason_map); i++)
LoadStringW(hInstance, reason_map[i].id, reason_map[i].reason,
MAX_STRING_RESOURCE_LEN);
stringsLoaded = TRUE;
@@ -1887,7 +1857,7 @@ static BOOL CRYPT_FormatReason(DWORD dwFormatStrType,
/* No need to check reasonFlags->cbData, we already know it's positive.
* Ignore any other bytes, as they're for undefined bits.
*/
- for (i = 0; i < sizeof(reason_map) / sizeof(reason_map[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(reason_map); i++)
{
if (reasonFlags->pbData[0] & reason_map[i].reasonBit)
{
@@ -1909,14 +1879,13 @@ static BOOL CRYPT_FormatReason(DWORD dwFormatStrType,
else
{
*pcbStr = bytesNeeded;
- for (i = 0; i < sizeof(reason_map) / sizeof(reason_map[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(reason_map); i++)
{
if (reasonFlags->pbData[0] & reason_map[i].reasonBit)
{
strcpyW(str, reason_map[i].reason);
str += strlenW(reason_map[i].reason);
- if (i < sizeof(reason_map) / sizeof(reason_map[0]) - 1 &&
- numReasons)
+ if (i < ARRAY_SIZE(reason_map) - 1 && numReasons)
{
strcpyW(str, sep);
str += strlenW(sep);
@@ -1963,18 +1932,12 @@ static BOOL WINAPI CRYPT_FormatCRLDistPoints(DWORD dwCertEncodingType,
if (!stringsLoaded)
{
- LoadStringW(hInstance, IDS_CRL_DIST_POINT, crlDistPoint,
- sizeof(crlDistPoint) / sizeof(crlDistPoint[0]));
- LoadStringW(hInstance, IDS_CRL_DIST_POINT_NAME, distPointName,
- sizeof(distPointName) / sizeof(distPointName[0]));
- LoadStringW(hInstance, IDS_CRL_DIST_POINT_FULL_NAME, fullName,
- sizeof(fullName) / sizeof(fullName[0]));
- LoadStringW(hInstance, IDS_CRL_DIST_POINT_RDN_NAME, rdnName,
- sizeof(rdnName) / sizeof(rdnName[0]));
- LoadStringW(hInstance, IDS_CRL_DIST_POINT_REASON, reason,
- sizeof(reason) / sizeof(reason[0]));
- LoadStringW(hInstance, IDS_CRL_DIST_POINT_ISSUER, issuer,
- sizeof(issuer) / sizeof(issuer[0]));
+ LoadStringW(hInstance, IDS_CRL_DIST_POINT, crlDistPoint, ARRAY_SIZE(crlDistPoint));
+ LoadStringW(hInstance, IDS_CRL_DIST_POINT_NAME, distPointName, ARRAY_SIZE(distPointName));
+ LoadStringW(hInstance, IDS_CRL_DIST_POINT_FULL_NAME, fullName, ARRAY_SIZE(fullName));
+ LoadStringW(hInstance, IDS_CRL_DIST_POINT_RDN_NAME, rdnName, ARRAY_SIZE(rdnName));
+ LoadStringW(hInstance, IDS_CRL_DIST_POINT_REASON, reason, ARRAY_SIZE(reason));
+ LoadStringW(hInstance, IDS_CRL_DIST_POINT_ISSUER, issuer, ARRAY_SIZE(issuer));
stringsLoaded = TRUE;
}
if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
@@ -2050,8 +2013,7 @@ static BOOL WINAPI CRYPT_FormatCRLDistPoints(DWORD dwCertEncodingType,
{
WCHAR infoNotAvailable[MAX_STRING_RESOURCE_LEN];
- LoadStringW(hInstance, IDS_INFO_NOT_AVAILABLE, infoNotAvailable,
- sizeof(infoNotAvailable) / sizeof(infoNotAvailable[0]));
+ LoadStringW(hInstance, IDS_INFO_NOT_AVAILABLE, infoNotAvailable, ARRAY_SIZE(infoNotAvailable));
bytesNeeded += strlenW(infoNotAvailable) * sizeof(WCHAR);
if (!pbFormat)
*pcbFormat = bytesNeeded;
@@ -2202,8 +2164,7 @@ static BOOL WINAPI CRYPT_FormatEnhancedKeyUsage(DWORD dwCertEncodingType,
sepLen = strlenW(commaSpace) * sizeof(WCHAR);
}
- LoadStringW(hInstance, IDS_USAGE_UNKNOWN, unknown,
- sizeof(unknown) / sizeof(unknown[0]));
+ LoadStringW(hInstance, IDS_USAGE_UNKNOWN, unknown, ARRAY_SIZE(unknown));
for (i = 0; i < usage->cUsageIdentifier; i++)
{
PCCRYPT_OID_INFO info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY,
@@ -2299,8 +2260,7 @@ static BOOL WINAPI CRYPT_FormatNetscapeCertType(DWORD dwCertEncodingType,
WCHAR infoNotAvailable[MAX_STRING_RESOURCE_LEN];
DWORD bytesNeeded = sizeof(WCHAR);
- LoadStringW(hInstance, IDS_INFO_NOT_AVAILABLE, infoNotAvailable,
- sizeof(infoNotAvailable) / sizeof(infoNotAvailable[0]));
+ LoadStringW(hInstance, IDS_INFO_NOT_AVAILABLE, infoNotAvailable, ARRAY_SIZE(infoNotAvailable));
if (!bits->cbData || bits->cbData > 1)
{
bytesNeeded += strlenW(infoNotAvailable) * sizeof(WCHAR);
@@ -2329,15 +2289,13 @@ static BOOL WINAPI CRYPT_FormatNetscapeCertType(DWORD dwCertEncodingType,
if (!stringsLoaded)
{
- for (i = 0; i < sizeof(netscapeCertTypeMap) /
- sizeof(netscapeCertTypeMap[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(netscapeCertTypeMap); i++)
LoadStringW(hInstance, netscapeCertTypeMap[i].id,
netscapeCertTypeMap[i].str, MAX_STRING_RESOURCE_LEN);
stringsLoaded = TRUE;
}
- CRYPT_FormatBits(bits->pbData[0], netscapeCertTypeMap,
- sizeof(netscapeCertTypeMap) / sizeof(netscapeCertTypeMap[0]),
- NULL, &bitStringLen, &first);
+ CRYPT_FormatBits(bits->pbData[0], netscapeCertTypeMap, ARRAY_SIZE(netscapeCertTypeMap),
+ NULL, &bitStringLen, &first);
bytesNeeded += bitStringLen;
bytesNeeded += 3 * sizeof(WCHAR); /* " (" + ")" */
CRYPT_FormatHexString(0, 0, 0, NULL, NULL, bits->pbData,
@@ -2357,9 +2315,8 @@ static BOOL WINAPI CRYPT_FormatNetscapeCertType(DWORD dwCertEncodingType,
bitStringLen = bytesNeeded;
first = TRUE;
- CRYPT_FormatBits(bits->pbData[0], netscapeCertTypeMap,
- sizeof(netscapeCertTypeMap) / sizeof(netscapeCertTypeMap[0]),
- str, &bitStringLen, &first);
+ CRYPT_FormatBits(bits->pbData[0], netscapeCertTypeMap, ARRAY_SIZE(netscapeCertTypeMap),
+ str, &bitStringLen, &first);
str += bitStringLen / sizeof(WCHAR) - 1;
*str++ = ' ';
*str++ = '(';
@@ -2407,16 +2364,12 @@ static BOOL WINAPI CRYPT_FormatSpcFinancialCriteria(DWORD dwCertEncodingType,
if (!stringsLoaded)
{
- LoadStringW(hInstance, IDS_FINANCIAL_CRITERIA, financialCriteria,
- sizeof(financialCriteria) / sizeof(financialCriteria[0]));
- LoadStringW(hInstance, IDS_FINANCIAL_CRITERIA_AVAILABLE, available,
- sizeof(available) / sizeof(available[0]));
- LoadStringW(hInstance, IDS_FINANCIAL_CRITERIA_NOT_AVAILABLE,
- notAvailable, sizeof(notAvailable) / sizeof(notAvailable[0]));
- LoadStringW(hInstance, IDS_FINANCIAL_CRITERIA_MEETS_CRITERIA,
- meetsCriteria, sizeof(meetsCriteria) / sizeof(meetsCriteria[0]));
- LoadStringW(hInstance, IDS_YES, yes, sizeof(yes) / sizeof(yes[0]));
- LoadStringW(hInstance, IDS_NO, no, sizeof(no) / sizeof(no[0]));
+ LoadStringW(hInstance, IDS_FINANCIAL_CRITERIA, financialCriteria, ARRAY_SIZE(financialCriteria));
+ LoadStringW(hInstance, IDS_FINANCIAL_CRITERIA_AVAILABLE, available, ARRAY_SIZE(available));
+ LoadStringW(hInstance, IDS_FINANCIAL_CRITERIA_NOT_AVAILABLE, notAvailable, ARRAY_SIZE(notAvailable));
+ LoadStringW(hInstance, IDS_FINANCIAL_CRITERIA_MEETS_CRITERIA, meetsCriteria, ARRAY_SIZE(meetsCriteria));
+ LoadStringW(hInstance, IDS_YES, yes, ARRAY_SIZE(yes));
+ LoadStringW(hInstance, IDS_NO, no, ARRAY_SIZE(no));
stringsLoaded = TRUE;
}
if (dwFormatStrType & CRYPT_FORMAT_STR_MULTI_LINE)
diff --git a/dlls/crypt32/oid.c b/dlls/crypt32/oid.c
index 5a447d09ca..61b2cbc88e 100644
--- a/dlls/crypt32/oid.c
+++ b/dlls/crypt32/oid.c
@@ -69,7 +69,7 @@ static const WCHAR ADDRESSBOOK[] = {'A','D','D','R','E','S','S','B','O','O','K',
static const WCHAR TRUSTEDPUBLISHER[] = {'T','r','u','s','t','e','d','P','u','b','l','i','s','h','e','r',0};
static const WCHAR DISALLOWED[] = {'D','i','s','a','l','l','o','w','e','d',0};
static const LPCWSTR LocalizedKeys[] = {ROOT,MY,CA,ADDRESSBOOK,TRUSTEDPUBLISHER,DISALLOWED};
-static WCHAR LocalizedNames[sizeof(LocalizedKeys)/sizeof(LocalizedKeys[0])][256];
+static WCHAR LocalizedNames[ARRAY_SIZE(LocalizedKeys)][256];
static void free_function_sets(void)
{
@@ -1006,7 +1006,7 @@ static void oid_init_localizednames(void)
{
unsigned int i;
- for(i = 0; i < sizeof(LocalizedKeys)/sizeof(LPCWSTR); i++)
+ for(i = 0; i < ARRAY_SIZE(LocalizedKeys); i++)
{
LoadStringW(hInstance, IDS_LOCALIZEDNAME_ROOT+i, LocalizedNames[i], 256);
}
@@ -1019,7 +1019,7 @@ LPCWSTR WINAPI CryptFindLocalizedName(LPCWSTR pwszCryptName)
{
unsigned int i;
- for(i = 0; i < sizeof(LocalizedKeys)/sizeof(LPCWSTR); i++)
+ for(i = 0; i < ARRAY_SIZE(LocalizedKeys); i++)
{
if(!lstrcmpiW(LocalizedKeys[i], pwszCryptName))
{
@@ -1399,8 +1399,7 @@ static void init_oid_info(void)
DWORD i;
oid_init_localizednames();
- for (i = 0; i < sizeof(oidInfoConstructors) /
- sizeof(oidInfoConstructors[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(oidInfoConstructors); i++)
{
if (!IS_INTRESOURCE(oidInfoConstructors[i].pwszName))
{
diff --git a/dlls/crypt32/regstore.c b/dlls/crypt32/regstore.c
index 7678bab6aa..ce32a30f3b 100644
--- a/dlls/crypt32/regstore.c
+++ b/dlls/crypt32/regstore.c
@@ -71,7 +71,7 @@ static void CRYPT_RegReadSerializedFromReg(HKEY key, DWORD contextType,
WCHAR subKeyName[MAX_PATH];
do {
- DWORD size = sizeof(subKeyName) / sizeof(WCHAR);
+ DWORD size = ARRAY_SIZE(subKeyName);
rc = RegEnumKeyExW(key, index++, subKeyName, &size, NULL, NULL, NULL,
NULL);
@@ -163,7 +163,7 @@ static void CRYPT_RegReadFromReg(HKEY key, HCERTSTORE store)
CERT_STORE_CRL_CONTEXT_FLAG, CERT_STORE_CTL_CONTEXT_FLAG };
DWORD i;
- for (i = 0; i < sizeof(subKeys) / sizeof(subKeys[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(subKeys); i++)
{
HKEY hKey;
LONG rc;
@@ -255,7 +255,7 @@ static BOOL CRYPT_RegWriteToReg(WINE_REGSTOREINFO *store)
BOOL ret = TRUE;
DWORD i;
- for (i = 0; ret && i < sizeof(subKeys) / sizeof(subKeys[0]); i++)
+ for (i = 0; ret && i < ARRAY_SIZE(subKeys); i++)
{
HKEY key;
LONG rc = RegCreateKeyExW(store->key, subKeys[i], 0, NULL, 0,
@@ -561,8 +561,7 @@ WINECRYPT_CERTSTORE *CRYPT_RegOpenStore(HCRYPTPROV hCryptProv, DWORD dwFlags,
CRYPT_RegReadFromReg(regInfo->key, regInfo->memStore);
regInfo->dirty = FALSE;
provInfo.cbSize = sizeof(provInfo);
- provInfo.cStoreProvFunc = sizeof(regProvFuncs) /
- sizeof(regProvFuncs[0]);
+ provInfo.cStoreProvFunc = ARRAY_SIZE(regProvFuncs);
provInfo.rgpvStoreProvFunc = regProvFuncs;
provInfo.hStoreProv = regInfo;
store = CRYPT_ProvCreateStore(dwFlags, memStore, &provInfo);
diff --git a/dlls/crypt32/rootstore.c b/dlls/crypt32/rootstore.c
index 73d954f740..e7ed4e9bea 100644
--- a/dlls/crypt32/rootstore.c
+++ b/dlls/crypt32/rootstore.c
@@ -780,7 +780,7 @@ static void add_ms_root_certs(HCERTSTORE to)
TRACE("\n");
- for (i = 0; i < sizeof(msRootCerts) / sizeof(msRootCerts[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(msRootCerts); i++)
if (!CertAddEncodedCertificateToStore(to, X509_ASN_ENCODING,
msRootCerts[i].pb, msRootCerts[i].cb, CERT_STORE_ADD_NEW, NULL))
WARN("adding root cert %d failed: %08x\n", i, GetLastError());
@@ -830,9 +830,7 @@ static void read_trusted_roots_from_known_locations(HCERTSTORE store)
}
#endif
- for (i = 0; !ret &&
- i < sizeof(CRYPT_knownLocations) / sizeof(CRYPT_knownLocations[0]);
- i++)
+ for (i = 0; !ret && i < ARRAY_SIZE(CRYPT_knownLocations); i++)
ret = import_certs_from_path(CRYPT_knownLocations[i], from, TRUE);
check_and_store_certs(from, store);
}
diff --git a/dlls/crypt32/sip.c b/dlls/crypt32/sip.c
index b0c4692c1f..f51bceb460 100644
--- a/dlls/crypt32/sip.c
+++ b/dlls/crypt32/sip.c
@@ -28,6 +28,7 @@
#include "winnls.h"
#include "mssip.h"
#include "winuser.h"
+#include "crypt32_private.h"
#include "wine/debug.h"
#include "wine/list.h"
@@ -440,7 +441,7 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid
WCHAR subKeyName[MAX_PATH];
do {
- size = sizeof(subKeyName) / sizeof(subKeyName[0]);
+ size = ARRAY_SIZE(subKeyName);
r = RegEnumKeyExW(key, index++, subKeyName, &size, NULL, NULL,
NULL, NULL);
if (r == ERROR_SUCCESS)
@@ -478,7 +479,7 @@ BOOL WINAPI CryptSIPRetrieveSubjectGuid
WCHAR subKeyName[MAX_PATH];
do {
- size = sizeof(subKeyName) / sizeof(subKeyName[0]);
+ size = ARRAY_SIZE(subKeyName);
r = RegEnumKeyExW(key, index++, subKeyName, &size, NULL, NULL,
NULL, NULL);
if (r == ERROR_SUCCESS)
diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c
index bc4ebde5f6..2b8ea1d5d8 100644
--- a/dlls/crypt32/store.c
+++ b/dlls/crypt32/store.c
@@ -124,7 +124,7 @@ BOOL WINAPI I_CertUpdateStore(HCERTSTORE store1, HCERTSTORE store2, DWORD unk0,
/* Poor-man's resync: empty first store, then add everything from second
* store to it.
*/
- for (i = 0; i < sizeof(interfaces) / sizeof(interfaces[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(interfaces); i++)
{
const void *context;
@@ -717,8 +717,7 @@ static WINECRYPT_CERTSTORE *CRYPT_MsgOpenStore(HCRYPTPROV hCryptProv,
CERT_STORE_PROV_INFO provInfo = { 0 };
provInfo.cbSize = sizeof(provInfo);
- provInfo.cStoreProvFunc = sizeof(msgProvFuncs) /
- sizeof(msgProvFuncs[0]);
+ provInfo.cStoreProvFunc = ARRAY_SIZE(msgProvFuncs);
provInfo.rgpvStoreProvFunc = msgProvFuncs;
provInfo.hStoreProv = CryptMsgDuplicate(msg);
store = CRYPT_ProvCreateStore(dwFlags, memStore, &provInfo);
@@ -1338,7 +1337,7 @@ BOOL WINAPI CertEnumSystemStore(DWORD dwFlags, void *pvSystemStoreLocationPara,
ret = TRUE;
do {
WCHAR name[MAX_PATH];
- DWORD size = sizeof(name) / sizeof(name[0]);
+ DWORD size = ARRAY_SIZE(name);
rc = RegEnumKeyExW(key, index++, name, &size, NULL, NULL, NULL,
NULL);
diff --git a/dlls/crypt32/str.c b/dlls/crypt32/str.c
index 1daf29f8a0..4843c4f5f1 100644
--- a/dlls/crypt32/str.c
+++ b/dlls/crypt32/str.c
@@ -26,6 +26,7 @@
#include "wincrypt.h"
#include "wine/debug.h"
#include "wine/unicode.h"
+#include "crypt32_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(crypt);
@@ -775,7 +776,7 @@ struct KeynameKeeper
static void CRYPT_InitializeKeynameKeeper(struct KeynameKeeper *keeper)
{
keeper->keyName = keeper->buf;
- keeper->keyLen = sizeof(keeper->buf) / sizeof(keeper->buf[0]);
+ keeper->keyLen = ARRAY_SIZE(keeper->buf);
}
static void CRYPT_FreeKeynameKeeper(struct KeynameKeeper *keeper)
@@ -1326,8 +1327,7 @@ DWORD WINAPI CertGetNameStringW(PCCERT_CONTEXT pCertContext, DWORD dwType,
{
PCERT_RDN_ATTR nameAttr = NULL;
- for (i = 0; !nameAttr && i < sizeof(simpleAttributeOIDs) /
- sizeof(simpleAttributeOIDs[0]); i++)
+ for (i = 0; !nameAttr && i < ARRAY_SIZE(simpleAttributeOIDs); i++)
nameAttr = CertFindRDNAttr(simpleAttributeOIDs[i], nameInfo);
if (nameAttr)
ret = CertRDNValueToStrW(nameAttr->dwValueType,
--
2.17.1
June 20, 2018
Re: [PATCH] comctl32/imagelist: fix ImageList_Read/Write.
by Zhiyi Zhang
Hi Denis,
Thanks for taking the time. I noticed a few issues with your patch.
1. Using C++ style comments.
2. Mixing style only changes, please separate them if you really
need to make style changes. Usually, I prefer not to touch the old
code simply for style changes.
3. Add a conformance test for the problem you intent to fix.
4. Add a version to patch mail subject.
You might want to read
https://wiki.winehq.org/Submitting_Patches
Regards,
Zhiyi
June 20, 2018
[PATCH v3 2/2] gdiplus: Avoid calling GdipFillPath() with an empty path.
by Zhiyi Zhang
There is no point filling an empty path. And an empty
path will cause SelectClipPath() used in brush_fill_path()
to return error.
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/gdiplus/graphics.c | 3 +++
dlls/gdiplus/tests/graphics.c | 47 +++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index a793665683..2d23085e8a 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -4264,6 +4264,9 @@ GpStatus WINGDIPAPI GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath *p
if(graphics->busy)
return ObjectBusy;
+ if (!path->pathdata.Count)
+ return Ok;
+
if (graphics->image && graphics->image->type == ImageTypeMetafile)
return METAFILE_FillPath((GpMetafile*)graphics->image, brush, path);
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index ae75c0efc1..5eb0a8a4d0 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -1539,6 +1539,52 @@ static void test_GdipFillClosedCurveI(void)
ReleaseDC(hwnd, hdc);
}
+static void test_GdipFillPath(void)
+{
+ GpStatus status;
+ GpGraphics *graphics;
+ GpSolidFill *brush;
+ GpPath *path;
+ HDC hdc = GetDC(hwnd);
+
+ ok(hdc != NULL, "Expected HDC to be initialized\n");
+ status = GdipCreateFromHDC(hdc, &graphics);
+ expect(Ok, status);
+ ok(graphics != NULL, "Expected graphics to be initialized\n");
+ status = GdipCreateSolidFill((ARGB)0xffffffff, &brush);
+ expect(Ok, status);
+ ok(brush != NULL, "Expected brush to be initialized\n");
+ status = GdipCreatePath(FillModeAlternate, &path);
+ expect(Ok, status);
+ ok(path != NULL, "Expected path to be initialized\n");
+
+ /* Empty path */
+ GdipResetPath(path);
+ status = GdipFillPath(graphics, (GpBrush *)brush, path);
+ expect(Ok, status);
+
+ /* Not closed path */
+ GdipResetPath(path);
+ status = GdipAddPathLineI(path, 0, 0, 2, 2);
+ expect(Ok, status);
+ status = GdipAddPathLineI(path, 2, 2, 4, 0);
+ expect(Ok, status);
+ status = GdipFillPath(graphics, (GpBrush *)brush, path);
+ expect(Ok, status);
+
+ /* Closed path */
+ GdipResetPath(path);
+ status = GdipAddPathRectangle(path, 0, 0, 4, 4);
+ expect(Ok, status);
+ status = GdipFillPath(graphics, (GpBrush *)brush, path);
+ expect(Ok, status);
+
+ GdipDeletePath(path);
+ GdipDeleteBrush((GpBrush *)brush);
+ GdipDeleteGraphics(graphics);
+ ReleaseDC(hwnd, hdc);
+}
+
static void test_Get_Release_DC(void)
{
GpStatus status;
@@ -6795,6 +6841,7 @@ START_TEST(graphics)
test_GdipDrawImagePointsRect();
test_GdipFillClosedCurve();
test_GdipFillClosedCurveI();
+ test_GdipFillPath();
test_GdipDrawString();
test_GdipGetNearestColor();
test_GdipGetVisibleClipBounds();
--
2.17.1
June 20, 2018
[PATCH v3 1/2] gdiplus: Report error for brush_fill_path().
by Zhiyi Zhang
Operation should be skipped if SelectClipPath() returns any
error. And we should report unexpected error to the caller.
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com>
---
dlls/gdiplus/graphics.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 894e879233..a793665683 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -1050,8 +1050,9 @@ static BOOL brush_can_fill_path(GpBrush *brush, BOOL is_fill)
}
}
-static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
+static GpStatus brush_fill_path(GpGraphics *graphics, GpBrush *brush)
{
+ GpStatus status = Ok;
switch (brush->bt)
{
case BrushTypeSolidColor:
@@ -1064,13 +1065,19 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
RECT rc;
/* partially transparent fill */
- SelectClipPath(graphics->hdc, RGN_AND);
+ if (!SelectClipPath(graphics->hdc, RGN_AND))
+ {
+ status = GenericError;
+ DeleteObject(bmp);
+ break;
+ }
if (GetClipBox(graphics->hdc, &rc) != NULLREGION)
{
HDC hdc = CreateCompatibleDC(NULL);
if (!hdc)
{
+ status = OutOfMemory;
DeleteObject(bmp);
break;
}
@@ -1091,7 +1098,11 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
HBRUSH gdibrush, old_brush;
gdibrush = create_gdi_brush(brush);
- if (!gdibrush) return;
+ if (!gdibrush)
+ {
+ status = OutOfMemory;
+ break;
+ }
old_brush = SelectObject(graphics->hdc, gdibrush);
FillPath(graphics->hdc);
@@ -1100,6 +1111,8 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush)
break;
}
}
+
+ return status;
}
static BOOL brush_can_fill_pixels(GpBrush *brush)
@@ -4205,7 +4218,7 @@ static GpStatus GDI32_GdipFillPath(GpGraphics *graphics, GpBrush *brush, GpPath
if(retval == Ok)
{
EndPath(graphics->hdc);
- brush_fill_path(graphics, brush);
+ retval = brush_fill_path(graphics, brush);
}
gdi_transform_release(graphics);
@@ -4511,13 +4524,13 @@ static GpStatus GDI32_GdipFillRegion(GpGraphics* graphics, GpBrush* brush,
Rectangle(graphics->hdc, rc.left, rc.top, rc.right, rc.bottom);
EndPath(graphics->hdc);
- brush_fill_path(graphics, brush);
+ status = brush_fill_path(graphics, brush);
}
RestoreDC(graphics->hdc, save_state);
- return Ok;
+ return status;
}
static GpStatus SOFTWARE_GdipFillRegion(GpGraphics *graphics, GpBrush *brush,
--
2.17.1
June 20, 2018
[PATCH] comctl32/imagelist: fix ImageList_Read/Write.
by Denis Malikov
From: Denis Malikov <mdn40000(a)mail.ru>
Date: Sat, 16 Jun 2018 16:35:45 +0700
Subject: [PATCH] comctl32/imagelist: fix ImageList_Read/Write.
Fix pointer calculation for mixing image and mask bits for versions x600 and x620.
Tested with *.reg files extracted from:
XP/2003 key HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify;
Vista/7 key HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify
Signed-off-by: Denis Malikov <mdn40000(a)mail.ru>
---
dlls/comctl32/imagelist.c | 59 +++++++++++++++++++++++++++--------------------
1 file changed, 34 insertions(+), 25 deletions(-)
diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index a08d60752e..052d59f9e4 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -59,7 +59,7 @@ struct _IMAGELIST
INT cGrow; /* 0C: cGrow */
INT cx; /* 10: cx */
INT cy; /* 14: cy */
- DWORD x4;
+ DWORD x4; /* hack for IL from stream. Keep version here */
UINT flags; /* 1C: flags */
COLORREF clrFg; /* 20: foreground color */
COLORREF clrBk; /* 24: background color */
@@ -83,6 +83,7 @@ struct _IMAGELIST
};
#define IMAGELIST_MAGIC 0x53414D58
+#define IMAGELIST_VERSION 0x101
/* Header used by ImageList_Read() and ImageList_Write() */
#include "pshpack2.h"
@@ -806,6 +807,7 @@ ImageList_Create (INT cx, INT cy, UINT flags,
himl->clrFg = CLR_DEFAULT;
himl->clrBk = CLR_NONE;
himl->color_table_set = FALSE;
+ himl->x4 = 0;
/* initialize overlay mask indices */
for (nCount = 0; nCount < MAX_OVERLAYIMAGE; nCount++)
@@ -2257,38 +2259,43 @@ HIMAGELIST WINAPI ImageList_Read(IStream *pstm)
BITMAPINFO *image_info = (BITMAPINFO *)image_buf;
BITMAPINFO *mask_info = (BITMAPINFO *)mask_buf;
void *image_bits, *mask_bits = NULL;
- ILHEAD ilHead;
- HIMAGELIST himl;
+ ILHEAD ilHead;
+ HIMAGELIST himl;
unsigned int i;
TRACE("%p\n", pstm);
if (FAILED(IStream_Read (pstm, &ilHead, sizeof(ILHEAD), NULL)))
- return NULL;
+ return NULL;
if (ilHead.usMagic != (('L' << 8) | 'I'))
- return NULL;
- if (ilHead.usVersion != 0x101) /* probably version? */
- return NULL;
+ return NULL;
+ if (ilHead.usVersion != IMAGELIST_VERSION &&
+ ilHead.usVersion != 0x600 && /* XP/2003 version */
+ ilHead.usVersion != 0x620) /* Vista/7 version */
+ return NULL;
TRACE("cx %u, cy %u, flags 0x%04x, cCurImage %u, cMaxImage %u\n",
ilHead.cx, ilHead.cy, ilHead.flags, ilHead.cCurImage, ilHead.cMaxImage);
himl = ImageList_Create(ilHead.cx, ilHead.cy, ilHead.flags, ilHead.cCurImage, ilHead.cMaxImage);
if (!himl)
- return NULL;
+ return NULL;
+
+ // keep version from stream
+ himl->x4 = ilHead.usVersion;
if (!(image_bits = read_bitmap(pstm, image_info)))
{
- WARN("failed to read bitmap from stream\n");
- return NULL;
+ WARN("failed to read bitmap from stream\n");
+ return NULL;
}
if (ilHead.flags & ILC_MASK)
{
if (!(mask_bits = read_bitmap(pstm, mask_info)))
{
WARN("failed to read mask bitmap from stream\n");
- return NULL;
- }
+ return NULL;
+ }
}
else mask_info = NULL;
@@ -2296,23 +2303,25 @@ HIMAGELIST WINAPI ImageList_Read(IStream *pstm)
{
DWORD *ptr = image_bits;
BYTE *mask_ptr = mask_bits;
- int stride = himl->cy * image_info->bmiHeader.biWidth;
+ int stride = himl->cy * (ilHead.usVersion != IMAGELIST_VERSION ? himl->cx : image_info->bmiHeader.biWidth);
+ int image_step = ilHead.usVersion != IMAGELIST_VERSION ? 1 : TILE_COUNT;
+ int mask_step = ilHead.usVersion != IMAGELIST_VERSION ? 4 : 8;
if (image_info->bmiHeader.biHeight > 0) /* bottom-up */
{
ptr += image_info->bmiHeader.biHeight * image_info->bmiHeader.biWidth - stride;
- mask_ptr += (image_info->bmiHeader.biHeight * image_info->bmiHeader.biWidth - stride) / 8;
+ mask_ptr += (image_info->bmiHeader.biHeight * image_info->bmiHeader.biWidth - stride) / mask_step;
stride = -stride;
image_info->bmiHeader.biHeight = himl->cy;
}
else image_info->bmiHeader.biHeight = -himl->cy;
- for (i = 0; i < ilHead.cCurImage; i += TILE_COUNT)
+ for (i = 0; i < ilHead.cCurImage; i += image_step)
{
- add_dib_bits( himl, i, min( ilHead.cCurImage - i, TILE_COUNT ),
+ add_dib_bits( himl, i, min( ilHead.cCurImage - i, image_step ),
himl->cx, himl->cy, image_info, mask_info, ptr, mask_ptr );
ptr += stride;
- mask_ptr += stride / 8;
+ mask_ptr += stride / mask_step;
}
}
else
@@ -2333,7 +2342,7 @@ HIMAGELIST WINAPI ImageList_Read(IStream *pstm)
ImageList_SetBkColor(himl,ilHead.bkcolor);
for (i=0;i<4;i++)
- ImageList_SetOverlayImage(himl,ilHead.ovls[i],i+1);
+ ImageList_SetOverlayImage(himl,ilHead.ovls[i],i+1);
return himl;
}
@@ -3078,10 +3087,10 @@ BOOL WINAPI ImageList_Write(HIMAGELIST himl, IStream *pstm)
TRACE("%p %p\n", himl, pstm);
if (!is_valid(himl))
- return FALSE;
+ return FALSE;
ilHead.usMagic = (('L' << 8) | 'I');
- ilHead.usVersion = 0x101;
+ ilHead.usVersion = himl->x4 > 0 ? himl->x4 : IMAGELIST_VERSION;
ilHead.cCurImage = himl->cCurImage;
ilHead.cMaxImage = himl->cMaxImage;
ilHead.cGrow = himl->cGrow;
@@ -3090,23 +3099,23 @@ BOOL WINAPI ImageList_Write(HIMAGELIST himl, IStream *pstm)
ilHead.bkcolor = himl->clrBk;
ilHead.flags = himl->flags;
for(i = 0; i < 4; i++) {
- ilHead.ovls[i] = himl->nOvlIdx[i];
+ ilHead.ovls[i] = himl->nOvlIdx[i];
}
TRACE("cx %u, cy %u, flags 0x04%x, cCurImage %u, cMaxImage %u\n",
ilHead.cx, ilHead.cy, ilHead.flags, ilHead.cCurImage, ilHead.cMaxImage);
if(FAILED(IStream_Write(pstm, &ilHead, sizeof(ILHEAD), NULL)))
- return FALSE;
+ return FALSE;
/* write the bitmap */
if(!_write_bitmap(himl->hbmImage, pstm))
- return FALSE;
+ return FALSE;
/* write the mask if we have one */
if(himl->flags & ILC_MASK) {
- if(!_write_bitmap(himl->hbmMask, pstm))
- return FALSE;
+ if(!_write_bitmap(himl->hbmMask, pstm))
+ return FALSE;
}
return TRUE;
--
2.16.2.windows.1
June 20, 2018
[PATCH] wsdapi: Add a trailing '\n' to a WARN() message.
by Francois Gouget
Signed-off-by: Francois Gouget <fgouget(a)free.fr>
---
dlls/wsdapi/network.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/wsdapi/network.c b/dlls/wsdapi/network.c
index e124a5d90cf..c8f260c7653 100644
--- a/dlls/wsdapi/network.c
+++ b/dlls/wsdapi/network.c
@@ -540,7 +540,7 @@ static BOOL start_listening_on_all_addresses(IWSDiscoveryPublisherImpl *impl, UL
{
if (impl->num_thread_handles >= MAX_WSD_THREADS)
{
- WARN("Exceeded maximum number of supported listener threads; too many network interfaces.");
+ WARN("Exceeded maximum number of supported listener threads; too many network interfaces.\n");
goto cleanup;
}
--
2.17.1
June 20, 2018
[PATCH] winetest: Don't show dll=skipped messages for skipped tests.
by Francois Gouget
This spams the report when using WineTest to run a few tests.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
programs/winetest/main.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/programs/winetest/main.c b/programs/winetest/main.c
index bfac17bdf6e..b3c3c1c8502 100644
--- a/programs/winetest/main.c
+++ b/programs/winetest/main.c
@@ -902,7 +902,6 @@ extract_test_proc (HMODULE hModule, LPCSTR lpszType, LPSTR lpszName, LONG_PTR lP
if (test_filtered_out( lpszName, NULL ))
{
nr_of_skips++;
- xprintf (" %s=skipped\n", dllname);
return TRUE;
}
extract_test (&wine_tests[nr_of_files], tempdir, lpszName);
--
2.17.1
June 20, 2018
[PATCH 2/2] testbot/web: Highlight test failures and build errors on the job page.
by Francois Gouget
Show build errors in the log summary mode (like we already do for the
test failures).
Furthermore, when showing the full log, highlight the test failures and
build errors so they are easier to spot. This uses the same color
scheme as in the test.winehq.org website. Also make the boundaries
between the test units more visible by highlighting their start line.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
testbot/web/JobDetails.pl | 61 +++++++++++++++++++++++++++++++++----
testbot/web/WineTestBot.css | 5 +++
2 files changed, 60 insertions(+), 6 deletions(-)
diff --git a/testbot/web/JobDetails.pl b/testbot/web/JobDetails.pl
index f829407eb..3add52b4c 100644
--- a/testbot/web/JobDetails.pl
+++ b/testbot/web/JobDetails.pl
@@ -228,6 +228,58 @@ sub GeneratePage($)
$self->SUPER::GeneratePage();
}
+sub GetHtmlLine($$$)
+{
+ my ($self, $FullLog, $Line) = @_;
+
+ $Line = $self->escapeHTML($Line);
+ if ($Line =~ /: Test marked todo: /)
+ {
+ return (undef, $Line) if (!$FullLog);
+ my $Html = $Line;
+ $Html =~ s~^(.*\S)\s*\r?$~<span class='log-todo'>$1</span>~;
+ return ($Html, $Line);
+ }
+ if ($Line =~ /: Tests skipped: / or
+ $Line =~ /^\w+:\w+ skipped /)
+ {
+ return (undef, $Line) if (!$FullLog);
+ my $Html = $Line;
+ $Html =~ s~^(.*\S)\s*\r?$~<span class='log-skip'>$1</span>~;
+ return ($Html, $Line);
+ }
+ if ($Line =~ /: Test (?:failed|succeeded inside todo block): / or
+ $Line =~ /Fatal: test .* does not exist/ or
+ $Line =~ / done \(258\)/ or
+ $Line =~ /: unhandled exception [0-9a-fA-F]{8} at / or
+ $Line =~ /^Unhandled exception: / or
+ # Build errors
+ $Line =~ /: error: / or
+ $Line =~ /^error: patch failed:/ or
+ $Line =~ /^Makefile:[0-9]+: recipe for target .* failed$/ or
+ $Line =~ /^(?:Build|Reconfig|Task): (?!ok)/ or
+ # Typical perl errors
+ $Line =~ /^Use of uninitialized value/)
+ {
+ return ($Line, $Line) if (!$FullLog);
+ my $Html = $Line;
+ $Html =~ s~^(.*\S)\s*\r?$~<span class='log-error'>$1</span>~;
+ return ($Html, $Line);
+ }
+ if ($FullLog &&
+ ($Line =~ /^\+ \S/ or
+ $Line =~ /^\w+:\w+ start / or
+ # Build messages
+ $Line =~ /^(?:Build|Reconfig|Task): ok/))
+ {
+ my $Html = $Line;
+ $Html =~ s~^(.*\S)\s*\r?$~<span class='log-info'>$1</span>~;
+ return ($Html, $Line);
+ }
+
+ return (undef, $Line);
+}
+
my %MILogLabels = (
"log" => "task log",
"log.old" => "old logs",
@@ -371,11 +423,8 @@ sub GenerateBody($)
{
$CurrentDll = $1;
}
- if ($MoreInfo->{Full} ||
- $Line =~ m/: Test (?:failed|succeeded inside todo block): / ||
- $Line =~ m/Fatal: test '[^']+' does not exist/ ||
- $Line =~ m/ done \(258\)/ ||
- $Line =~ m/: unhandled exception [0-9a-fA-F]{8} at /)
+ my ($Highlight, $Plain) = $self->GetHtmlLine($MoreInfo->{Full}, $Line);
+ if ($MoreInfo->{Full} || defined $Highlight)
{
if ($PrintedDll ne $CurrentDll && !$MoreInfo->{Full})
{
@@ -402,7 +451,7 @@ sub GenerateBody($)
}
else
{
- print $self->escapeHTML($Line), "\n";
+ print(($Highlight || $Plain), "\n");
}
}
}
diff --git a/testbot/web/WineTestBot.css b/testbot/web/WineTestBot.css
index ebc622e34..28ac1b1c2 100644
--- a/testbot/web/WineTestBot.css
+++ b/testbot/web/WineTestBot.css
@@ -353,6 +353,11 @@ pre
.boterror { color: #e55600; }
.canceled { color: black; }
+.log-info { background-color: #d9ffcc; }
+.log-skip { color: blue; }
+.log-todo { color: #d08000; }
+.log-error { color: red; }
+
a.title { color:inherit; text-decoration: none; }
th.Record { text-align: center; }
--
2.17.1
June 20, 2018
[PATCH 1/2] testbot/web: Allow showing multiple job screenshots and logs.
by Francois Gouget
It's now possible to have the job details page show multiple
screenshots and multiple logs.
Once a screenshot / log is shown, the link can be clicked again to hide
it.
The code can also more easily be extended to handle more log files.
The code inserting the links is simpler too.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
testbot/bin/WineRunTask.pl | 2 +-
testbot/web/JobDetails.pl | 156 +++++++++++++++++++++++--------------
2 files changed, 97 insertions(+), 61 deletions(-)
diff --git a/testbot/bin/WineRunTask.pl b/testbot/bin/WineRunTask.pl
index 3d8113fd9..c4ca578e2 100755
--- a/testbot/bin/WineRunTask.pl
+++ b/testbot/bin/WineRunTask.pl
@@ -448,7 +448,7 @@ elsif ($Step->Type eq "suite")
if (defined($WebHostName))
{
my $StepTask = 100 * $StepNo + $TaskNo;
- $Script .= "-u \"http://$WebHostName/JobDetails.pl?Key=$JobId&scrshot_$StepTask=1#k$StepTask\"";
+ $Script .= "-u \"http://$WebHostName/JobDetails.pl?Key=$JobId&s$StepTask=1#k$StepTask\"";
}
my $Info = $VM->Description ? $VM->Description : "";
if ($VM->Details)
diff --git a/testbot/web/JobDetails.pl b/testbot/web/JobDetails.pl
index 70d8b5983..f829407eb 100644
--- a/testbot/web/JobDetails.pl
+++ b/testbot/web/JobDetails.pl
@@ -228,12 +228,95 @@ sub GeneratePage($)
$self->SUPER::GeneratePage();
}
+my %MILogLabels = (
+ "log" => "task log",
+ "log.old" => "old logs",
+);
+
+sub InitMoreInfo($)
+{
+ my ($self) = @_;
+
+ my $More = $self->{More} = {};
+ my $Keys = $self->SortKeys(undef, $self->{Collection}->GetKeys());
+ foreach my $Key (@$Keys)
+ {
+ my $StepTask = $self->{Collection}->GetItem($Key);
+ $More->{$Key}->{Screenshot} = $self->GetParam("s$Key");
+
+ my $Value = $self->GetParam("f$Key");
+ my $TaskDir = $StepTask->GetTaskDir();
+ foreach my $Log ("log", "log.old")
+ {
+ if (!-f "$TaskDir/$Log" or -z "$TaskDir/$Log")
+ {
+ my $Err = $Log;
+ next if ($Err !~ s/^log/err/ or !-f "$TaskDir/$Err" or -z "$TaskDir/$Err");
+ }
+ push @{$More->{$Key}->{Logs}}, $Log;
+
+ $More->{$Key}->{Full} = $Log if (uri_escape($Log) eq $Value);
+ }
+ $More->{$Key}->{Full} ||= "";
+ }
+}
+
+sub GenerateMoreInfoLink($$$;$)
+{
+ my ($self, $LinkKey, $Label, $Set, $Value) = @_;
+
+ my $Url = $ENV{"SCRIPT_NAME"} ."?Key=". uri_escape($self->{JobId});
+
+ my $Action = "Show";
+ foreach my $Key (sort keys %{$self->{More}})
+ {
+ my $MoreInfo = $self->{More}->{$Key};
+ if ($Key eq $LinkKey and $Set eq "Screenshot")
+ {
+ if (!$MoreInfo->{Screenshot})
+ {
+ $Url .= "&s$Key=1";
+ }
+ else
+ {
+ $Action = "Hide";
+ }
+ }
+ else
+ {
+ $Url .= "&s$Key=1" if ($MoreInfo->{Screenshot});
+ }
+
+ if ($Key eq $LinkKey and $Set eq "Full")
+ {
+ if ($MoreInfo->{Full} ne $Value)
+ {
+ $Url .= "&f$Key=". uri_escape($Value);
+ }
+ else
+ {
+ $Action = "Hide";
+ }
+ }
+ else
+ {
+ $Url .= "&f$Key=". uri_escape($MoreInfo->{Full}) if ($MoreInfo->{Full});
+ }
+ }
+ $Url .= "#k" . uri_escape($LinkKey);
+
+ print "<div class='TaskMoreInfoLink'><a href='",
+ $self->CGI->escapeHTML($Url), "'>$Action $Label</a></div>\n";
+}
+
sub GenerateBody($)
{
my ($self) = @_;
$self->SUPER::GenerateBody();
+ $self->InitMoreInfo();
+
print "<div class='Content'>\n";
my $Keys = $self->SortKeys(undef, $self->{Collection}->GetKeys());
foreach my $Key (@$Keys)
@@ -249,18 +332,11 @@ sub GenerateBody($)
$self->CGI->escapeHTML($VM->Details || "No details!"),
"</details>\n";
- my $FullLogParamName = "log_$Key";
- my $FullLog = $self->GetParam($FullLogParamName);
- $FullLog = "" if ($FullLog !~ /^[12]$/);
-
- my $ScreenshotParamName = "scrshot_$Key";
- my $Screenshot = $self->GetParam($ScreenshotParamName);
- $Screenshot = "" if ($Screenshot ne "1");
-
+ my $MoreInfo = $self->{More}->{$Key};
print "<div class='TaskMoreInfoLinks'>\n";
if (-r "$TaskDir/screenshot.png")
{
- if ($Screenshot)
+ if ($MoreInfo->{Screenshot})
{
my $URI = "/Screenshot.pl?JobKey=" . uri_escape($self->{JobId}) .
"&StepKey=" . uri_escape($StepTask->StepNo) .
@@ -268,59 +344,19 @@ sub GenerateBody($)
print "<div class='Screenshot'><img src='" .
$self->CGI->escapeHTML($URI) . "' alt='Screenshot' /></div>\n";
}
- else
- {
- my $URI = $ENV{"SCRIPT_NAME"} . "?Key=" . uri_escape($self->{JobId}) .
- "&$ScreenshotParamName=1";
- $URI .= "&$FullLogParamName=$FullLog";
- $URI .= "#k" . uri_escape($Key);
- print "<div class='TaskMoreInfoLink'><a href='" .
- $self->CGI->escapeHTML($URI) .
- "'>Show final screenshot</a></div>";
- print "\n";
- }
+ $self->GenerateMoreInfoLink($Key, "final screenshot", "Screenshot");
}
- my $LogName = "$TaskDir/log";
- my $ErrName = "$TaskDir/err";
- if (-r $LogName and $FullLog != "1")
- {
- my $URI = $ENV{"SCRIPT_NAME"} . "?Key=" . uri_escape($self->{JobId}) .
- "&$FullLogParamName=1";
- $URI .= "&$ScreenshotParamName=$Screenshot";
- $URI .= "#k" . uri_escape($Key);
- print "<div class='TaskMoreInfoLink'><a href='" .
- $self->CGI->escapeHTML($URI) .
- "'>Show full log</a></div>\n";
- }
- if ((-r $LogName or -r $ErrName) and $FullLog == "2")
+ foreach my $Log (@{$MoreInfo->{Logs}})
{
- my $URI = $ENV{"SCRIPT_NAME"} . "?Key=" . uri_escape($self->{JobId});
- $URI .= "&$ScreenshotParamName=$Screenshot";
- $URI .= "#k" . uri_escape($Key);
- print "<div class='TaskMoreInfoLink'><a href='" .
- $self->CGI->escapeHTML($URI) .
- "'>Show latest log</a></div>\n";
- }
- if ((-r "$LogName.old" or -r "$ErrName.old") and $FullLog != "2")
- {
- my $URI = $ENV{"SCRIPT_NAME"} . "?Key=" . uri_escape($self->{JobId}) .
- "&$FullLogParamName=2";
- $URI .= "&$ScreenshotParamName=$Screenshot";
- $URI .= "#k" . uri_escape($Key);
- print "<div class='TaskMoreInfoLink'><a href='" .
- $self->CGI->escapeHTML($URI) .
- "'>Show old logs</a></div>\n";
+ $self->GenerateMoreInfoLink($Key, $MILogLabels{$Log}, "Full", $Log);
}
print "</div>\n";
- if ($FullLog eq "2")
- {
- $LogName .= ".old";
- $ErrName .= ".old";
- }
+ my $LogName = $MoreInfo->{Full} || $MoreInfo->{Logs}->[0] || "log";
+ my $ErrName = $LogName eq "log.old" ? "err.old" : "err";
- if (open LOGFILE, "<$LogName")
+ if (open LOGFILE, "<", "$TaskDir/$LogName")
{
my $HasLogEntries = !1;
my $First = 1;
@@ -335,13 +371,13 @@ sub GenerateBody($)
{
$CurrentDll = $1;
}
- if ($FullLog ||
+ if ($MoreInfo->{Full} ||
$Line =~ m/: Test (?:failed|succeeded inside todo block): / ||
$Line =~ m/Fatal: test '[^']+' does not exist/ ||
$Line =~ m/ done \(258\)/ ||
$Line =~ m/: unhandled exception [0-9a-fA-F]{8} at /)
{
- if ($PrintedDll ne $CurrentDll && ! $FullLog)
+ if ($PrintedDll ne $CurrentDll && !$MoreInfo->{Full})
{
if ($First)
{
@@ -359,7 +395,7 @@ sub GenerateBody($)
print "<pre><code>";
$First = !1;
}
- if (! $FullLog && $Line =~ m/^[^:]+:([^:]*)(?::[0-9a-f]+)? done \(258\)/)
+ if (!$MoreInfo->{Full} && $Line =~ m/^[^:]+:([^:]*)(?::[0-9a-f]+)? done \(258\)/)
{
my $Unit = $1 ne "" ? "$1: " : "";
print "${Unit}Timeout\n";
@@ -372,7 +408,7 @@ sub GenerateBody($)
}
close LOGFILE;
- if (open ERRFILE, "<$ErrName")
+ if (open ERRFILE, "<", "$TaskDir/$ErrName")
{
$CurrentDll = "*err*";
while (defined($Line = <ERRFILE>))
@@ -409,7 +445,7 @@ sub GenerateBody($)
" failures found" : "Empty log";
}
}
- elsif (open ERRFILE, "<$ErrName")
+ elsif (open ERRFILE, "<", "$TaskDir/$ErrName")
{
my $HasErrEntries = !1;
my $Line;
--
2.17.1
June 20, 2018
[PATCH 4/4] testbot/build: Let the TestBot deal with logging.
by Francois Gouget
The Engine-side scripts (WineRun*.pl) already redirect stdout and
stderr to the appropriate log. So it does not make sense to delete that
log and then add new redirects for every command started from the
client scripts.
Remove FatalError() since it's not used in Reconfig.pl.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
testbot/bin/build/Build.pl | 42 ++++++++------------------
testbot/bin/build/Reconfig.pl | 55 +++++++++++------------------------
2 files changed, 29 insertions(+), 68 deletions(-)
diff --git a/testbot/bin/build/Build.pl b/testbot/bin/build/Build.pl
index e97995559..c23bb8780 100755
--- a/testbot/bin/build/Build.pl
+++ b/testbot/bin/build/Build.pl
@@ -49,27 +49,19 @@ use WineTestBot::PatchUtils;
use WineTestBot::Utils;
-my $LogFileName = "$LogDir/Build.log";
-
sub InfoMsg(@)
{
- my $OldUMask = umask(002);
- if (open(my $Log, ">>", $LogFileName))
- {
- print $Log @_;
- close($Log);
- }
- umask($OldUMask);
+ print @_;
}
sub LogMsg(@)
{
- InfoMsg "Build: ", @_;
+ print "Build: ", @_;
}
sub FatalError(@)
{
- LogMsg @_;
+ print STDERR @_;
exit 1;
}
@@ -90,10 +82,9 @@ sub ApplyPatch($)
my ($PatchFile) = @_;
InfoMsg "Applying patch\n";
- system("( cd $DataDir/wine && set -x && " .
- " git apply --verbose ". ShQuote($PatchFile) ." && ".
- " git add -A " .
- ") >>$LogFileName 2>&1");
+ system("cd $DataDir/wine && set -x && ".
+ "git apply --verbose ". ShQuote($PatchFile) ." && ".
+ "git add -A");
if ($? != 0)
{
LogMsg "Patch failed to apply\n";
@@ -104,9 +95,7 @@ sub ApplyPatch($)
if ($Impacts->{Makefiles})
{
InfoMsg "\nRunning make_makefiles\n";
- system("( cd $DataDir/wine && set -x && " .
- " ./tools/make_makefiles " .
- ") >>$LogFileName 2>&1");
+ system("cd $DataDir/wine && set -x && ./tools/make_makefiles");
if ($? != 0)
{
LogMsg "make_makefiles failed\n";
@@ -117,9 +106,7 @@ sub ApplyPatch($)
if ($Impacts->{Autoconf} && !$Impacts->{HasConfigure})
{
InfoMsg "\nRunning autoconf\n";
- system("( cd $DataDir/wine && set -x && " .
- " autoconf " .
- ") >>$LogFileName 2>&1");
+ system("cd $DataDir/wine && set -x && autoconf");
if ($? != 0)
{
LogMsg "Autoconf failed\n";
@@ -135,9 +122,8 @@ sub BuildNative()
mkdir "$DataDir/build-native" if (! -d "$DataDir/build-native");
InfoMsg "\nRebuilding native tools\n";
- system("( cd $DataDir/build-native && set -x && " .
- " time make -j$ncpus __tooldeps__ " .
- ") >>$LogFileName 2>&1");
+ system("cd $DataDir/build-native && set -x && ".
+ "time make -j$ncpus __tooldeps__");
if ($? != 0)
{
LogMsg "Rebuild of native tools failed\n";
@@ -161,9 +147,8 @@ sub BuildTestExecutables($$)
}
InfoMsg "\nBuilding the $Bits-bit test executable(s)\n";
- system("( cd $DataDir/build-mingw$Bits && set -x && " .
- " time make -j$ncpus ". join(" ", sort @BuildDirs) .
- ") >>$LogFileName 2>&1");
+ system("cd $DataDir/build-mingw$Bits && set -x && ".
+ "time make -j$ncpus ". join(" ", sort @BuildDirs));
if ($? != 0)
{
LogMsg "Rebuild of $Bits-bit crossbuild failed\n";
@@ -186,9 +171,6 @@ sub BuildTestExecutables($$)
$ENV{PATH} = "/usr/lib/ccache:/usr/bin:/bin";
delete $ENV{ENV};
-# Start with a clean logfile
-unlink($LogFileName);
-
my ($PatchFile, $BitIndicators);
if (@ARGV == 2)
{
diff --git a/testbot/bin/build/Reconfig.pl b/testbot/bin/build/Reconfig.pl
index c950d4974..2da2f54a4 100755
--- a/testbot/bin/build/Reconfig.pl
+++ b/testbot/bin/build/Reconfig.pl
@@ -43,28 +43,15 @@ sub BEGIN
use WineTestBot::Config;
use WineTestBot::PatchUtils;
-my $LogFileName = "$LogDir/Reconfig.log";
sub InfoMsg(@)
{
- my $OldUMask = umask(002);
- if (open(my $Log, ">>", $LogFileName))
- {
- print $Log @_;
- close($Log);
- }
- umask($OldUMask);
+ print @_;
}
sub LogMsg(@)
{
- InfoMsg "Reconfig: ", @_;
-}
-
-sub FatalError(@)
-{
- LogMsg @_;
- exit 1;
+ print "Reconfig: ", @_;
}
my $ncpus;
@@ -86,9 +73,8 @@ sub BuildTestAgentd()
if (! -x "$BinDir/build/testagentd")
{
InfoMsg "\nBuilding the native testagentd\n";
- system("( cd $::RootDir/src/testagentd && set -x && " .
- " time make -j$ncpus build " .
- ") >>$LogFileName 2>&1");
+ system("cd $::RootDir/src/testagentd && set -x && ".
+ "time make -j$ncpus build");
if ($? != 0)
{
LogMsg "Build testagentd failed\n";
@@ -97,9 +83,8 @@ sub BuildTestAgentd()
}
InfoMsg "\nRebuilding the Windows TestAgentd\n";
- system("( cd $::RootDir/src/testagentd && set -x && " .
- " time make -j$ncpus iso " .
- ") >>$LogFileName 2>&1");
+ system("cd $::RootDir/src/testagentd && set -x && ".
+ "time make -j$ncpus iso");
if ($? != 0)
{
LogMsg "Build winetestbot.iso failed\n";
@@ -112,9 +97,8 @@ sub BuildTestAgentd()
sub BuildTestLauncher()
{
InfoMsg "\nRebuilding TestLauncher\n";
- system("( cd $::RootDir/src/TestLauncher && set -x && " .
- " time make -j$ncpus" .
- ") >>$LogFileName 2>&1");
+ system("cd $::RootDir/src/TestLauncher && set -x && ".
+ "time make -j$ncpus");
if ($? != 0)
{
LogMsg "Build TestLauncher failed\n";
@@ -127,7 +111,7 @@ sub BuildTestLauncher()
sub GitPull()
{
InfoMsg "\nUpdating the Wine source\n";
- system("cd $DataDir/wine && git pull >>$LogFileName 2>&1");
+ system("cd $DataDir/wine && git pull");
if ($? != 0)
{
LogMsg "Git pull failed\n";
@@ -150,11 +134,10 @@ sub BuildNative()
# Rebuild from scratch to make sure cruft will not accumulate
InfoMsg "\nRebuilding native tools\n";
- system("( cd $DataDir/build-native && set -x && " .
- " rm -rf * && " .
- " time ../wine/configure --enable-win64 --without-x --without-freetype --disable-winetest && " .
- " time make -j$ncpus __tooldeps__ " .
- ") >>$LogFileName 2>&1");
+ system("cd $DataDir/build-native && set -x && ".
+ "rm -rf * && ".
+ "time ../wine/configure --enable-win64 --without-x --without-freetype --disable-winetest && ".
+ "time make -j$ncpus __tooldeps__");
if ($? != 0)
{
@@ -174,11 +157,10 @@ sub BuildCross($)
# Rebuild from scratch to make sure cruft will not accumulate
InfoMsg "\nRebuilding the $Bits-bit test executables\n";
- system("( cd $DataDir/build-mingw$Bits && set -x && " .
- " rm -rf * && " .
- " time ../wine/configure --host=$Host --with-wine-tools=../build-native --without-x --without-freetype --disable-winetest && " .
- " time make -j$ncpus buildtests" .
- ") >>$LogFileName 2>&1");
+ system("cd $DataDir/build-mingw$Bits && set -x && ".
+ "rm -rf * && ".
+ "time ../wine/configure --host=$Host --with-wine-tools=../build-native --without-x --without-freetype --disable-winetest && ".
+ "time make -j$ncpus buildtests");
if ($? != 0)
{
LogMsg "Build cross ($Bits bits) failed\n";
@@ -191,9 +173,6 @@ sub BuildCross($)
$ENV{PATH} = "/usr/lib/ccache:/usr/bin:/bin";
delete $ENV{ENV};
-# Start with a clean logfile
-unlink($LogFileName);
-
if (! -d "$DataDir/staging" and ! mkdir "$DataDir/staging")
{
LogMsg "Unable to create '$DataDir/staging': $!\n";
--
2.17.1
June 20, 2018
[PATCH 3/4] testbot/Build: Don't use tainting and improve handling of the patch filename.
by Francois Gouget
Tainting is moot because the whole purpose of the script is to run
arbitrary user-provided code (in patch form).
Still validate the patch filename but use the standard IsValidFileName()
function (instead of the much stricter regular expression used so far)
so patches accepted by Submit.pl don't get rejected at this late stage.
However carefully quote the filename when building our shell command so
it does not fail if the filename contains a space (for instance).
Also note that in practice (so far) the patch filename is always called
patch.diff as this is hardcoded in WineRunBuild.pl. So this is all a
bit academic.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
testbot/bin/build/Build.pl | 25 ++++++++++++++-----------
testbot/lib/WineTestBot/Utils.pm | 26 +++++++++++++++++++++++++-
2 files changed, 39 insertions(+), 12 deletions(-)
diff --git a/testbot/bin/build/Build.pl b/testbot/bin/build/Build.pl
index 8318af12a..e97995559 100755
--- a/testbot/bin/build/Build.pl
+++ b/testbot/bin/build/Build.pl
@@ -1,10 +1,13 @@
-#!/usr/bin/perl -Tw
+#!/usr/bin/perl
# -*- Mode: Perl; perl-indent-level: 2; indent-tabs-mode: nil -*-
#
# Performs the 'build' task in the build machine. Specifically this applies a
# conformance test patch, rebuilds the impacted test and retrieves the
# resulting 32 and 64 bit binaries.
#
+# This script does not use tainting (-T) because its whole purpose is to run
+# arbitrary user-provided code anyway (in patch form).
+#
# Copyright 2009 Ge van Geldorp
# Copyright 2012-2014, 2017-2018 Francois Gouget
#
@@ -22,6 +25,7 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+use warnings;
use strict;
sub BEGIN
@@ -42,6 +46,8 @@ sub BEGIN
use WineTestBot::Config;
use WineTestBot::PatchUtils;
+use WineTestBot::Utils;
+
my $LogFileName = "$LogDir/Build.log";
@@ -85,7 +91,7 @@ sub ApplyPatch($)
InfoMsg "Applying patch\n";
system("( cd $DataDir/wine && set -x && " .
- " git apply --verbose $PatchFile && " .
+ " git apply --verbose ". ShQuote($PatchFile) ." && ".
" git add -A " .
") >>$LogFileName 2>&1");
if ($? != 0)
@@ -199,18 +205,15 @@ if (! $PatchFile || !$BitIndicators)
FatalError "Usage: Build.pl <patchfile> <bits>\n";
}
-# Untaint parameters
-if ($PatchFile =~ m/^([\w_.\-]+)$/)
+# Verify parameters
+if (!IsValidFileName($PatchFile))
{
- $PatchFile = "$DataDir/staging/$1";
- if (! -r $PatchFile)
- {
- FatalError "Patch file $PatchFile not readable\n";
- }
+ FatalError "The patch filename '$PatchFile' contains invalid characters\n";
}
-else
+$PatchFile = "$DataDir/staging/$PatchFile";
+if (!-r $PatchFile)
{
- FatalError "Invalid patch file $PatchFile\n";
+ FatalError "Patch file '$PatchFile' is not readable\n";
}
my ($Run32, $Run64);
diff --git a/testbot/lib/WineTestBot/Utils.pm b/testbot/lib/WineTestBot/Utils.pm
index 962e6ff67..111a56589 100644
--- a/testbot/lib/WineTestBot/Utils.pm
+++ b/testbot/lib/WineTestBot/Utils.pm
@@ -28,7 +28,8 @@ WineTestBot::Utils - Utility functions
use Exporter 'import';
our @EXPORT = qw(MakeSecureURL SecureConnection GenerateRandomString
OpenNewFile CreateNewFile CreateNewLink CreateNewDir
- DurationToString BuildEMailRecipient IsValidFileName);
+ DurationToString BuildEMailRecipient IsValidFileName
+ ShQuote);
use Fcntl;
@@ -196,4 +197,27 @@ sub IsValidFileName($)
return $FileName !~ m~[<>:"/\\|?*]~;
}
+=pod
+=over 12
+
+=item C<ShQuote()>
+
+Quotes strings so they can be used in shell commands.
+
+Note that this implies escaping '$'s and '`'s which may not be appropriate
+in another context.
+
+=back
+=cut
+
+sub ShQuote($)
+{
+ my ($Str)=@_;
+ $Str =~ s%\\%\\\\%g;
+ $Str =~ s%\$%\\\$%g;
+ $Str =~ s%\"%\\\"%g;
+ $Str =~ s%\`%\\\`%g;
+ return "\"$Str\"";
+}
+
1;
--
2.17.1
June 20, 2018
[PATCH 2/4] testbot/web: Reject filenames that are not valid Windows filenames.
by Francois Gouget
IsValidFileName() verifies that the filename is valid on both Windows
and Unix. This is necessary to ensure we will be able to upload the file
to the build and/or test VMs.
IsValidFileName() is defined in the Utils.pm module so it can be reused
where necessary.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
testbot/lib/WineTestBot/Utils.pm | 25 ++++++++++++++++++++++++-
testbot/web/Submit.pl | 4 ++--
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/testbot/lib/WineTestBot/Utils.pm b/testbot/lib/WineTestBot/Utils.pm
index 8b0bfeb0c..962e6ff67 100644
--- a/testbot/lib/WineTestBot/Utils.pm
+++ b/testbot/lib/WineTestBot/Utils.pm
@@ -28,7 +28,7 @@ WineTestBot::Utils - Utility functions
use Exporter 'import';
our @EXPORT = qw(MakeSecureURL SecureConnection GenerateRandomString
OpenNewFile CreateNewFile CreateNewLink CreateNewDir
- DurationToString BuildEMailRecipient);
+ DurationToString BuildEMailRecipient IsValidFileName);
use Fcntl;
@@ -173,4 +173,27 @@ sub CreateNewDir($$)
}
}
+
+#
+# Shell helpers
+#
+
+=pod
+=over 12
+
+=item C<IsValidFileName()>
+
+Returns true if the filename is valid on Unix and Windows systems.
+
+This also ensures this is not a trick filename such as '../important/file'.
+
+=back
+=cut
+
+sub IsValidFileName($)
+{
+ my ($FileName) = @_;
+ return $FileName !~ m~[<>:"/\\|?*]~;
+}
+
1;
diff --git a/testbot/web/Submit.pl b/testbot/web/Submit.pl
index c16b99f1e..afebc722b 100644
--- a/testbot/web/Submit.pl
+++ b/testbot/web/Submit.pl
@@ -514,10 +514,10 @@ sub ValidateAndGetFileName($$)
$self->{ErrMessage} = "You must provide a file to test";
return undef;
}
- if ($FileName =~ m=[/\\]=)
+ if (!IsValidFileName($FileName))
{
$self->{ErrField} = $FieldName;
- $self->{ErrMessage} = "The filename is invalid";
+ $self->{ErrMessage} = "The filename contains invalid characters";
return undef;
}
my $PropertyDescriptor = CreateSteps()->GetPropertyDescriptorByName("FileName");
--
2.17.1
June 20, 2018
[PATCH 1/4] testbot: Add section headers and reorder the Utils.pm functions.
by Francois Gouget
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
testbot/lib/WineTestBot/Utils.pm | 100 +++++++++++++++++--------------
1 file changed, 54 insertions(+), 46 deletions(-)
diff --git a/testbot/lib/WineTestBot/Utils.pm b/testbot/lib/WineTestBot/Utils.pm
index 81a2eda39..8b0bfeb0c 100644
--- a/testbot/lib/WineTestBot/Utils.pm
+++ b/testbot/lib/WineTestBot/Utils.pm
@@ -35,6 +35,10 @@ use Fcntl;
use WineTestBot::Config;
+#
+# Web helpers
+#
+
sub MakeSecureURL($)
{
my ($URL) = @_;
@@ -53,6 +57,56 @@ sub SecureConnection()
return defined($ENV{"HTTPS"}) && $ENV{"HTTPS"} eq "on";
}
+sub DurationToString($;$)
+{
+ my ($Secs, $Raw) = @_;
+
+ return "n/a" if (!defined $Secs);
+
+ my @Parts;
+ if (!$Raw)
+ {
+ my $Mins = int($Secs / 60);
+ $Secs -= 60 * $Mins;
+ my $Hours = int($Mins / 60);
+ $Mins -= 60 * $Hours;
+ my $Days = int($Hours / 24);
+ $Hours -= 24 * $Days;
+ push @Parts, "${Days}d" if ($Days);
+ push @Parts, "${Hours}h" if ($Hours);
+ push @Parts, "${Mins}m" if ($Mins);
+ }
+ if (!@Parts or int($Secs) != 0)
+ {
+ push @Parts, (@Parts or int($Secs) == $Secs) ?
+ int($Secs) ."s" :
+ sprintf('%.1fs', $Secs);
+ }
+ return join(" ", @Parts);
+}
+
+sub BuildEMailRecipient($$)
+{
+ my ($EMailAddress, $Name) = @_;
+
+ if (! defined($EMailAddress))
+ {
+ return undef;
+ }
+ my $Recipient = "<" . $EMailAddress . ">";
+ if ($Name)
+ {
+ $Recipient .= " ($Name)";
+ }
+
+ return $Recipient;
+}
+
+
+#
+# Temporary file helpers
+#
+
sub GenerateRandomString($)
{
my ($Len) = @_;
@@ -119,50 +173,4 @@ sub CreateNewDir($$)
}
}
-sub DurationToString($;$)
-{
- my ($Secs, $Raw) = @_;
-
- return "n/a" if (!defined $Secs);
-
- my @Parts;
- if (!$Raw)
- {
- my $Mins = int($Secs / 60);
- $Secs -= 60 * $Mins;
- my $Hours = int($Mins / 60);
- $Mins -= 60 * $Hours;
- my $Days = int($Hours / 24);
- $Hours -= 24 * $Days;
- push @Parts, "${Days}d" if ($Days);
- push @Parts, "${Hours}h" if ($Hours);
- push @Parts, "${Mins}m" if ($Mins);
- }
- if (!@Parts or int($Secs) != 0)
- {
- push @Parts, (@Parts or int($Secs) == $Secs) ?
- int($Secs) ."s" :
- sprintf('%.1fs', $Secs);
- }
- return join(" ", @Parts);
-}
-
-sub BuildEMailRecipient($$)
-{
- my ($EMailAddress, $Name) = @_;
-
- if (! defined($EMailAddress))
- {
- return undef;
- }
- my $Recipient = "<" . $EMailAddress . ">";
- if ($Name)
- {
- $Recipient .= " ($Name)";
- }
-
- return $Recipient;
-}
-
-
1;
--
2.17.1
June 20, 2018
[PATCH] testbot/WineRunTask: Trace the effective timeout, with leeway.
by Francois Gouget
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
testbot/bin/WineRunTask.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/testbot/bin/WineRunTask.pl b/testbot/bin/WineRunTask.pl
index 4fd51d985..51b105b19 100755
--- a/testbot/bin/WineRunTask.pl
+++ b/testbot/bin/WineRunTask.pl
@@ -493,7 +493,7 @@ if (!$Pid)
my $NewStatus = 'completed';
my ($TaskFailures, $TaskTimedOut, $TAError, $PossibleCrash);
-Debug(Elapsed($Start), " Waiting for the script (", $Task->Timeout, "s timeout)\n");
+Debug(Elapsed($Start), " Waiting for the script (", $Timeout, "s timeout)\n");
if (!defined $TA->Wait($Pid, $Timeout, $Keepalive))
{
my $ErrMessage = $TA->GetLastError();
--
2.17.1
June 20, 2018
[PATCH] testbot: Retrieve the list of Wine files.
by Francois Gouget
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
testbot/bin/WineRunReconfig.pl | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/testbot/bin/WineRunReconfig.pl b/testbot/bin/WineRunReconfig.pl
index fe69fc3b7..d04b78061 100755
--- a/testbot/bin/WineRunReconfig.pl
+++ b/testbot/bin/WineRunReconfig.pl
@@ -444,6 +444,16 @@ if ($NewStatus eq "completed")
{
$TAError = "An error occurred while retrieving the test list: ". $TA->GetLastError();
}
+
+ Debug(Elapsed($Start), " Retrieving the list of Wine files '$TaskDir/winefiles.txt'\n");
+ if ($TA->GetFile("latest/winefiles.txt", "$TaskDir/winefiles.txt"))
+ {
+ copy "$TaskDir/winefiles.txt", "$DataDir/latest/winefiles.txt";
+ }
+ elsif (!defined $TAError)
+ {
+ $TAError = "An error occurred while retrieving the list of Wine files: ". $TA->GetLastError();
+ }
}
$TA->Disconnect();
--
2.17.1
June 20, 2018
[PATCH] testbot/WineRun*: Rename the timeout WrapUpAndExit() parameter.
by Francois Gouget
It is a boolean indicating whether the task timed out, not the timeout
value in seconds.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
testbot/bin/WineRunBuild.pl | 4 ++--
testbot/bin/WineRunReconfig.pl | 4 ++--
testbot/bin/WineRunTask.pl | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/testbot/bin/WineRunBuild.pl b/testbot/bin/WineRunBuild.pl
index eab33bc08..1bc6cffbc 100755
--- a/testbot/bin/WineRunBuild.pl
+++ b/testbot/bin/WineRunBuild.pl
@@ -196,11 +196,11 @@ sub LogTaskError($)
sub WrapUpAndExit($;$$)
{
- my ($Status, $Retry, $Timeout) = @_;
+ my ($Status, $Retry, $TimedOut) = @_;
my $NewVMStatus = $Status eq 'queued' ? 'offline' : 'dirty';
my $VMResult = $Status eq "boterror" ? "boterror" :
$Status eq "queued" ? "error" :
- $Timeout ? "timeout" : "";
+ $TimedOut ? "timeout" : "";
my $TestFailures;
my $Tries = $Task->TestFailures || 0;
diff --git a/testbot/bin/WineRunReconfig.pl b/testbot/bin/WineRunReconfig.pl
index e7b447e92..fe69fc3b7 100755
--- a/testbot/bin/WineRunReconfig.pl
+++ b/testbot/bin/WineRunReconfig.pl
@@ -195,12 +195,12 @@ sub LogTaskError($)
sub WrapUpAndExit($;$$)
{
- my ($Status, $Retry, $Timeout) = @_;
+ my ($Status, $Retry, $TimedOut) = @_;
my $NewVMStatus = $Status eq 'queued' ? 'offline' :
$Status eq 'completed' ? 'idle' : 'dirty';
my $VMResult = $Status eq "boterror" ? "boterror" :
$Status eq "queued" ? "error" :
- $Timeout ? "timeout" : "";
+ $TimedOut ? "timeout" : "";
my $TestFailures;
my $Tries = $Task->TestFailures || 0;
diff --git a/testbot/bin/WineRunTask.pl b/testbot/bin/WineRunTask.pl
index 3b0ccbc4a..e10656ed8 100755
--- a/testbot/bin/WineRunTask.pl
+++ b/testbot/bin/WineRunTask.pl
@@ -226,11 +226,11 @@ sub LogTaskError($)
sub WrapUpAndExit($;$$$)
{
- my ($Status, $TestFailures, $Retry, $Timeout) = @_;
+ my ($Status, $TestFailures, $Retry, $TimedOut) = @_;
my $NewVMStatus = $Status eq 'queued' ? 'offline' : 'dirty';
my $VMResult = $Status eq "boterror" ? "boterror" :
$Status eq "queued" ? "error" :
- $Timeout ? "timeout" : "";
+ $TimedOut ? "timeout" : "";
Debug(Elapsed($Start), " Taking a screenshot\n");
TakeScreenshot($VM, "$TaskDir/screenshot.png");
--
2.17.1
June 20, 2018
[PATCH] testbot/build: Detect patches that impact more than the tests.
by Francois Gouget
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
testbot/bin/build/Build.pl | 2 +-
testbot/lib/WineTestBot/PatchUtils.pm | 101 ++++++++++++++++----------
2 files changed, 64 insertions(+), 39 deletions(-)
diff --git a/testbot/bin/build/Build.pl b/testbot/bin/build/Build.pl
index 3fe0e14ea..8318af12a 100755
--- a/testbot/bin/build/Build.pl
+++ b/testbot/bin/build/Build.pl
@@ -246,7 +246,7 @@ exit(1) if (!$Impacts);
CountCPUs();
-if (!BuildNative())
+if ($Impacts->{WineBuild} and !BuildNative())
{
exit(1);
}
diff --git a/testbot/lib/WineTestBot/PatchUtils.pm b/testbot/lib/WineTestBot/PatchUtils.pm
index 6eb8e3cd8..f83df6087 100644
--- a/testbot/lib/WineTestBot/PatchUtils.pm
+++ b/testbot/lib/WineTestBot/PatchUtils.pm
@@ -36,6 +36,23 @@ our @EXPORT = qw(GetPatchImpact UpdateWineData);
use WineTestBot::Config;
+# Patches to these paths don't impact the Wine build. So ignore them.
+my $IgnoredPathsRe = join('|',
+ '\.mailmap$',
+ 'ANNOUNCE$',
+ 'AUTHORS$',
+ 'COPYING\.LIB$',
+ 'LICENSE\$',
+ 'LICENSE\.OLD$',
+ 'MAINTAINERS$',
+ 'README$',
+ 'VERSION$',
+ 'documentation/',
+ 'tools/c2man\.pl$',
+ 'tools/winapi/',
+ 'tools/winemaker/',
+);
+
=pod
=over 12
@@ -102,46 +119,54 @@ sub GetTestList()
return $TestList;
}
-sub _AddTest($$$)
+sub _HandleFile($$$)
{
my ($Impacts, $Path, $Change) = @_;
- return if ($Path !~ m~^(dlls|programs)/([^/]+)/tests/([^/\s]+)$~);
- my ($Root, $Module, $File) = ($1, $2, $3);
-
- my $Tests = $Impacts->{Tests};
- if (!$Tests->{$Module})
+ if ($Path =~ m~^(dlls|programs)/([^/]+)/tests/([^/\s]+)$~)
{
- my $ExeBase = ($Root eq "programs") ? "${Module}.exe_test" :
- "${Module}_test";
- $Tests->{$Module} = {
- "Module" => $Module,
- "Path" => "$Root/$Module/tests",
- "ExeBase" => $ExeBase,
- };
- }
+ my ($Root, $Module, $File) = ($1, $2, $3);
+ $Impacts->{TestBuild} = 1;
- # Assume makefile modifications may break the build but not the tests
- if ($File eq "Makefile.in")
- {
- if ($Change eq "new" or $Change eq "rm")
+ my $Tests = $Impacts->{Tests};
+ if (!$Tests->{$Module})
{
- # This adds / removes a directory
- $Impacts->{Makefiles} = 1;
+ my $ExeBase = ($Root eq "programs") ? "${Module}.exe_test" :
+ "${Module}_test";
+ $Tests->{$Module} = {
+ "Module" => $Module,
+ "Path" => "$Root/$Module/tests",
+ "ExeBase" => $ExeBase,
+ };
}
- return;
- }
- return if ($Impacts->{NoUnits});
- if (!$Tests->{$Module}->{Files})
- {
- my $TestList = ( $Impacts->{TestList} ||= GetTestList() );
- foreach my $File (keys %{$TestList->{$Module}})
+ # Assume makefile modifications may break the build but not the tests
+ if ($File eq "Makefile.in")
{
- $Tests->{$Module}->{Files}->{$File} = 0; # not modified
+ if ($Change eq "new" or $Change eq "rm")
+ {
+ # This adds / removes a directory
+ $Impacts->{Makefiles} = 1;
+ }
+ return;
}
+ return if ($Impacts->{NoUnits});
+
+ if (!$Tests->{$Module}->{Files})
+ {
+ my $TestList = ( $Impacts->{TestList} ||= GetTestList() );
+ foreach my $File (keys %{$TestList->{$Module}})
+ {
+ $Tests->{$Module}->{Files}->{$File} = 0; # not modified
+ }
+ }
+ $Tests->{$Module}->{Files}->{$File} = $Change;
+ }
+ else
+ {
+ # Figure out if this patch impacts the Wine build
+ $Impacts->{WineBuild} = 1 if ($Path !~ /^(?:$IgnoredPathsRe)/);
}
- $Tests->{$Module}->{Files}->{$File} = $Change;
}
=pod
@@ -176,8 +201,8 @@ sub GetPatchImpact($;$$)
{
foreach my $File (keys %{$PastInfo->{Files}})
{
- _AddTest($Impacts, "$PastInfo->{Path}/$File",
- $PastInfo->{Files}->{$File} eq "rm" ? "rm" : 0);
+ _HandleFile($Impacts, "$PastInfo->{Path}/$File",
+ $PastInfo->{Files}->{$File} eq "rm" ? "rm" : 0);
}
}
}
@@ -187,33 +212,33 @@ sub GetPatchImpact($;$$)
{
if ($Line =~ m=^--- \w+/(?:aclocal\.m4|configure\.ac)$=)
{
- $Impacts->{Autoconf} = 1;
+ $Impacts->{WineBuild} = $Impacts->{Autoconf} = 1;
}
elsif ($Line =~ m=^--- \w+/configure$=)
{
- $Impacts->{HasConfigure} = 1;
+ $Impacts->{WineBuild} = $Impacts->{HasConfigure} = 1;
}
elsif ($Line =~ m=^--- \w+/tools/make_makefiles$=)
{
- $Impacts->{Makefiles} = 1;
+ $Impacts->{WineBuild} = $Impacts->{Makefiles} = 1;
}
elsif ($Line =~ m=^--- /dev/null$=)
{
$Change = "new";
}
- elsif ($Line =~ m~^--- \w+/([^/]+/[^/]+/tests/[^/\s]+)$~)
+ elsif ($Line =~ m~^--- \w+/([^\s]+)$~)
{
$Path = $1;
}
elsif ($Line =~ m~^\+\+\+ /dev/null$~)
{
- _AddTest($Impacts, $Path, "rm") if (defined $Path);
+ _HandleFile($Impacts, $Path, "rm") if (defined $Path);
$Path = undef;
$Change = "";
}
- elsif ($Line =~ m~^\+\+\+ \w+/(\w+/[^/]+/tests/[^/\s]+)$~)
+ elsif ($Line =~ m~^\+\+\+ \w+/([^\s]+)$~)
{
- _AddTest($Impacts, $1, $Change || "modify");
+ _HandleFile($Impacts, $1, $Change || "modify");
$Path = undef;
$Change = "";
}
--
2.17.1
June 20, 2018
[PATCH] testbot: Adjust the reconfig timeout.
by Francois Gouget
$ReconfigTimeout was way overestimated, maybe reflecting a time when
either the TestBot or the Wine dependencies were causing too many files
to be rebuilt.
Note that $BuildTimeout is a bit large too: a patch touching a test
module and a core header would typically only require about 2.5
minutes. But in the unlikely event where that patch touched dozens of
test modules it may still be too short. So $BuildTimeout is left
unchanged.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
testbot/lib/WineTestBot/Config.pm | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/testbot/lib/WineTestBot/Config.pm b/testbot/lib/WineTestBot/Config.pm
index b7d633db6..66cb813ff 100644
--- a/testbot/lib/WineTestBot/Config.pm
+++ b/testbot/lib/WineTestBot/Config.pm
@@ -97,9 +97,10 @@ $SingleTimeout = 2 * 60;
# How long to let a regular build run before forcibly shutting it down
# (in seconds).
$BuildTimeout = 5 * 60;
-# How long to let a full recompilation run before forcibly shutting it down
-# (in seconds).
-$ReconfigTimeout = 45 * 60;
+# How long to let a reconfig task run before forcibly shutting it down
+# (in seconds). Note that this includes building the native Wine build tools,
+# and the 32 and 64 bit test executables.
+$ReconfigTimeout = (1 + 2 * 5) * 60;
# How much to add to the task timeout to account for file transfers, etc.
$TimeoutMargin = 2 * 60;
# Maximum amount of traces for a test unit.
--
2.17.1
June 20, 2018
[PATCH] testbot: Simplify a loop in PatchUtils::GetPatchImpact().
by Francois Gouget
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
---
testbot/lib/WineTestBot/PatchUtils.pm | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/testbot/lib/WineTestBot/PatchUtils.pm b/testbot/lib/WineTestBot/PatchUtils.pm
index ec609d987..6eb8e3cd8 100644
--- a/testbot/lib/WineTestBot/PatchUtils.pm
+++ b/testbot/lib/WineTestBot/PatchUtils.pm
@@ -227,10 +227,8 @@ sub GetPatchImpact($;$$)
$Impacts->{ModuleCount} = 0;
$Impacts->{UnitCount} = 0;
- foreach my $Module (keys %{$Impacts->{Tests}})
+ foreach my $TestInfo (values %{$Impacts->{Tests}})
{
- my $TestInfo = $Impacts->{Tests}->{$Module};
-
# For each module, identify modifications to non-C files and helper dlls
my $AllUnits;
foreach my $File (keys %{$TestInfo->{Files}})
--
2.17.1
June 20, 2018
K32EnumDeviceDrivers
by Anthony Lauzon
Hi All,
I've been hacking away at K32EnumDeviceDrivers trying to get it to properly
handle calls, and have made some decent progress that maybe some of you who
are experts can finish. The reason why I am trying to implement
K32EnumDeviceDrivers is that Creative's Emulator X3 crashes when trying to
call it. I've managed to get the app one step closer to launching with
this K32EnumDeviceDrivers implementation, which does in fact enumerate the
devices, and am now stuck on a different error. I hope this patch is of
some utility to you all.
Anthony
June 19, 2018
[PATCH 2/2] winedbg: Suppress all message boxes if ShowCrashDialog is disabled.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
The only message box shown by this function is the aforementioned
'failed to attach to process' error, but in general the user probably
doesn't want any windows to be shown if ShowCrashDialog is disabled.
programs/winedbg/crashdlg.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/programs/winedbg/crashdlg.c b/programs/winedbg/crashdlg.c
index 4e02a4b..5eb3d27 100644
--- a/programs/winedbg/crashdlg.c
+++ b/programs/winedbg/crashdlg.c
@@ -34,13 +34,18 @@
static char *crash_log;
-int msgbox_res_id(HWND hwnd, UINT textId, UINT captionId, UINT uType)
+int msgbox_res_id(HWND hwnd, UINT textid, UINT captionid, UINT type)
{
- WCHAR caption[256];
- WCHAR text[256];
- LoadStringW(GetModuleHandleW(NULL), captionId, caption, sizeof(caption)/sizeof(caption[0]));
- LoadStringW(GetModuleHandleW(NULL), textId, text, sizeof(text)/sizeof(text[0]));
- return MessageBoxW(hwnd, text, caption, uType);
+ if (DBG_IVAR(ShowCrashDialog))
+ {
+ WCHAR caption[256];
+ WCHAR text[256];
+ LoadStringW(GetModuleHandleW(NULL), captionid, caption, ARRAY_SIZE(caption));
+ LoadStringW(GetModuleHandleW(NULL), textid, text, ARRAY_SIZE(text));
+ return MessageBoxW(hwnd, text, caption, type);
+ }
+
+ return IDCANCEL;
}
static WCHAR *get_program_name(HANDLE hProcess)
--
2.7.4
June 19, 2018
[PATCH 1/2] winedbg: Provide a more helpful error message when unable to attach to a process.
by Zebediah Figura
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
If anyone has suggestions for better wording, feel free to speak.
programs/winedbg/winedbg.rc | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/programs/winedbg/winedbg.rc b/programs/winedbg/winedbg.rc
index 2cfaf9e..7ad7686 100644
--- a/programs/winedbg/winedbg.rc
+++ b/programs/winedbg/winedbg.rc
@@ -34,8 +34,9 @@ END
STRINGTABLE
BEGIN
- IDS_AUTO_CAPTION "Wine program crash"
- IDS_INVALID_PARAMS "Internal errors - invalid parameters received"
+ IDS_AUTO_CAPTION "Program Error"
+ IDS_INVALID_PARAMS "A program on your system has crashed, but WineDbg was \
+ unable to attach to the process to obtain a backtrace."
IDS_UNIDENTIFIED "(unidentified)"
IDS_TEXT_FILES, "Text files (*.txt)"
IDS_ALL_FILES, "All files (*.*)"
--
2.7.4
June 19, 2018
Re: [PATCH 3/6] d3d9/tests: Add test for depth stencil initialization.
by Marvin
Hi,
While running your changed tests on Windows, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at
https://testbot.winehq.org/JobDetails.pl?Key=39233
Your paranoid android.
=== w1064 (32 bit visual) ===
visual.c:8620: Test failed: Got unexpected color 0x00007580 for quad 2 (different colors).
June 19, 2018
[PATCH 6/6] wined3d: Call wined3d_cs_emit_update_sub_resource() directly in buffer_init().
by Józef Kucia
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
dlls/wined3d/buffer.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 4b14d684e542..181be6bbe487 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1325,6 +1325,8 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format *format = wined3d_get_format(gl_info, format_id, usage);
+ struct wined3d_resource *resource = &buffer->resource;
+ struct wined3d_box box;
BOOL dynamic_buffer_ok;
HRESULT hr;
@@ -1346,7 +1348,7 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
return E_INVALIDARG;
}
- if (FAILED(hr = resource_init(&buffer->resource, device, WINED3D_RTYPE_BUFFER, format, WINED3D_MULTISAMPLE_NONE,
+ if (FAILED(hr = resource_init(resource, device, WINED3D_RTYPE_BUFFER, format, WINED3D_MULTISAMPLE_NONE,
0, usage, access, size, 1, 1, size, parent, parent_ops, &buffer_resource_ops)))
{
WARN("Failed to initialize resource, hr %#x.\n", hr);
@@ -1386,7 +1388,7 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
{
TRACE("Not creating a BO because the buffer is not GPU accessible.\n");
}
- else if (!dynamic_buffer_ok && (buffer->resource.usage & WINED3DUSAGE_DYNAMIC))
+ else if (!dynamic_buffer_ok && (resource->usage & WINED3DUSAGE_DYNAMIC))
{
TRACE("Not creating a BO because the buffer has dynamic usage and no GL support.\n");
}
@@ -1398,16 +1400,19 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
if (!(buffer->maps = heap_alloc(sizeof(*buffer->maps))))
{
ERR("Out of memory.\n");
- buffer_unload(&buffer->resource);
- resource_cleanup(&buffer->resource);
- wined3d_resource_wait_idle(&buffer->resource);
+ buffer_unload(resource);
+ resource_cleanup(resource);
+ wined3d_resource_wait_idle(resource);
return E_OUTOFMEMORY;
}
buffer->maps_size = 1;
if (data)
- wined3d_device_update_sub_resource(device, &buffer->resource,
- 0, NULL, data->data, data->row_pitch, data->slice_pitch, 0);
+ {
+ wined3d_box_set(&box, 0, 0, resource->size, 1, 0, 1);
+ wined3d_cs_emit_update_sub_resource(device->cs, resource,
+ 0, &box, data->data, data->row_pitch, data->slice_pitch);
+ }
return WINED3D_OK;
}
--
2.16.4
June 19, 2018
[PATCH 5/6] wined3d: Use WINED3D_LOCATION_DISCARDED before initializing buffers with data.
by Józef Kucia
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
dlls/wined3d/buffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index e06d156c0b3f..4b14d684e542 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1354,7 +1354,7 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
}
buffer->buffer_type_hint = buffer_type_hint_from_bind_flags(gl_info, bind_flags);
buffer->bind_flags = bind_flags;
- buffer->locations = WINED3D_LOCATION_SYSMEM;
+ buffer->locations = data ? WINED3D_LOCATION_DISCARDED : WINED3D_LOCATION_SYSMEM;
if (!wined3d_resource_allocate_sysmem(&buffer->resource))
return E_OUTOFMEMORY;
--
2.16.4
June 19, 2018
[PATCH 4/6] wined3d: Reduce nesting in texture2d_load_sysmem().
by Józef Kucia
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
dlls/wined3d/surface.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 521703314d0c..5502d055c263 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -198,7 +198,6 @@ static void texture2d_blt_fbo(const struct wined3d_device *device, struct wined3
else
wined3d_texture_prepare_location(dst_texture, dst_sub_resource_idx, context, dst_location);
-
if (src_location == WINED3D_LOCATION_DRAWABLE)
{
required_texture = src_texture;
@@ -1655,21 +1654,18 @@ BOOL texture2d_load_sysmem(struct wined3d_texture *texture, unsigned int sub_res
WINED3D_LOCATION_RB_RESOLVED, dst_location);
return TRUE;
}
- else
- {
- if (sub_resource->locations & (WINED3D_LOCATION_RB_MULTISAMPLE | WINED3D_LOCATION_RB_RESOLVED))
- wined3d_texture_load_location(texture, sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB);
- /* Download the sub-resource to system memory. */
- if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
- {
- wined3d_texture_bind_and_dirtify(texture, context,
- !(sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB));
- texture2d_download_data(texture, sub_resource_idx, context, dst_location);
- ++texture->download_count;
+ if (sub_resource->locations & (WINED3D_LOCATION_RB_MULTISAMPLE | WINED3D_LOCATION_RB_RESOLVED))
+ wined3d_texture_load_location(texture, sub_resource_idx, context, WINED3D_LOCATION_TEXTURE_RGB);
- return TRUE;
- }
+ /* Download the sub-resource to system memory. */
+ if (sub_resource->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
+ {
+ wined3d_texture_bind_and_dirtify(texture, context,
+ !(sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB));
+ texture2d_download_data(texture, sub_resource_idx, context, dst_location);
+ ++texture->download_count;
+ return TRUE;
}
if (!(texture->resource.usage & WINED3DUSAGE_DEPTHSTENCIL)
--
2.16.4
June 19, 2018
[PATCH 3/6] d3d9/tests: Add test for depth stencil initialization.
by Józef Kucia
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
dlls/d3d9/tests/visual.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 115 insertions(+)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 95982e051556..b36c1890392c 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -211,6 +211,34 @@ static DWORD getPixelColor(IDirect3DDevice9 *device, UINT x, UINT y)
return ret;
}
+#define check_rt_color(a, b) check_rt_color_(__LINE__, a, b)
+static void check_rt_color_(unsigned int line, IDirect3DSurface9 *rt, D3DCOLOR expected_color)
+{
+ struct surface_readback rb;
+ D3DSURFACE_DESC desc;
+ unsigned int x, y;
+ D3DCOLOR color;
+ HRESULT hr;
+
+ hr = IDirect3DSurface9_GetDesc(rt, &desc);
+ ok_(__FILE__, line)(hr == S_OK, "Failed to get surface desc, hr %#x.\n", hr);
+
+ get_rt_readback(rt, &rb);
+ for (y = 0; y < desc.Height; ++y)
+ {
+ for (x = 0; x < desc.Width; ++x)
+ {
+ color = get_readback_color(&rb, x, y) & 0x00ffffff;
+ if (color != expected_color)
+ break;
+ }
+ if (color != expected_color)
+ break;
+ }
+ release_surface_readback(&rb);
+ ok_(__FILE__, line)(color == 0x000000ff, "Got unexpected color 0x%08x.\n", color);
+}
+
static IDirect3DDevice9 *create_device(IDirect3D9 *d3d, HWND device_window, HWND focus_window, BOOL windowed)
{
D3DPRESENT_PARAMETERS present_parameters = {0};
@@ -21406,6 +21434,92 @@ done:
DestroyWindow(window);
}
+static void test_depth_stencil_init(void)
+{
+ IDirect3DDevice9 *device;
+ IDirect3DSurface9 *ds[2];
+ IDirect3DSurface9 *rt;
+ IDirect3D9 *d3d;
+ ULONG refcount;
+ unsigned int i;
+ HWND window;
+ HRESULT hr;
+
+ static const struct
+ {
+ struct vec3 position;
+ }
+ quad[] =
+ {
+ {{-1.0f, -1.0f, 0.0f}},
+ {{-1.0f, 1.0f, 0.0f}},
+ {{ 1.0f, -1.0f, 0.0f}},
+ {{ 1.0f, 1.0f, 0.0f}},
+ };
+
+ window = create_window();
+ d3d = Direct3DCreate9(D3D_SDK_VERSION);
+ ok(!!d3d, "Failed to create D3D object.\n");
+ if (!(device = create_device(d3d, window, window, TRUE)))
+ {
+ skip("Failed to create D3D device.\n");
+ goto done;
+ }
+
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+ ok(hr == S_OK, "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE);
+ ok(hr == S_OK, "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
+ ok(hr == S_OK, "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
+ ok(hr == S_OK, "Failed to set color op, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
+ ok(hr == S_OK, "Failed to set color arg, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ);
+ ok(hr == S_OK, "Failed to set FVF, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 640, 480, D3DFMT_D24S8, 0, 0, FALSE, &ds[0], NULL);
+ ok(hr == S_OK, "Failed to create depth stencil surface, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_GetDepthStencilSurface(device, &ds[1]);
+ ok(hr == S_OK, "Failed to get depth stencil surface, hr %#x.\n", hr);
+
+ for (i = 0; i < ARRAY_SIZE(ds); ++i)
+ {
+ hr = IDirect3DDevice9_SetDepthStencilSurface(device, ds[i]);
+ ok(hr == S_OK, "Failed to set depth stencil surface, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0);
+ ok(hr == S_OK, "Failed to clear, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_BeginScene(device);
+ ok(hr == S_OK, "Failed to begin scene, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_SetRenderState(device, D3DRS_TEXTUREFACTOR, 0x000000ff);
+ ok(hr == S_OK, "Failed to set render state, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad));
+ ok(hr == S_OK, "Failed to draw, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_EndScene(device);
+ ok(hr == S_OK, "Failed to end scene, hr %#x.\n", hr);
+
+ hr = IDirect3DDevice9_GetRenderTarget(device, 0, &rt);
+ ok(hr == S_OK, "Failed to get render target, hr %#x.\n", hr);
+ check_rt_color(rt, 0x000000ff);
+ IDirect3DSurface9_Release(rt);
+
+ hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
+ ok(hr == D3D_OK, "Failed to present, hr %#x.\n", hr);
+
+ IDirect3DSurface9_Release(ds[i]);
+ }
+
+ refcount = IDirect3DDevice9_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+
+done:
+ IDirect3D9_Release(d3d);
+ DestroyWindow(window);
+}
+
static void test_texture_blending(void)
{
#define STATE_END() {0xffffffff, 0xffffffff}
@@ -24037,6 +24151,7 @@ START_TEST(visual)
test_flip();
test_uninitialized_varyings();
test_multisample_init();
+ test_depth_stencil_init();
test_texture_blending();
test_color_clamping();
test_line_antialiasing_blending();
--
2.16.4
June 19, 2018
[PATCH 2/6] wined3d: Initialize depth/stencil texture data.
by Józef Kucia
Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com>
---
Fixes rendering glitches in Company of Heroes on radeonsi.
---
dlls/wined3d/texture.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 91c703c970fd..c316906a9576 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -2802,8 +2802,7 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
if (wined3d_texture_use_pbo(texture, gl_info))
texture->resource.map_binding = WINED3D_LOCATION_BUFFER;
- if ((desc->resource_type != WINED3D_RTYPE_TEXTURE_3D
- && !(texture->resource.usage & WINED3DUSAGE_DEPTHSTENCIL))
+ if (desc->resource_type != WINED3D_RTYPE_TEXTURE_3D
|| !wined3d_texture_use_pbo(texture, gl_info))
{
if (!wined3d_resource_allocate_sysmem(&texture->resource))
@@ -2842,8 +2841,7 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
sub_resource = &texture->sub_resources[i];
sub_resource->locations = WINED3D_LOCATION_DISCARDED;
- if (desc->resource_type != WINED3D_RTYPE_TEXTURE_3D
- && !(texture->resource.usage & WINED3DUSAGE_DEPTHSTENCIL))
+ if (desc->resource_type != WINED3D_RTYPE_TEXTURE_3D)
{
wined3d_texture_validate_location(texture, i, WINED3D_LOCATION_SYSMEM);
wined3d_texture_invalidate_location(texture, i, ~WINED3D_LOCATION_SYSMEM);
--
2.16.4
June 19, 2018