ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
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
List overview
Download
Ros-diffs
October 2018
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
21 participants
354 discussions
Start a n
N
ew thread
01/01: [IMAADP32.ACM] Sync with Wine Staging 3.17. CORE-15127
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d4bc0feb6e082b1d013d1…
commit d4bc0feb6e082b1d013d1e3c3fa74b22db234c37 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Oct 1 12:52:44 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Oct 1 12:52:44 2018 +0100 [IMAADP32.ACM] Sync with Wine Staging 3.17. CORE-15127 --- dll/win32/imaadp32.acm/imaadp32.c | 15 ++++++--------- media/doc/README.WINE | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/dll/win32/imaadp32.acm/imaadp32.c b/dll/win32/imaadp32.acm/imaadp32.c index 474f548582..9518adc345 100644 --- a/dll/win32/imaadp32.acm/imaadp32.c +++ b/dll/win32/imaadp32.acm/imaadp32.c @@ -79,9 +79,6 @@ static const Format ADPCM_Formats[] = {1, 4, 22050}, {2, 4, 22050}, {1, 4, 44100}, {2, 4, 44100}, }; -#define NUM_PCM_FORMATS (sizeof(PCM_Formats) / sizeof(PCM_Formats[0])) -#define NUM_ADPCM_FORMATS (sizeof(ADPCM_Formats) / sizeof(ADPCM_Formats[0])) - /*********************************************************************** * ADPCM_GetFormatIndex */ @@ -93,11 +90,11 @@ static DWORD ADPCM_GetFormatIndex(const WAVEFORMATEX *wfx) switch (wfx->wFormatTag) { case WAVE_FORMAT_PCM: - hi = NUM_PCM_FORMATS; + hi = ARRAY_SIZE(PCM_Formats); fmts = PCM_Formats; break; case WAVE_FORMAT_IMA_ADPCM: - hi = NUM_ADPCM_FORMATS; + hi = ARRAY_SIZE(ADPCM_Formats); fmts = ADPCM_Formats; break; default: @@ -585,13 +582,13 @@ static LRESULT ADPCM_FormatTagDetails(PACMFORMATTAGDETAILSW aftd, DWORD dwQuery) case 0: aftd->dwFormatTag = WAVE_FORMAT_PCM; aftd->cbFormatSize = sizeof(PCMWAVEFORMAT); - aftd->cStandardFormats = NUM_PCM_FORMATS; + aftd->cStandardFormats = ARRAY_SIZE(PCM_Formats); lstrcpyW(aftd->szFormatTag, szPcm); break; case 1: aftd->dwFormatTag = WAVE_FORMAT_IMA_ADPCM; aftd->cbFormatSize = sizeof(IMAADPCMWAVEFORMAT); - aftd->cStandardFormats = NUM_ADPCM_FORMATS; + aftd->cStandardFormats = ARRAY_SIZE(ADPCM_Formats); lstrcpyW(aftd->szFormatTag, szImaAdPcm); break; } @@ -614,7 +611,7 @@ static LRESULT ADPCM_FormatDetails(PACMFORMATDETAILSW afd, DWORD dwQuery) switch (afd->dwFormatTag) { case WAVE_FORMAT_PCM: - if (afd->dwFormatIndex >= NUM_PCM_FORMATS) return ACMERR_NOTPOSSIBLE; + if (afd->dwFormatIndex >= ARRAY_SIZE(PCM_Formats)) return ACMERR_NOTPOSSIBLE; afd->pwfx->nChannels = PCM_Formats[afd->dwFormatIndex].nChannels; afd->pwfx->nSamplesPerSec = PCM_Formats[afd->dwFormatIndex].rate; afd->pwfx->wBitsPerSample = PCM_Formats[afd->dwFormatIndex].nBits; @@ -627,7 +624,7 @@ static LRESULT ADPCM_FormatDetails(PACMFORMATDETAILSW afd, DWORD dwQuery) afd->pwfx->nSamplesPerSec * afd->pwfx->nBlockAlign; break; case WAVE_FORMAT_IMA_ADPCM: - if (afd->dwFormatIndex >= NUM_ADPCM_FORMATS) return ACMERR_NOTPOSSIBLE; + if (afd->dwFormatIndex >= ARRAY_SIZE(ADPCM_Formats)) return ACMERR_NOTPOSSIBLE; afd->pwfx->nChannels = ADPCM_Formats[afd->dwFormatIndex].nChannels; afd->pwfx->nSamplesPerSec = ADPCM_Formats[afd->dwFormatIndex].rate; afd->pwfx->wBitsPerSample = ADPCM_Formats[afd->dwFormatIndex].nBits; diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 5ab6bf344f..0583308dba 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -75,7 +75,7 @@ reactos/dll/win32/hnetcfg # Synced to WineStaging-3.9 reactos/dll/win32/httpapi # Synced to WineStaging-3.3 reactos/dll/win32/iccvid # Synced to WineStaging-3.3 reactos/dll/win32/ieframe # Synced to WineStaging-3.17 -reactos/dll/win32/imaadp32.acm # Synced to WineStaging-3.3 +reactos/dll/win32/imaadp32.acm # Synced to WineStaging-3.17 reactos/dll/win32/imagehlp # Synced to WineStaging-3.3 reactos/dll/win32/imm32 # Synced to WineStaging-3.9 reactos/dll/win32/inetcomm # Synced to WineStaging-3.3
6 years, 2 months
1
0
0
0
01/01: [IEFRAME] Sync with Wine Staging 3.17. CORE-15127
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=336b2a4564a618799628d…
commit 336b2a4564a618799628dc7bb6770beee46a7524 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Oct 1 12:52:10 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Oct 1 12:52:10 2018 +0100 [IEFRAME] Sync with Wine Staging 3.17. CORE-15127 --- dll/win32/ieframe/dochost.c | 2 +- dll/win32/ieframe/ieframe_main.c | 2 +- dll/win32/ieframe/iexplore.c | 10 +++++----- dll/win32/ieframe/intshcut.c | 4 ++-- dll/win32/ieframe/navigate.c | 10 +++++----- dll/win32/ieframe/oleobject.c | 2 +- dll/win32/ieframe/shellbrowser.c | 2 +- media/doc/README.WINE | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/dll/win32/ieframe/dochost.c b/dll/win32/ieframe/dochost.c index 424868d62e..d22ad3d18c 100644 --- a/dll/win32/ieframe/dochost.c +++ b/dll/win32/ieframe/dochost.c @@ -428,7 +428,7 @@ static void update_travellog(DocHost *This) static const WCHAR about_schemeW[] = {'a','b','o','u','t',':'}; - if(This->url && !strncmpiW(This->url, about_schemeW, sizeof(about_schemeW)/sizeof(*about_schemeW))) { + if(This->url && !strncmpiW(This->url, about_schemeW, ARRAY_SIZE(about_schemeW))) { TRACE("Skipping about URL\n"); return; } diff --git a/dll/win32/ieframe/ieframe_main.c b/dll/win32/ieframe/ieframe_main.c index a862f9afe5..e207ce0575 100644 --- a/dll/win32/ieframe/ieframe_main.c +++ b/dll/win32/ieframe/ieframe_main.c @@ -91,7 +91,7 @@ static void release_typelib(void) if(!typelib) return; - for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++) { + for(i=0; i < ARRAY_SIZE(typeinfos); i++) { if(typeinfos[i]) ITypeInfo_Release(typeinfos[i]); } diff --git a/dll/win32/ieframe/iexplore.c b/dll/win32/ieframe/iexplore.c index 8362e8053b..477d58fce6 100644 --- a/dll/win32/ieframe/iexplore.c +++ b/dll/win32/ieframe/iexplore.c @@ -263,7 +263,7 @@ static void add_tbs_to_menu(HMENU menu) WCHAR classes_key[] = {'S','o','f','t','w','a','r','e','\\', 'C','l','a','s','s','e','s','\\','C','L','S','I','D',0}; WCHAR guid[39]; - DWORD value_len = sizeof(guid)/sizeof(guid[0]); + DWORD value_len = ARRAY_SIZE(guid); int i; if(SHRegOpenUSKeyW(classes_key, KEY_READ, NULL, &classes_handle, TRUE) != ERROR_SUCCESS) @@ -276,11 +276,11 @@ static void add_tbs_to_menu(HMENU menu) for(i = 0; SHRegEnumUSValueW(toolbar_handle, i, guid, &value_len, NULL, NULL, NULL, SHREGENUM_HKLM) == ERROR_SUCCESS; i++) { WCHAR tb_name[100]; - DWORD tb_name_len = sizeof(tb_name)/sizeof(tb_name[0]); + DWORD tb_name_len = ARRAY_SIZE(tb_name); HUSKEY tb_class_handle; MENUITEMINFOW item; LSTATUS ret; - value_len = sizeof(guid)/sizeof(guid[0]); + value_len = ARRAY_SIZE(guid); if(lstrlenW(guid) != 38) { @@ -425,7 +425,7 @@ static void add_tb_button(InternetExplorer *ie, int bmp, int cmd, int strId) TBBUTTON btn; WCHAR buf[30]; - LoadStringW(ieframe_instance, strId, buf, sizeof(buf)/sizeof(buf[0])); + LoadStringW(ieframe_instance, strId, buf, ARRAY_SIZE(buf)); btn.iBitmap = bmp; btn.idCommand = cmd; @@ -452,7 +452,7 @@ static void create_rebar(InternetExplorer *ie) HIMAGELIST imagelist; SIZE toolbar_size; - LoadStringW(ieframe_instance, IDS_ADDRESS, addr, sizeof(addr)/sizeof(addr[0])); + LoadStringW(ieframe_instance, IDS_ADDRESS, addr, ARRAY_SIZE(addr)); hwndRebar = CreateWindowExW(WS_EX_TOOLWINDOW, REBARCLASSNAMEW, NULL, WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|RBS_VARHEIGHT|CCS_TOP|CCS_NODIVIDER, 0, 0, 0, 0, diff --git a/dll/win32/ieframe/intshcut.c b/dll/win32/ieframe/intshcut.c index 2376b1b424..4331bb9b0a 100644 --- a/dll/win32/ieframe/intshcut.c +++ b/dll/win32/ieframe/intshcut.c @@ -93,7 +93,7 @@ static BOOL run_winemenubuilder( const WCHAR *args ) WCHAR app[MAX_PATH]; void *redir; - GetSystemDirectoryW( app, MAX_PATH - sizeof(menubuilder)/sizeof(WCHAR) ); + GetSystemDirectoryW( app, MAX_PATH - ARRAY_SIZE( menubuilder )); strcatW( app, menubuilder ); len = (strlenW( app ) + strlenW( args ) + 1) * sizeof(WCHAR); @@ -278,7 +278,7 @@ static HRESULT WINAPI UniformResourceLocatorW_InvokeCommand(IUniformResourceLoca return E_NOTIMPL; } - hres = CoInternetParseUrl(This->url, PARSE_SCHEMA, 0, app, sizeof(app)/sizeof(WCHAR), NULL, 0); + hres = CoInternetParseUrl(This->url, PARSE_SCHEMA, 0, app, ARRAY_SIZE(app), NULL, 0); if(FAILED(hres)) return E_FAIL; diff --git a/dll/win32/ieframe/navigate.c b/dll/win32/ieframe/navigate.c index 658857fadd..96fb083005 100644 --- a/dll/win32/ieframe/navigate.c +++ b/dll/win32/ieframe/navigate.c @@ -111,7 +111,7 @@ static void set_status_text(BindStatusCallback *This, ULONG statuscode, LPCWSTR fmt[0] = 0; /* the format string must have one "%s" for the str */ LoadStringW(ieframe_instance, IDS_STATUSFMT_FIRST + statuscode, fmt, IDS_STATUSFMT_MAXLEN); - snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), fmt, str); + snprintfW(buffer, ARRAY_SIZE(buffer), fmt, str); } V_VT(&arg) = VT_BSTR; @@ -576,7 +576,7 @@ static void on_before_navigate2(DocHost *This, LPCWSTR url, SAFEARRAY *post_data DISPPARAMS dispparams; VARIANTARG params[7]; WCHAR file_path[MAX_PATH]; - DWORD file_path_len = sizeof(file_path) / sizeof(*file_path); + DWORD file_path_len = ARRAY_SIZE(file_path); dispparams.cArgs = 7; dispparams.cNamedArgs = 0; @@ -642,7 +642,7 @@ static BOOL try_application_url(LPCWSTR url) static const WCHAR wszURLProtocol[] = {'U','R','L',' ','P','r','o','t','o','c','o','l',0}; - hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, app, sizeof(app)/sizeof(WCHAR), NULL, 0); + hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, app, ARRAY_SIZE(app), NULL, 0); if(FAILED(hres)) return FALSE; @@ -674,7 +674,7 @@ static HRESULT create_moniker(LPCWSTR url, IMoniker **mon) if(PathIsURLW(url)) return CreateURLMoniker(NULL, url, mon); - size = sizeof(new_url)/sizeof(WCHAR); + size = ARRAY_SIZE(new_url); hres = UrlApplySchemeW(url, new_url, &size, URL_APPLY_GUESSSCHEME | URL_APPLY_GUESSFILE | URL_APPLY_DEFAULT); TRACE("was %s got %s\n", debugstr_w(url), debugstr_w(new_url)); if(FAILED(hres)) { @@ -978,7 +978,7 @@ HRESULT navigate_url(DocHost *This, LPCWSTR url, const VARIANT *Flags, }else { DWORD size; - size = sizeof(new_url)/sizeof(WCHAR); + size = ARRAY_SIZE(new_url); hres = UrlApplySchemeW(url, new_url, &size, URL_APPLY_GUESSSCHEME | URL_APPLY_GUESSFILE | URL_APPLY_DEFAULT); if(FAILED(hres)) { diff --git a/dll/win32/ieframe/oleobject.c b/dll/win32/ieframe/oleobject.c index 1ff9a92666..22fe4b1848 100644 --- a/dll/win32/ieframe/oleobject.c +++ b/dll/win32/ieframe/oleobject.c @@ -385,7 +385,7 @@ static HRESULT WINAPI EnumOLEVERB_Next(IEnumOLEVERB *iface, ULONG celt, OLEVERB if(pceltFetched) *pceltFetched = 0; - if(This->iter == sizeof(verbs)/sizeof(*verbs)) + if(This->iter == ARRAY_SIZE(verbs)) return S_FALSE; if(celt) diff --git a/dll/win32/ieframe/shellbrowser.c b/dll/win32/ieframe/shellbrowser.c index f75689e49a..78e0e85a79 100644 --- a/dll/win32/ieframe/shellbrowser.c +++ b/dll/win32/ieframe/shellbrowser.c @@ -658,7 +658,7 @@ static HRESULT WINAPI DocObjectService_FireBeforeNavigate2( VARIANT_BOOL cancel = VARIANT_FALSE; SAFEARRAY *post_data; WCHAR file_path[MAX_PATH]; - DWORD file_path_len = sizeof(file_path) / sizeof(*file_path); + DWORD file_path_len = ARRAY_SIZE(file_path); TRACE("%p %p %s %x %s %p %d %s %d %p\n", This, pDispatch, debugstr_w(lpszUrl), dwFlags, debugstr_w(lpszFrameName), pPostData, cbPostData, diff --git a/media/doc/README.WINE b/media/doc/README.WINE index e74dc1f150..5ab6bf344f 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -74,7 +74,7 @@ reactos/dll/win32/hlink # Synced to WineStaging-3.3 reactos/dll/win32/hnetcfg # Synced to WineStaging-3.9 reactos/dll/win32/httpapi # Synced to WineStaging-3.3 reactos/dll/win32/iccvid # Synced to WineStaging-3.3 -reactos/dll/win32/ieframe # Synced to WineStaging-3.9 +reactos/dll/win32/ieframe # Synced to WineStaging-3.17 reactos/dll/win32/imaadp32.acm # Synced to WineStaging-3.3 reactos/dll/win32/imagehlp # Synced to WineStaging-3.3 reactos/dll/win32/imm32 # Synced to WineStaging-3.9
6 years, 2 months
1
0
0
0
01/01: [HHCTRL.OCX] Sync with Wine Staging 3.17. CORE-15127
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a214feb6fea63693fc939…
commit a214feb6fea63693fc93922a4d17c262d239cad4 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Oct 1 12:51:35 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Oct 1 12:51:35 2018 +0100 [HHCTRL.OCX] Sync with Wine Staging 3.17. CORE-15127 --- dll/win32/hhctrl.ocx/chm.c | 12 ++++++------ dll/win32/hhctrl.ocx/help.c | 6 +++--- media/doc/README.WINE | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dll/win32/hhctrl.ocx/chm.c b/dll/win32/hhctrl.ocx/chm.c index 8cf2539d71..01403368b0 100644 --- a/dll/win32/hhctrl.ocx/chm.c +++ b/dll/win32/hhctrl.ocx/chm.c @@ -483,12 +483,12 @@ LPCWSTR skip_schema(LPCWSTR url) static const WCHAR msits_schema[] = {'m','s','-','i','t','s',':'}; static const WCHAR mk_schema[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':'}; - if(!strncmpiW(its_schema, url, sizeof(its_schema)/sizeof(WCHAR))) - return url+sizeof(its_schema)/sizeof(WCHAR); - if(!strncmpiW(msits_schema, url, sizeof(msits_schema)/sizeof(WCHAR))) - return url+sizeof(msits_schema)/sizeof(WCHAR); - if(!strncmpiW(mk_schema, url, sizeof(mk_schema)/sizeof(WCHAR))) - return url+sizeof(mk_schema)/sizeof(WCHAR); + if(!strncmpiW(its_schema, url, ARRAY_SIZE(its_schema))) + return url + ARRAY_SIZE(its_schema); + if(!strncmpiW(msits_schema, url, ARRAY_SIZE(msits_schema))) + return url + ARRAY_SIZE(msits_schema); + if(!strncmpiW(mk_schema, url, ARRAY_SIZE(mk_schema))) + return url + ARRAY_SIZE(mk_schema); return url; } diff --git a/dll/win32/hhctrl.ocx/help.c b/dll/win32/hhctrl.ocx/help.c index c7a2a7a9e2..75b28f2f57 100644 --- a/dll/win32/hhctrl.ocx/help.c +++ b/dll/win32/hhctrl.ocx/help.c @@ -241,7 +241,7 @@ static BOOL AppendFullPathURL(LPCWSTR file, LPWSTR buf, LPCWSTR index) TRACE("%s %p %s\n", debugstr_w(file), buf, debugstr_w(index)); - if(!GetFullPathNameW(file, sizeof(full_path)/sizeof(full_path[0]), full_path, NULL)) { + if (!GetFullPathNameW(file, ARRAY_SIZE(full_path), full_path, NULL)) { WARN("GetFullPathName failed: %u\n", GetLastError()); return FALSE; } @@ -1830,7 +1830,7 @@ HHInfo *CreateHelpViewer(HHInfo *info, LPCWSTR filename, HWND caller) /* Set the invalid tab ID (-1) as the default value for all * of the tabs, this matches a failed TCM_INSERTITEM call. */ - for(i=0;i<sizeof(info->tabs)/sizeof(HHTab);i++) + for (i = 0; i < ARRAY_SIZE(info->tabs); i++) info->tabs[i].id = -1; OleInitialize(NULL); @@ -1867,7 +1867,7 @@ HHInfo *CreateHelpViewer(HHInfo *info, LPCWSTR filename, HWND caller) */ static char find_html_symbol(const char *entity, int entity_len) { - int max = sizeof(html_encoded_symbols)/sizeof(html_encoded_symbols[0])-1; + int max = ARRAY_SIZE(html_encoded_symbols)-1; int min = 0, dir; while(min <= max) diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 34f5a994cf..e74dc1f150 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -69,7 +69,7 @@ reactos/dll/win32/faultrep # Synced to WineStaging-2.9 reactos/dll/win32/fontsub # Synced to WineStaging-2.9 reactos/dll/win32/fusion # Synced to WineStaging-3.17 reactos/dll/win32/gdiplus # Synced to WineStaging-3.17 -reactos/dll/win32/hhctrl.ocx # Synced to WineStaging-3.3 +reactos/dll/win32/hhctrl.ocx # Synced to WineStaging-3.17 reactos/dll/win32/hlink # Synced to WineStaging-3.3 reactos/dll/win32/hnetcfg # Synced to WineStaging-3.9 reactos/dll/win32/httpapi # Synced to WineStaging-3.3
6 years, 2 months
1
0
0
0
01/01: [GDIPLUS_WINETEST] Sync with Wine Staging 3.17. CORE-15127
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3e9224d013a9ff5102ba9…
commit 3e9224d013a9ff5102ba9d99c383445b6ede9663 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Oct 1 12:50:59 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Oct 1 12:50:59 2018 +0100 [GDIPLUS_WINETEST] Sync with Wine Staging 3.17. CORE-15127 --- modules/rostests/winetests/gdiplus/graphics.c | 58 +++++++++++++++++++++-- modules/rostests/winetests/gdiplus/graphicspath.c | 58 +++++++++++------------ modules/rostests/winetests/gdiplus/image.c | 40 ++++++++-------- 3 files changed, 102 insertions(+), 54 deletions(-) diff --git a/modules/rostests/winetests/gdiplus/graphics.c b/modules/rostests/winetests/gdiplus/graphics.c index 6acc656c8f..b0e3d8232b 100644 --- a/modules/rostests/winetests/gdiplus/graphics.c +++ b/modules/rostests/winetests/gdiplus/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; @@ -2148,6 +2194,7 @@ static void test_clip_xform(void) expect(0xff, color); GdipDeleteGraphics(graphics); + GdipDeleteRegion(clip); ReleaseDC(hwnd, hdc); } @@ -3721,7 +3768,7 @@ static void test_GdipMeasureString(void) expect(Ok, status); expect(UnitPixel, font_unit); - for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) + for (i = 0; i < ARRAY_SIZE(td); i++) { GpImage *image; @@ -3799,7 +3846,7 @@ todo_wine expect(Ok, status); expect(unit, font_unit); - for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) + for (i = 0; i < ARRAY_SIZE(td); i++) { REAL unit_scale; GpImage *image; @@ -3883,7 +3930,7 @@ todo_wine } /* Font with units = UnitWorld */ - for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) + for (i = 0; i < ARRAY_SIZE(td); i++) { GpPointF pt = {0.0, 100.0}; GpImage* image; @@ -3972,7 +4019,7 @@ static void test_transform(void) GpPointF ptf[2]; UINT i; - for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) + for (i = 0; i < ARRAY_SIZE(td); i++) { graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].scale, &image); ptf[0].X = td[i].in[0].X; @@ -4032,7 +4079,7 @@ static void test_pen_thickness(void) BitmapData bd; INT min, max, size; - for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) + for (i = 0; i < ARRAY_SIZE(td); i++) { status = GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat24bppRGB, NULL, &u.bitmap); expect(Ok, status); @@ -6795,6 +6842,7 @@ START_TEST(graphics) test_GdipDrawImagePointsRect(); test_GdipFillClosedCurve(); test_GdipFillClosedCurveI(); + test_GdipFillPath(); test_GdipDrawString(); test_GdipGetNearestColor(); test_GdipGetVisibleClipBounds(); diff --git a/modules/rostests/winetests/gdiplus/graphicspath.c b/modules/rostests/winetests/gdiplus/graphicspath.c index c5403cbe0e..096fbc600a 100644 --- a/modules/rostests/winetests/gdiplus/graphicspath.c +++ b/modules/rostests/winetests/gdiplus/graphicspath.c @@ -207,7 +207,7 @@ static void test_line2(void) status = GdipAddPathLine2(path, &(line2_points[6]), 3); expect(Ok, status); - ok_path(path, line2_path, sizeof(line2_path)/sizeof(path_test_t), FALSE); + ok_path(path, line2_path, ARRAY_SIZE(line2_path), FALSE); GdipDeletePath(path); } @@ -278,7 +278,7 @@ static void test_arc(void) status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 50.0, 0.0); expect(Ok, status); - ok_path(path, arc_path, sizeof(arc_path)/sizeof(path_test_t), FALSE); + ok_path(path, arc_path, ARRAY_SIZE(arc_path), FALSE); GdipDeletePath(path); } @@ -458,7 +458,7 @@ static void test_pathpath(void) status = GdipAddPathPath(path1, path2, TRUE); expect(Ok, status); - ok_path(path1, pathpath_path, sizeof(pathpath_path)/sizeof(path_test_t), FALSE); + ok_path(path1, pathpath_path, ARRAY_SIZE(pathpath_path), FALSE); GdipDeletePath(path1); GdipDeletePath(path2); @@ -529,7 +529,7 @@ static void test_ellipse(void) status = GdipAddPathEllipse(path, 10.0, 300.0, 0.0, 1.0); expect(Ok, status); - ok_path(path, ellipse_path, sizeof(ellipse_path)/sizeof(path_test_t), FALSE); + ok_path(path, ellipse_path, ARRAY_SIZE(ellipse_path), FALSE); GdipDeletePath(path); } @@ -565,7 +565,7 @@ static void test_linei(void) status = GdipAddPathLineI(path, 35.0, 35.0, 36.0, 38.0); expect(Ok, status); - ok_path(path, linei_path, sizeof(linei_path)/sizeof(path_test_t), FALSE); + ok_path(path, linei_path, ARRAY_SIZE(linei_path), FALSE); GdipDeletePath(path); } @@ -614,7 +614,7 @@ static void test_polygon(void) status = GdipAddPathPolygon(path, points, 5); expect(Ok, status); /* check resulting path */ - ok_path(path, poly_path, sizeof(poly_path)/sizeof(path_test_t), FALSE); + ok_path(path, poly_path, ARRAY_SIZE(poly_path), FALSE); GdipDeletePath(path); } @@ -643,7 +643,7 @@ static void test_rect(void) status = GdipAddPathRectangle(path, 100.0, 50.0, 120.0, 30.0); expect(Ok, status); - ok_path(path, rect_path, sizeof(rect_path)/sizeof(path_test_t), FALSE); + ok_path(path, rect_path, ARRAY_SIZE(rect_path), FALSE); GdipDeletePath(path); @@ -661,7 +661,7 @@ static void test_rect(void) status = GdipAddPathRectangles(path, (GDIPCONST GpRectF*)&rects, 2); expect(Ok, status); - ok_path(path, rect_path, sizeof(rect_path)/sizeof(path_test_t), FALSE); + ok_path(path, rect_path, ARRAY_SIZE(rect_path), FALSE); GdipDeletePath(path); } @@ -756,7 +756,7 @@ static void test_addcurve(void) /* add to empty path */ status = GdipAddPathCurve2(path, points, 4, 1.0); expect(Ok, status); - ok_path(path, addcurve_path, sizeof(addcurve_path)/sizeof(path_test_t), FALSE); + ok_path(path, addcurve_path, ARRAY_SIZE(addcurve_path), FALSE); GdipDeletePath(path); /* add to notempty path and opened figure */ @@ -764,7 +764,7 @@ static void test_addcurve(void) GdipAddPathLine(path, 100.0, 120.0, 123.0, 10.0); status = GdipAddPathCurve2(path, points, 4, 1.0); expect(Ok, status); - ok_path(path, addcurve_path2, sizeof(addcurve_path2)/sizeof(path_test_t), FALSE); + ok_path(path, addcurve_path2, ARRAY_SIZE(addcurve_path2), FALSE); /* NULL args */ GdipResetPath(path); @@ -789,12 +789,12 @@ static void test_addcurve(void) /* use all points */ status = GdipAddPathCurve3(path, points, 4, 0, 3, 1.0); expect(Ok, status); - ok_path(path, addcurve_path, sizeof(addcurve_path)/sizeof(path_test_t), FALSE); + ok_path(path, addcurve_path, ARRAY_SIZE(addcurve_path), FALSE); GdipResetPath(path); status = GdipAddPathCurve3(path, points, 4, 1, 2, 1.0); expect(Ok, status); - ok_path(path, addcurve_path3, sizeof(addcurve_path3)/sizeof(path_test_t), FALSE); + ok_path(path, addcurve_path3, ARRAY_SIZE(addcurve_path3), FALSE); GdipDeletePath(path); } @@ -844,7 +844,7 @@ static void test_addclosedcurve(void) /* add to empty path */ status = GdipAddPathClosedCurve2(path, points, 4, 1.0); expect(Ok, status); - ok_path(path, addclosedcurve_path, sizeof(addclosedcurve_path)/sizeof(path_test_t), FALSE); + ok_path(path, addclosedcurve_path, ARRAY_SIZE(addclosedcurve_path), FALSE); GdipDeletePath(path); } @@ -886,7 +886,7 @@ static void test_reverse(void) status = GdipReversePath(path); expect(Ok, status); - ok_path(path, reverse_path, sizeof(reverse_path)/sizeof(path_test_t), FALSE); + ok_path(path, reverse_path, ARRAY_SIZE(reverse_path), FALSE); GdipDeletePath(path); } @@ -917,21 +917,21 @@ static void test_addpie(void) status = GdipAddPathPie(path, 0.0, 0.0, 100.0, 50.0, 10.0, 50.0); expect(Ok, status); - ok_path(path, addpie_path, sizeof(addpie_path)/sizeof(path_test_t), FALSE); + ok_path(path, addpie_path, ARRAY_SIZE(addpie_path), FALSE); status = GdipResetPath(path); expect(Ok, status); /* zero width base ellipse */ status = GdipAddPathPie(path, 0.0, 0.0, 0.0, 60.0, -90.0, 24.0); expect(InvalidParameter, status); - ok_path(path, addpie_path2, sizeof(addpie_path2)/sizeof(path_test_t), FALSE); + ok_path(path, addpie_path2, ARRAY_SIZE(addpie_path2), FALSE); status = GdipResetPath(path); expect(Ok, status); /* zero height base ellipse */ status = GdipAddPathPie(path, 0.0, 0.0, 60.0, 0.0 , -90.0, 24.0); expect(InvalidParameter, status); - ok_path(path, addpie_path3, sizeof(addpie_path3)/sizeof(path_test_t), FALSE); + ok_path(path, addpie_path3, ARRAY_SIZE(addpie_path3), FALSE); GdipDeletePath(path); } @@ -1020,7 +1020,7 @@ static void test_flatten(void) status = GdipFlattenPath(path, NULL, 1.0); expect(Ok, status); - ok_path(path, flattenellipse_path, sizeof(flattenellipse_path)/sizeof(path_test_t), TRUE); + ok_path(path, flattenellipse_path, ARRAY_SIZE(flattenellipse_path), TRUE); status = GdipResetPath(path); expect(Ok, status); @@ -1028,7 +1028,7 @@ static void test_flatten(void) expect(Ok, status); status = GdipFlattenPath(path, NULL, 1.0); expect(Ok, status); - ok_path(path, flattenline_path, sizeof(flattenline_path)/sizeof(path_test_t), FALSE); + ok_path(path, flattenline_path, ARRAY_SIZE(flattenline_path), FALSE); status = GdipResetPath(path); expect(Ok, status); @@ -1036,7 +1036,7 @@ static void test_flatten(void) expect(Ok, status); status = GdipFlattenPath(path, NULL, 1.0); expect(Ok, status); - ok_path(path, flattenarc_path, sizeof(flattenarc_path)/sizeof(path_test_t), TRUE); + ok_path(path, flattenarc_path, ARRAY_SIZE(flattenarc_path), TRUE); /* easy case - quater of a full circle */ status = GdipResetPath(path); @@ -1045,7 +1045,7 @@ static void test_flatten(void) expect(Ok, status); status = GdipFlattenPath(path, NULL, 1.0); expect(Ok, status); - ok_path(path, flattenquater_path, sizeof(flattenquater_path)/sizeof(path_test_t), FALSE); + ok_path(path, flattenquater_path, ARRAY_SIZE(flattenquater_path), FALSE); GdipDeleteMatrix(m); GdipDeletePath(path); @@ -1119,7 +1119,7 @@ static void test_widen(void) status = GdipWidenPath(path, pen, m, 1.0); expect(Ok, status); - ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE); + ok_path(path, widenline_path, ARRAY_SIZE(widenline_path), FALSE); /* horizontal 2x stretch */ status = GdipResetPath(path); @@ -1132,7 +1132,7 @@ static void test_widen(void) status = GdipWidenPath(path, pen, m, 1.0); expect(Ok, status); - ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE); + ok_path(path, widenline_path, ARRAY_SIZE(widenline_path), FALSE); /* vertical 2x stretch */ status = GdipResetPath(path); @@ -1145,7 +1145,7 @@ static void test_widen(void) status = GdipWidenPath(path, pen, m, 1.0); expect(Ok, status); - ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE); + ok_path(path, widenline_path, ARRAY_SIZE(widenline_path), FALSE); status = GdipScaleMatrix(m, 1.0, 0.5, MatrixOrderAppend); expect(Ok, status); @@ -1161,7 +1161,7 @@ static void test_widen(void) status = GdipWidenPath(path, pen, m, 1.0); expect(Ok, status); - ok_path(path, widenline_dash_path, sizeof(widenline_dash_path)/sizeof(path_test_t), FALSE); + ok_path(path, widenline_dash_path, ARRAY_SIZE(widenline_dash_path), FALSE); status = GdipSetPenDashStyle(pen, DashStyleSolid); expect(Ok, status); @@ -1178,7 +1178,7 @@ static void test_widen(void) status = GdipWidenPath(path, pen, m, 1.0); expect(Ok, status); - ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE); + ok_path(path, widenline_path, ARRAY_SIZE(widenline_path), FALSE); /* horizontal 2x stretch */ status = GdipResetPath(path); @@ -1191,7 +1191,7 @@ static void test_widen(void) status = GdipWidenPath(path, pen, m, 1.0); expect(Ok, status); - ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE); + ok_path(path, widenline_path, ARRAY_SIZE(widenline_path), FALSE); /* vertical 2x stretch */ status = GdipResetPath(path); @@ -1204,7 +1204,7 @@ static void test_widen(void) status = GdipWidenPath(path, pen, m, 1.0); expect(Ok, status); - ok_path(path, widenline_wide_path, sizeof(widenline_wide_path)/sizeof(path_test_t), FALSE); + ok_path(path, widenline_wide_path, ARRAY_SIZE(widenline_wide_path), FALSE); status = GdipScaleMatrix(m, 1.0, 0.5, MatrixOrderAppend); expect(Ok, status); @@ -1221,7 +1221,7 @@ static void test_widen(void) status = GdipWidenPath(path, pen, m, 1.0); expect(Ok, status); - ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE); + ok_path(path, widenline_path, ARRAY_SIZE(widenline_path), FALSE); /* pen width = 0 pixels - native fails to widen but can draw with this pen */ GdipDeletePen(pen); diff --git a/modules/rostests/winetests/gdiplus/image.c b/modules/rostests/winetests/gdiplus/image.c index bb27dd6af2..516e7129a6 100644 --- a/modules/rostests/winetests/gdiplus/image.c +++ b/modules/rostests/winetests/gdiplus/image.c @@ -74,10 +74,10 @@ static void expect_guid(REFGUID expected, REFGUID got, int line, BOOL todo) char buffer[39]; char buffer2[39]; - StringFromGUID2(got, bufferW, sizeof(bufferW)/sizeof(bufferW[0])); - WideCharToMultiByte(CP_ACP, 0, bufferW, sizeof(bufferW)/sizeof(bufferW[0]), buffer, sizeof(buffer), NULL, NULL); - StringFromGUID2(expected, bufferW, sizeof(bufferW)/sizeof(bufferW[0])); - WideCharToMultiByte(CP_ACP, 0, bufferW, sizeof(bufferW)/sizeof(bufferW[0]), buffer2, sizeof(buffer2), NULL, NULL); + StringFromGUID2(got, bufferW, ARRAY_SIZE(bufferW)); + WideCharToMultiByte(CP_ACP, 0, bufferW, ARRAY_SIZE(bufferW), buffer, sizeof(buffer), NULL, NULL); + StringFromGUID2(expected, bufferW, ARRAY_SIZE(bufferW)); + WideCharToMultiByte(CP_ACP, 0, bufferW, ARRAY_SIZE(bufferW), buffer2, sizeof(buffer2), NULL, NULL); todo_wine_if (todo) ok_(__FILE__, line)(IsEqualGUID(expected, got), "Expected %s, got %s\n", buffer2, buffer); } @@ -3328,7 +3328,7 @@ static void test_image_properties(void) char buf[256]; } item; - for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) + for (i = 0; i < ARRAY_SIZE(td); i++) { image = load_image(td[i].image_data, td[i].image_size); if (!image) @@ -3646,9 +3646,9 @@ static void test_tiff_properties(void) prop_count = 0xdeadbeef; status = GdipGetPropertyCount(image, &prop_count); expect(Ok, status); - ok(prop_count == sizeof(td)/sizeof(td[0]) || - broken(prop_count == sizeof(td)/sizeof(td[0]) - 1) /* Win7 SP0 */, - "expected property count %u, got %u\n", (UINT)(sizeof(td)/sizeof(td[0])), prop_count); + ok(prop_count == ARRAY_SIZE(td) || + broken(prop_count == ARRAY_SIZE(td) - 1) /* Win7 SP0 */, + "expected property count %u, got %u\n", (UINT) ARRAY_SIZE(td), prop_count); prop_id = HeapAlloc(GetProcessHeap(), 0, prop_count * sizeof(*prop_id)); @@ -3756,8 +3756,8 @@ static void test_GdipGetAllPropertyItems(void) prop_count = 0xdeadbeef; status = GdipGetPropertyCount(image, &prop_count); expect(Ok, status); - ok(prop_count == sizeof(td)/sizeof(td[0]), - "expected property count %u, got %u\n", (UINT)(sizeof(td)/sizeof(td[0])), prop_count); + ok(prop_count == ARRAY_SIZE(td), + "expected property count %u, got %u\n", (UINT) ARRAY_SIZE(td), prop_count); prop_id = HeapAlloc(GetProcessHeap(), 0, prop_count * sizeof(*prop_id)); @@ -4031,7 +4031,7 @@ static void test_bitmapbits(void) } palette; ARGB *entries = palette.pal.Entries; - for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) + for (i = 0; i < ARRAY_SIZE(td); i++) { BYTE pixels[sizeof(pixels_24)]; memcpy(pixels, pixels_24, sizeof(pixels_24)); @@ -4300,7 +4300,7 @@ static void test_image_format(void) BitmapData data; UINT i, ret; - for (i = 0; i < sizeof(fmt)/sizeof(fmt[0]); i++) + for (i = 0; i < ARRAY_SIZE(fmt); i++) { status = GdipCreateBitmapFromScan0(1, 1, 0, fmt[i], NULL, &bitmap); ok(status == Ok || broken(status == InvalidParameter) /* before win7 */, @@ -4452,7 +4452,7 @@ static void test_DrawImage_scale(void) status = GdipSetInterpolationMode(graphics, InterpolationModeNearestNeighbor); expect(Ok, status); - for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) + for (i = 0; i < ARRAY_SIZE(td); i++) { status = GdipSetPixelOffsetMode(graphics, td[i].pixel_offset_mode); expect(Ok, status); @@ -4558,10 +4558,10 @@ static void test_gif_properties(void) status = GdipGetPropertyCount(image, &prop_count); expect(Ok, status); - ok(prop_count == sizeof(td)/sizeof(td[0]) || broken(prop_count == 1) /* before win7 */, - "expected property count %u, got %u\n", (UINT)(sizeof(td)/sizeof(td[0])), prop_count); + ok(prop_count == ARRAY_SIZE(td) || broken(prop_count == 1) /* before win7 */, + "expected property count %u, got %u\n", (UINT) ARRAY_SIZE(td), prop_count); - if (prop_count != sizeof(td)/sizeof(td[0])) + if (prop_count != ARRAY_SIZE(td)) { GdipDisposeImage(image); return; @@ -4834,7 +4834,7 @@ static void test_supported_encoders(void) status = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat24bppRGB, NULL, &bm); ok(status == Ok, "GdipCreateBitmapFromScan0 error %d\n", status); - for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) + for (i = 0; i < ARRAY_SIZE(td); i++) { ret = get_encoder_clsid(td[i].mime, &format, &clsid); ok(ret, "%s encoder is not in the list\n", wine_dbgstr_w(td[i].mime)); @@ -4883,7 +4883,7 @@ static void test_createeffect(void) stat = pGdipCreateEffect(noneffect, &effect); todo_wine expect(Win32Error, stat); - for(i=0; i < sizeof(effectlist) / sizeof(effectlist[0]); i++) + for(i=0; i < ARRAY_SIZE(effectlist); i++) { stat = pGdipCreateEffect(*effectlist[i], &effect); todo_wine expect(Ok, stat); @@ -4996,7 +4996,7 @@ static void test_histogram(void) expect(Ok, stat); expect(256, num); - for (i = 0; i < sizeof(test_formats)/sizeof(test_formats[0]); i++) + for (i = 0; i < ARRAY_SIZE(test_formats); i++) { num = 0; stat = pGdipBitmapGetHistogramSize(test_formats[i], &num); @@ -5146,7 +5146,7 @@ static void test_png_color_formats(void) UINT flags; int i; - for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) + for (i = 0; i < ARRAY_SIZE(td); i++) { memcpy(buf, png_1x1_data, sizeof(png_1x1_data)); buf[24] = td[i].bit_depth;
6 years, 2 months
1
0
0
0
01/01: [GDIPLUS] Sync with Wine Staging 3.17. CORE-15127
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8d2e1e843c831a5b3139f…
commit 8d2e1e843c831a5b3139f53201e644203c74bbcc Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Oct 1 12:50:25 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Oct 1 12:50:25 2018 +0100 [GDIPLUS] Sync with Wine Staging 3.17. CORE-15127 --- dll/win32/gdiplus/graphics.c | 34 +++++++++++++++++++++++++++------- media/doc/README.WINE | 2 +- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/dll/win32/gdiplus/graphics.c b/dll/win32/gdiplus/graphics.c index 1e2aff14f4..5666346afc 100644 --- a/dll/win32/gdiplus/graphics.c +++ b/dll/win32/gdiplus/graphics.c @@ -1156,8 +1156,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: @@ -1170,12 +1171,22 @@ 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) break; + if (!hdc) + { + status = OutOfMemory; + DeleteObject(bmp); + break; + } SelectObject(hdc, bmp); gdi_alpha_blend(graphics, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, @@ -1193,7 +1204,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); @@ -1202,6 +1217,8 @@ static void brush_fill_path(GpGraphics *graphics, GpBrush* brush) break; } } + + return status; } static BOOL brush_can_fill_pixels(GpBrush *brush) @@ -4337,7 +4354,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); @@ -4383,6 +4400,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); @@ -4643,13 +4663,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, diff --git a/media/doc/README.WINE b/media/doc/README.WINE index e218e01830..34f5a994cf 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -68,7 +68,7 @@ reactos/dll/win32/dciman32 # Synced to WineStaging-3.3 reactos/dll/win32/faultrep # Synced to WineStaging-2.9 reactos/dll/win32/fontsub # Synced to WineStaging-2.9 reactos/dll/win32/fusion # Synced to WineStaging-3.17 -reactos/dll/win32/gdiplus # Synced to WineStaging-3.9 +reactos/dll/win32/gdiplus # Synced to WineStaging-3.17 reactos/dll/win32/hhctrl.ocx # Synced to WineStaging-3.3 reactos/dll/win32/hlink # Synced to WineStaging-3.3 reactos/dll/win32/hnetcfg # Synced to WineStaging-3.9
6 years, 2 months
1
0
0
0
01/01: [FUSION] Sync with Wine Staging 3.17. CORE-15127
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fe0fd16499730f80351ee…
commit fe0fd16499730f80351eec0a6f325f1dcf8e64db Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Oct 1 12:49:44 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Oct 1 12:49:44 2018 +0100 [FUSION] Sync with Wine Staging 3.17. CORE-15127 --- dll/win32/fusion/asmcache.c | 8 ++++---- dll/win32/fusion/fusion.c | 10 +++++----- media/doc/README.WINE | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dll/win32/fusion/asmcache.c b/dll/win32/fusion/asmcache.c index 668aa8777e..deca5f4c37 100644 --- a/dll/win32/fusion/asmcache.c +++ b/dll/win32/fusion/asmcache.c @@ -117,14 +117,14 @@ static BOOL get_assembly_directory(LPWSTR dir, DWORD size, const char *version, if (!strcmp(version, "v4.0.30319")) { strcpyW(dir + len, dotnet); - len += sizeof(dotnet)/sizeof(WCHAR) -1; + len += ARRAY_SIZE(dotnet) - 1; strcpyW(dir + len, gac + 1); - len += sizeof(gac)/sizeof(WCHAR) - 2; + len += ARRAY_SIZE(gac) - 2; } else { strcpyW(dir + len, gac); - len += sizeof(gac)/sizeof(WCHAR) - 1; + len += ARRAY_SIZE(gac) - 1; } switch (architecture) { @@ -433,7 +433,7 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface, WCHAR asmdir[MAX_PATH], *p, **external_files = NULL, *dst_dir = NULL; PEKIND architecture; char *clr_version; - DWORD i, count = 0, src_len, dst_len = sizeof(format_v40)/sizeof(format_v40[0]); + DWORD i, count = 0, src_len, dst_len = ARRAY_SIZE(format_v40); HRESULT hr; TRACE("(%p, %d, %s, %p)\n", iface, dwFlags, diff --git a/dll/win32/fusion/fusion.c b/dll/win32/fusion/fusion.c index b038b38092..a57d7e067c 100644 --- a/dll/win32/fusion/fusion.c +++ b/dll/win32/fusion/fusion.c @@ -144,9 +144,9 @@ HRESULT WINAPI GetCachePath(ASM_CACHE_FLAGS dwCacheFlags, LPWSTR pwzCachePath, case ASM_CACHE_GAC: { strcpyW(path + len, assembly); - len += sizeof(assembly)/sizeof(WCHAR) - 1; + len += ARRAY_SIZE(assembly) - 1; strcpyW(path + len, gac); - len += sizeof(gac)/sizeof(WCHAR) - 1; + len += ARRAY_SIZE(gac) - 1; break; } case ASM_CACHE_DOWNLOAD: @@ -156,13 +156,13 @@ HRESULT WINAPI GetCachePath(ASM_CACHE_FLAGS dwCacheFlags, LPWSTR pwzCachePath, } case ASM_CACHE_ROOT: strcpyW(path + len, assembly); - len += sizeof(assembly)/sizeof(WCHAR) - 1; + len += ARRAY_SIZE(assembly) - 1; break; case ASM_CACHE_ROOT_EX: strcpyW(path + len, dotnet); - len += sizeof(dotnet)/sizeof(WCHAR) - 1; + len += ARRAY_SIZE(dotnet) - 1; strcpyW(path + len, assembly); - len += sizeof(assembly)/sizeof(WCHAR) - 1; + len += ARRAY_SIZE(assembly) - 1; break; default: return E_INVALIDARG; diff --git a/media/doc/README.WINE b/media/doc/README.WINE index ee52066a8b..e218e01830 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -67,7 +67,7 @@ reactos/dll/win32/dbghelp # Synced to WineStaging-3.9 reactos/dll/win32/dciman32 # Synced to WineStaging-3.3 reactos/dll/win32/faultrep # Synced to WineStaging-2.9 reactos/dll/win32/fontsub # Synced to WineStaging-2.9 -reactos/dll/win32/fusion # Synced to WineStaging-3.3 +reactos/dll/win32/fusion # Synced to WineStaging-3.17 reactos/dll/win32/gdiplus # Synced to WineStaging-3.9 reactos/dll/win32/hhctrl.ocx # Synced to WineStaging-3.3 reactos/dll/win32/hlink # Synced to WineStaging-3.3
6 years, 2 months
1
0
0
0
01/01: [CRYPTUI] Sync with Wine Staging 3.17. CORE-15127
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4fc4698f2a01e72abc3c4…
commit 4fc4698f2a01e72abc3c45e72cab470dcd445689 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Oct 1 12:49:09 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Oct 1 12:49:09 2018 +0100 [CRYPTUI] Sync with Wine Staging 3.17. CORE-15127 --- dll/win32/cryptui/main.c | 221 ++++++++++++++++++----------------------------- media/doc/README.WINE | 2 +- 2 files changed, 84 insertions(+), 139 deletions(-) diff --git a/dll/win32/cryptui/main.c b/dll/win32/cryptui/main.c index a652239bb3..4ac37c96df 100644 --- a/dll/win32/cryptui/main.c +++ b/dll/win32/cryptui/main.c @@ -73,22 +73,18 @@ static void add_cert_columns(HWND hwnd) SendMessageW(lv, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT); GetWindowRect(lv, &rc); - LoadStringW(hInstance, IDS_SUBJECT_COLUMN, buf, - sizeof(buf) / sizeof(buf[0])); + LoadStringW(hInstance, IDS_SUBJECT_COLUMN, buf, ARRAY_SIZE(buf)); column.mask = LVCF_WIDTH | LVCF_TEXT; column.cx = (rc.right - rc.left) * 29 / 100 - 2; column.pszText = buf; SendMessageW(lv, LVM_INSERTCOLUMNW, 0, (LPARAM)&column); - LoadStringW(hInstance, IDS_ISSUER_COLUMN, buf, - sizeof(buf) / sizeof(buf[0])); + LoadStringW(hInstance, IDS_ISSUER_COLUMN, buf, ARRAY_SIZE(buf)); SendMessageW(lv, LVM_INSERTCOLUMNW, 1, (LPARAM)&column); column.cx = (rc.right - rc.left) * 16 / 100 - 2; - LoadStringW(hInstance, IDS_EXPIRATION_COLUMN, buf, - sizeof(buf) / sizeof(buf[0])); + LoadStringW(hInstance, IDS_EXPIRATION_COLUMN, buf, ARRAY_SIZE(buf)); SendMessageW(lv, LVM_INSERTCOLUMNW, 2, (LPARAM)&column); column.cx = (rc.right - rc.left) * 23 / 100 - 1; - LoadStringW(hInstance, IDS_FRIENDLY_NAME_COLUMN, buf, - sizeof(buf) / sizeof(buf[0])); + LoadStringW(hInstance, IDS_FRIENDLY_NAME_COLUMN, buf, ARRAY_SIZE(buf)); SendMessageW(lv, LVM_INSERTCOLUMNW, 3, (LPARAM)&column); } @@ -143,11 +139,9 @@ static void add_cert_to_view(HWND lv, PCCERT_CONTEXT cert, DWORD *allocatedLen, SendMessageW(lv, LVM_SETITEMTEXTW, item.iItem, (LPARAM)&item); } - GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, dateFmt, - sizeof(dateFmt) / sizeof(dateFmt[0])); + GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, dateFmt, ARRAY_SIZE(dateFmt)); FileTimeToSystemTime(&cert->pCertInfo->NotAfter, &sysTime); - GetDateFormatW(LOCALE_SYSTEM_DEFAULT, 0, &sysTime, dateFmt, date, - sizeof(date) / sizeof(date[0])); + GetDateFormatW(LOCALE_SYSTEM_DEFAULT, 0, &sysTime, dateFmt, date, ARRAY_SIZE(date)); item.pszText = date; item.iSubItem = 2; SendMessageW(lv, LVM_SETITEMTEXTW, item.iItem, (LPARAM)&item); @@ -222,12 +216,10 @@ static void initialize_purpose_selection(HWND hwnd) LPSTR usages; int index; - LoadStringW(hInstance, IDS_PURPOSE_ALL, buf, - sizeof(buf) / sizeof(buf[0])); + LoadStringW(hInstance, IDS_PURPOSE_ALL, buf, ARRAY_SIZE(buf)); index = SendMessageW(cb, CB_INSERTSTRING, -1, (LPARAM)buf); SendMessageW(cb, CB_SETITEMDATA, index, (LPARAM)PurposeFilterShowAll); - LoadStringW(hInstance, IDS_PURPOSE_ADVANCED, buf, - sizeof(buf) / sizeof(buf[0])); + LoadStringW(hInstance, IDS_PURPOSE_ADVANCED, buf, ARRAY_SIZE(buf)); index = SendMessageW(cb, CB_INSERTSTRING, -1, (LPARAM)buf); SendMessageW(cb, CB_SETITEMDATA, index, (LPARAM)PurposeFilterShowAdvanced); SendMessageW(cb, CB_SETCURSEL, 0, 0); @@ -500,12 +492,12 @@ static void show_cert_stores(HWND hwnd, DWORD dwFlags, struct CertMgrData *data) if (dwFlags & CRYPTUI_CERT_MGR_PUBLISHER_TAB) { storeList = publisherStoreList; - cStores = sizeof(publisherStoreList) / sizeof(publisherStoreList[0]); + cStores = ARRAY_SIZE(publisherStoreList); } else { storeList = defaultStoreList; - cStores = sizeof(defaultStoreList) / sizeof(defaultStoreList[0]); + cStores = ARRAY_SIZE(defaultStoreList); } if (dwFlags & CRYPTUI_CERT_MGR_SINGLE_TAB_FLAG) cStores = 1; @@ -942,8 +934,7 @@ static void cert_mgr_show_cert_usages(HWND hwnd, int index) { WCHAR buf[MAX_STRING_LEN]; - LoadStringW(hInstance, IDS_ALLOWED_PURPOSE_NONE, buf, - sizeof(buf) / sizeof(buf[0])); + LoadStringW(hInstance, IDS_ALLOWED_PURPOSE_NONE, buf, ARRAY_SIZE(buf)); SendMessageW(text, WM_SETTEXT, 0, (LPARAM)buf); } } @@ -951,8 +942,7 @@ static void cert_mgr_show_cert_usages(HWND hwnd, int index) { WCHAR buf[MAX_STRING_LEN]; - LoadStringW(hInstance, IDS_ALLOWED_PURPOSE_ALL, buf, - sizeof(buf) / sizeof(buf[0])); + LoadStringW(hInstance, IDS_ALLOWED_PURPOSE_ALL, buf, ARRAY_SIZE(buf)); SendMessageW(text, WM_SETTEXT, 0, (LPARAM)buf); } } @@ -979,12 +969,10 @@ static void cert_mgr_do_remove(HWND hwnd) pTitle = data->title; else { - LoadStringW(hInstance, IDS_CERT_MGR, title, - sizeof(title) / sizeof(title[0])); + LoadStringW(hInstance, IDS_CERT_MGR, title, ARRAY_SIZE(title)); pTitle = title; } - LoadStringW(hInstance, warningID, warning, - sizeof(warning) / sizeof(warning[0])); + LoadStringW(hInstance, warningID, warning, ARRAY_SIZE(warning)); if (MessageBoxW(hwnd, warning, pTitle, MB_YESNO) == IDYES) { int selection = -1; @@ -1072,7 +1060,7 @@ static int cert_mgr_sort_by_text(HWND lv, int col, int index1, int index2) WCHAR buf1[MAX_STRING_LEN]; WCHAR buf2[MAX_STRING_LEN]; - item.cchTextMax = sizeof(buf1) / sizeof(buf1[0]); + item.cchTextMax = ARRAY_SIZE(buf1); item.mask = LVIF_TEXT; item.pszText = buf1; item.iItem = index1; @@ -1490,7 +1478,7 @@ static HCERTSTORE selected_item_to_store(HWND tree, HTREEITEM hItem) memset(&item, 0, sizeof(item)); item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT; item.hItem = hItem; - item.cchTextMax = sizeof(buf) / sizeof(buf[0]); + item.cchTextMax = ARRAY_SIZE(buf); item.pszText = buf; SendMessageW(tree, TVM_GETITEMW, 0, (LPARAM)&item); if (item.lParam) @@ -1558,12 +1546,10 @@ static LRESULT CALLBACK select_store_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, pTitle = selectInfo->info->pwszTitle; else { - LoadStringW(hInstance, IDS_SELECT_STORE_TITLE, title, - sizeof(title) / sizeof(title[0])); + LoadStringW(hInstance, IDS_SELECT_STORE_TITLE, title, ARRAY_SIZE(title)); pTitle = title; } - LoadStringW(hInstance, IDS_SELECT_STORE, error, - sizeof(error) / sizeof(error[0])); + LoadStringW(hInstance, IDS_SELECT_STORE, error, ARRAY_SIZE(error)); MessageBoxW(hwnd, error, pTitle, MB_ICONEXCLAMATION | MB_OK); } else @@ -1958,7 +1944,7 @@ static struct OIDToString oidMap[] = { static struct OIDToString *findSupportedOID(LPCSTR oid) { - int indexHigh = sizeof(oidMap) / sizeof(oidMap[0]) - 1, indexLow = 0; + int indexHigh = ARRAY_SIZE(oidMap) - 1, indexLow = 0; while (indexLow <= indexHigh) { @@ -2397,11 +2383,9 @@ static void add_date_string_to_control(HWND hwnd, const FILETIME *fileTime) WCHAR date[80]; SYSTEMTIME sysTime; - GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, dateFmt, - sizeof(dateFmt) / sizeof(dateFmt[0])); + GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, dateFmt, ARRAY_SIZE(dateFmt)); FileTimeToSystemTime(fileTime, &sysTime); - GetDateFormatW(LOCALE_SYSTEM_DEFAULT, 0, &sysTime, dateFmt, date, - sizeof(date) / sizeof(date[0])); + GetDateFormatW(LOCALE_SYSTEM_DEFAULT, 0, &sysTime, dateFmt, date, ARRAY_SIZE(date)); add_unformatted_text_to_control(hwnd, date, lstrlenW(date)); } @@ -2658,8 +2642,7 @@ static WCHAR *format_long_date(const FILETIME *fileTime) SYSTEMTIME sysTime; /* FIXME: format isn't quite right, want time too */ - GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT, LOCALE_SLONGDATE, dateFmt, - sizeof(dateFmt) / sizeof(dateFmt[0])); + GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT, LOCALE_SLONGDATE, dateFmt, ARRAY_SIZE(dateFmt)); FileTimeToSystemTime(fileTime, &sysTime); len = GetDateFormatW(LOCALE_SYSTEM_DEFAULT, 0, &sysTime, dateFmt, NULL, 0); if (len) @@ -2693,8 +2676,7 @@ static WCHAR *field_format_public_key(PCCERT_CONTEXT cert) { WCHAR fmt[MAX_STRING_LEN]; - if (LoadStringW(hInstance, IDS_FIELD_PUBLIC_KEY_FORMAT, fmt, - sizeof(fmt) / sizeof(fmt[0]))) + if (LoadStringW(hInstance, IDS_FIELD_PUBLIC_KEY_FORMAT, fmt, ARRAY_SIZE(fmt))) { DWORD len; @@ -2795,7 +2777,7 @@ static void add_string_id_and_value_to_list(HWND hwnd, struct detail_data *data, { WCHAR buf[MAX_STRING_LEN]; - LoadStringW(hInstance, id, buf, sizeof(buf) / sizeof(buf[0])); + LoadStringW(hInstance, id, buf, ARRAY_SIZE(buf)); add_field_and_value_to_list(hwnd, data, buf, value, create, param); } @@ -2838,7 +2820,7 @@ static void add_v1_fields(HWND hwnd, struct detail_data *data) /* The last item in v1_fields is the public key, which is not in the loop * because it's a special case. */ - for (i = 0; i < sizeof(v1_fields) / sizeof(v1_fields[0]) - 1; i++) + for (i = 0; i < ARRAY_SIZE(v1_fields) - 1; i++) add_v1_field(hwnd, data, &v1_fields[i]); if (cert->pCertInfo->SubjectPublicKeyInfo.PublicKey.cbData) add_v1_field(hwnd, data, &v1_fields[i]); @@ -2905,7 +2887,7 @@ static WCHAR *field_format_extension_hex_with_ascii(const CERT_EXTENSION *ext) { static const WCHAR pad[] = { ' ',' ',' ' }; - for (; j % 8; j++, ptr += sizeof(pad) / sizeof(pad[0])) + for (; j % 8; j++, ptr += ARRAY_SIZE(pad)) memcpy(ptr, pad, sizeof(pad)); } /* The last sprintfW included a space, so just insert one @@ -3026,7 +3008,7 @@ static void add_properties(HWND hwnd, struct detail_data *data) DWORD i; PCCERT_CONTEXT cert = data->pCertViewInfo->pCertContext; - for (i = 0; i < sizeof(prop_id_map) / sizeof(prop_id_map[0]); i++) + for (i = 0; i < ARRAY_SIZE(prop_id_map); i++) { DWORD cb; @@ -3089,12 +3071,11 @@ static void create_show_list(HWND hwnd, struct detail_data *data) WCHAR buf[MAX_STRING_LEN]; int i; - for (i = 0; i < sizeof(listItems) / sizeof(listItems[0]); i++) + for (i = 0; i < ARRAY_SIZE(listItems); i++) { int index; - LoadStringW(hInstance, listItems[i].id, buf, - sizeof(buf) / sizeof(buf[0])); + LoadStringW(hInstance, listItems[i].id, buf, ARRAY_SIZE(buf)); index = SendMessageW(cb, CB_INSERTSTRING, -1, (LPARAM)buf); SendMessageW(cb, CB_SETITEMDATA, index, (LPARAM)data); } @@ -3110,12 +3091,12 @@ static void create_listview_columns(HWND hwnd) SendMessageW(lv, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT); GetWindowRect(lv, &rc); - LoadStringW(hInstance, IDS_FIELD, buf, sizeof(buf) / sizeof(buf[0])); + LoadStringW(hInstance, IDS_FIELD, buf, ARRAY_SIZE(buf)); column.mask = LVCF_WIDTH | LVCF_TEXT; column.cx = (rc.right - rc.left) / 2 - 2; column.pszText = buf; SendMessageW(lv, LVM_INSERTCOLUMNW, 0, (LPARAM)&column); - LoadStringW(hInstance, IDS_VALUE, buf, sizeof(buf) / sizeof(buf[0])); + LoadStringW(hInstance, IDS_VALUE, buf, ARRAY_SIZE(buf)); SendMessageW(lv, LVM_INSERTCOLUMNW, 1, (LPARAM)&column); } @@ -3123,7 +3104,7 @@ static void set_fields_selection(HWND hwnd, struct detail_data *data, int sel) { HWND list = GetDlgItem(hwnd, IDC_DETAIL_LIST); - if (sel >= 0 && sel < sizeof(listItems) / sizeof(listItems[0])) + if (sel >= 0 && sel < ARRAY_SIZE(listItems)) { SendMessageW(list, LVM_DELETEALLITEMS, 0, 0); listItems[sel].add(list, data); @@ -3247,8 +3228,8 @@ static LRESULT CALLBACK add_purpose_dlg_proc(HWND hwnd, UINT msg, switch (LOWORD(wp)) { case IDOK: - SendMessageA(GetDlgItem(hwnd, IDC_NEW_PURPOSE), WM_GETTEXT, - sizeof(buf) / sizeof(buf[0]), (LPARAM)buf); + SendMessageA(GetDlgItem(hwnd, IDC_NEW_PURPOSE), WM_GETTEXT, ARRAY_SIZE(buf), + (LPARAM)buf); if (!buf[0]) { /* An empty purpose is the same as cancelling */ @@ -3259,10 +3240,8 @@ static LRESULT CALLBACK add_purpose_dlg_proc(HWND hwnd, UINT msg, { WCHAR title[MAX_STRING_LEN], error[MAX_STRING_LEN]; - LoadStringW(hInstance, IDS_CERTIFICATE_PURPOSE_ERROR, error, - sizeof(error) / sizeof(error[0])); - LoadStringW(hInstance, IDS_CERTIFICATE_PROPERTIES, title, - sizeof(title) / sizeof(title[0])); + LoadStringW(hInstance, IDS_CERTIFICATE_PURPOSE_ERROR, error, ARRAY_SIZE(error)); + LoadStringW(hInstance, IDS_CERTIFICATE_PROPERTIES, title, ARRAY_SIZE(title)); MessageBoxW(hwnd, error, title, MB_ICONERROR | MB_OK); } else if (is_oid_in_list( @@ -3270,10 +3249,9 @@ static LRESULT CALLBACK add_purpose_dlg_proc(HWND hwnd, UINT msg, { WCHAR title[MAX_STRING_LEN], error[MAX_STRING_LEN]; - LoadStringW(hInstance, IDS_CERTIFICATE_PURPOSE_EXISTS, - error, sizeof(error) / sizeof(error[0])); - LoadStringW(hInstance, IDS_CERTIFICATE_PROPERTIES, title, - sizeof(title) / sizeof(title[0])); + LoadStringW(hInstance, IDS_CERTIFICATE_PURPOSE_EXISTS, error, + ARRAY_SIZE(error)); + LoadStringW(hInstance, IDS_CERTIFICATE_PROPERTIES, title, ARRAY_SIZE(title)); MessageBoxW(hwnd, error, title, MB_ICONEXCLAMATION | MB_OK); } else @@ -3532,11 +3510,9 @@ static void apply_general_changes(HWND hwnd) struct edit_cert_data *data = (struct edit_cert_data *)GetWindowLongPtrW(hwnd, DWLP_USER); - SendMessageW(GetDlgItem(hwnd, IDC_FRIENDLY_NAME), WM_GETTEXT, - sizeof(buf) / sizeof(buf[0]), (LPARAM)buf); + SendMessageW(GetDlgItem(hwnd, IDC_FRIENDLY_NAME), WM_GETTEXT, ARRAY_SIZE(buf), (LPARAM)buf); set_cert_string_property(data->cert, CERT_FRIENDLY_NAME_PROP_ID, buf); - SendMessageW(GetDlgItem(hwnd, IDC_DESCRIPTION), WM_GETTEXT, - sizeof(buf) / sizeof(buf[0]), (LPARAM)buf); + SendMessageW(GetDlgItem(hwnd, IDC_DESCRIPTION), WM_GETTEXT, ARRAY_SIZE(buf), (LPARAM)buf); set_cert_string_property(data->cert, CERT_DESCRIPTION_PROP_ID, buf); if (IsDlgButtonChecked(hwnd, IDC_ENABLE_ALL_PURPOSES)) { @@ -3829,7 +3805,7 @@ static LRESULT CALLBACK detail_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, LVITEMW item; int res; - item.cchTextMax = sizeof(buf) / sizeof(buf[0]); + item.cchTextMax = ARRAY_SIZE(buf); item.mask = LVIF_TEXT; item.pszText = buf; item.iItem = nm->iItem; @@ -4695,12 +4671,10 @@ static void import_warning(DWORD dwFlags, HWND hwnd, LPCWSTR szTitle, pTitle = szTitle; else { - LoadStringW(hInstance, IDS_IMPORT_WIZARD, title, - sizeof(title) / sizeof(title[0])); + LoadStringW(hInstance, IDS_IMPORT_WIZARD, title, ARRAY_SIZE(title)); pTitle = title; } - LoadStringW(hInstance, warningID, error, - sizeof(error) / sizeof(error[0])); + LoadStringW(hInstance, warningID, error, ARRAY_SIZE(error)); MessageBoxW(hwnd, error, pTitle, MB_ICONERROR | MB_OK); } } @@ -4875,8 +4849,7 @@ static LRESULT CALLBACK import_welcome_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, int height; data = (struct ImportWizData *)page->lParam; - LoadStringW(hInstance, IDS_WIZARD_TITLE_FONT, fontFace, - sizeof(fontFace) / sizeof(fontFace[0])); + LoadStringW(hInstance, IDS_WIZARD_TITLE_FONT, fontFace, ARRAY_SIZE(fontFace)); height = -MulDiv(12, GetDeviceCaps(hDC, LOGPIXELSY), 72); data->titleFont = CreateFontW(height, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, @@ -4935,7 +4908,7 @@ static WCHAR *make_import_file_filter(DWORD dwFlags) int len, totalLen = 2; LPWSTR filter = NULL, str; - for (i = 0; i < sizeof(import_filters) / sizeof(import_filters[0]); i++) + for (i = 0; i < ARRAY_SIZE(import_filters); i++) { if (!import_filters[i].allowFlags || !dwFlags || (dwFlags & import_filters[i].allowFlags)) @@ -4950,7 +4923,7 @@ static WCHAR *make_import_file_filter(DWORD dwFlags) LPWSTR ptr; ptr = filter; - for (i = 0; i < sizeof(import_filters) / sizeof(import_filters[0]); i++) + for (i = 0; i < ARRAY_SIZE(import_filters); i++) { if (!import_filters[i].allowFlags || !dwFlags || (dwFlags & import_filters[i].allowFlags)) @@ -5012,12 +4985,10 @@ static BOOL import_validate_filename(HWND hwnd, struct ImportWizData *data, pTitle = data->pwszWizardTitle; else { - LoadStringW(hInstance, IDS_IMPORT_WIZARD, title, - sizeof(title) / sizeof(title[0])); + LoadStringW(hInstance, IDS_IMPORT_WIZARD, title, ARRAY_SIZE(title)); pTitle = title; } - LoadStringW(hInstance, IDS_IMPORT_OPEN_FAILED, error, - sizeof(error) / sizeof(error[0])); + LoadStringW(hInstance, IDS_IMPORT_OPEN_FAILED, error, ARRAY_SIZE(error)); FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, (LPWSTR) &msgBuf, 0, NULL); @@ -5127,7 +5098,7 @@ static LRESULT CALLBACK import_file_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, ofn.hwndOwner = hwnd; ofn.lpstrFilter = make_import_file_filter(data->dwFlags); ofn.lpstrFile = fileBuf; - ofn.nMaxFile = sizeof(fileBuf) / sizeof(fileBuf[0]); + ofn.nMaxFile = ARRAY_SIZE(fileBuf); fileBuf[0] = 0; if (GetOpenFileNameW(&ofn)) SendMessageW(GetDlgItem(hwnd, IDC_IMPORT_FILENAME), WM_SETTEXT, @@ -5173,8 +5144,7 @@ static LRESULT CALLBACK import_store_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, EnableWindow(GetDlgItem(hwnd, IDC_IMPORT_BROWSE_STORE), TRUE); EnableWindow(GetDlgItem(hwnd, IDC_IMPORT_SPECIFY_STORE), !(data->dwFlags & CRYPTUI_WIZ_IMPORT_NO_CHANGE_DEST_STORE)); - LoadStringW(hInstance, IDS_IMPORT_DEST_DETERMINED, - storeTitle, sizeof(storeTitle) / sizeof(storeTitle[0])); + LoadStringW(hInstance, IDS_IMPORT_DEST_DETERMINED, storeTitle, ARRAY_SIZE(storeTitle)); SendMessageW(GetDlgItem(hwnd, IDC_IMPORT_STORE), WM_SETTEXT, 0, (LPARAM)storeTitle); } @@ -5242,8 +5212,8 @@ static LRESULT CALLBACK import_store_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, { WCHAR storeTitle[MAX_STRING_LEN]; - LoadStringW(hInstance, IDS_IMPORT_DEST_DETERMINED, - storeTitle, sizeof(storeTitle) / sizeof(storeTitle[0])); + LoadStringW(hInstance, IDS_IMPORT_DEST_DETERMINED, storeTitle, + ARRAY_SIZE(storeTitle)); SendMessageW(GetDlgItem(hwnd, IDC_IMPORT_STORE), WM_SETTEXT, 0, (LPARAM)storeTitle); data->hDestCertStore = store; @@ -5266,22 +5236,18 @@ static void show_import_details(HWND lv, struct ImportWizData *data) item.mask = LVIF_TEXT; item.iItem = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0); item.iSubItem = 0; - LoadStringW(hInstance, IDS_IMPORT_STORE_SELECTION, text, - sizeof(text)/ sizeof(text[0])); + LoadStringW(hInstance, IDS_IMPORT_STORE_SELECTION, text, ARRAY_SIZE(text)); item.pszText = text; SendMessageW(lv, LVM_INSERTITEMW, 0, (LPARAM)&item); item.iSubItem = 1; if (data->autoDest) - LoadStringW(hInstance, IDS_IMPORT_DEST_AUTOMATIC, text, - sizeof(text)/ sizeof(text[0])); + LoadStringW(hInstance, IDS_IMPORT_DEST_AUTOMATIC, text, ARRAY_SIZE(text)); else - LoadStringW(hInstance, IDS_IMPORT_DEST_DETERMINED, text, - sizeof(text)/ sizeof(text[0])); + LoadStringW(hInstance, IDS_IMPORT_DEST_DETERMINED, text, ARRAY_SIZE(text)); SendMessageW(lv, LVM_SETITEMTEXTW, item.iItem, (LPARAM)&item); item.iItem = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0); item.iSubItem = 0; - LoadStringW(hInstance, IDS_IMPORT_CONTENT, text, - sizeof(text)/ sizeof(text[0])); + LoadStringW(hInstance, IDS_IMPORT_CONTENT, text, ARRAY_SIZE(text)); SendMessageW(lv, LVM_INSERTITEMW, 0, (LPARAM)&item); switch (data->contentType) { @@ -5307,15 +5273,14 @@ static void show_import_details(HWND lv, struct ImportWizData *data) contentID = IDS_IMPORT_CONTENT_STORE; break; } - LoadStringW(hInstance, contentID, text, sizeof(text)/ sizeof(text[0])); + LoadStringW(hInstance, contentID, text, ARRAY_SIZE(text)); item.iSubItem = 1; SendMessageW(lv, LVM_SETITEMTEXTW, item.iItem, (LPARAM)&item); if (data->fileName) { item.iItem = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0); item.iSubItem = 0; - LoadStringW(hInstance, IDS_IMPORT_FILE, text, - sizeof(text)/ sizeof(text[0])); + LoadStringW(hInstance, IDS_IMPORT_FILE, text, ARRAY_SIZE(text)); SendMessageW(lv, LVM_INSERTITEMW, 0, (LPARAM)&item); item.iSubItem = 1; item.pszText = data->fileName; @@ -5422,12 +5387,10 @@ static LRESULT CALLBACK import_finish_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, pTitle = data->pwszWizardTitle; else { - LoadStringW(hInstance, IDS_IMPORT_WIZARD, title, - sizeof(title) / sizeof(title[0])); + LoadStringW(hInstance, IDS_IMPORT_WIZARD, title, ARRAY_SIZE(title)); pTitle = title; } - LoadStringW(hInstance, IDS_IMPORT_SUCCEEDED, message, - sizeof(message) / sizeof(message[0])); + LoadStringW(hInstance, IDS_IMPORT_SUCCEEDED, message, ARRAY_SIZE(message)); MessageBoxW(hwnd, message, pTitle, MB_OK); } else @@ -5617,8 +5580,7 @@ static LRESULT CALLBACK export_welcome_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, int height; data = (struct ExportWizData *)page->lParam; - LoadStringW(hInstance, IDS_WIZARD_TITLE_FONT, fontFace, - sizeof(fontFace) / sizeof(fontFace[0])); + LoadStringW(hInstance, IDS_WIZARD_TITLE_FONT, fontFace, ARRAY_SIZE(fontFace)); height = -MulDiv(12, GetDeviceCaps(hDC, LOGPIXELSY), 72); data->titleFont = CreateFontW(height, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, @@ -5733,8 +5695,7 @@ static LRESULT CALLBACK export_private_key_dlg_proc(HWND hwnd, UINT msg, { WCHAR error[MAX_STRING_LEN]; - LoadStringW(hInstance, errorID, error, - sizeof(error) / sizeof(error[0])); + LoadStringW(hInstance, errorID, error, ARRAY_SIZE(error)); SendMessageW(GetDlgItem(hwnd, IDC_EXPORT_PRIVATE_KEY_UNAVAILABLE), WM_SETTEXT, 0, (LPARAM)error); EnableWindow(GetDlgItem(hwnd, IDC_EXPORT_PRIVATE_KEY_YES), FALSE); @@ -5948,12 +5909,10 @@ static void export_password_mismatch(HWND hwnd, const struct ExportWizData *data pTitle = data->pwszWizardTitle; else { - LoadStringW(hInstance, IDS_EXPORT_WIZARD, title, - sizeof(title) / sizeof(title[0])); + LoadStringW(hInstance, IDS_EXPORT_WIZARD, title, ARRAY_SIZE(title)); pTitle = title; } - LoadStringW(hInstance, IDS_EXPORT_PASSWORD_MISMATCH, error, - sizeof(error) / sizeof(error[0])); + LoadStringW(hInstance, IDS_EXPORT_PASSWORD_MISMATCH, error, ARRAY_SIZE(error)); MessageBoxW(hwnd, error, pTitle, MB_ICONERROR | MB_OK); SetFocus(GetDlgItem(hwnd, IDC_EXPORT_PASSWORD)); } @@ -6113,12 +6072,10 @@ static BOOL export_validate_filename(HWND hwnd, struct ExportWizData *data, pTitle = data->pwszWizardTitle; else { - LoadStringW(hInstance, IDS_EXPORT_WIZARD, title, - sizeof(title) / sizeof(title[0])); + LoadStringW(hInstance, IDS_EXPORT_WIZARD, title, ARRAY_SIZE(title)); pTitle = title; } - LoadStringW(hInstance, IDS_EXPORT_FILE_EXISTS, warning, - sizeof(warning) / sizeof(warning[0])); + LoadStringW(hInstance, IDS_EXPORT_FILE_EXISTS, warning, ARRAY_SIZE(warning)); if (MessageBoxW(hwnd, warning, pTitle, MB_YESNO) == IDYES) forceCreate = TRUE; else @@ -6146,12 +6103,10 @@ static BOOL export_validate_filename(HWND hwnd, struct ExportWizData *data, pTitle = data->pwszWizardTitle; else { - LoadStringW(hInstance, IDS_EXPORT_WIZARD, title, - sizeof(title) / sizeof(title[0])); + LoadStringW(hInstance, IDS_EXPORT_WIZARD, title, ARRAY_SIZE(title)); pTitle = title; } - LoadStringW(hInstance, IDS_IMPORT_OPEN_FAILED, error, - sizeof(error) / sizeof(error[0])); + LoadStringW(hInstance, IDS_IMPORT_OPEN_FAILED, error, ARRAY_SIZE(error)); FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, (LPWSTR) &msgBuf, 0, NULL); @@ -6300,12 +6255,10 @@ static LRESULT CALLBACK export_file_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, pTitle = data->pwszWizardTitle; else { - LoadStringW(hInstance, IDS_EXPORT_WIZARD, title, - sizeof(title) / sizeof(title[0])); + LoadStringW(hInstance, IDS_EXPORT_WIZARD, title, ARRAY_SIZE(title)); pTitle = title; } - LoadStringW(hInstance, IDS_IMPORT_EMPTY_FILE, error, - sizeof(error) / sizeof(error[0])); + LoadStringW(hInstance, IDS_IMPORT_EMPTY_FILE, error, ARRAY_SIZE(error)); MessageBoxW(hwnd, error, pTitle, MB_ICONERROR | MB_OK); SetWindowLongPtrW(hwnd, DWLP_MSGRESULT, 1); ret = 1; @@ -6356,7 +6309,7 @@ static LRESULT CALLBACK export_file_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, data->contextInfo.dwExportFormat, data->exportInfo.dwSubjectChoice); ofn.lpstrFile = fileBuf; - ofn.nMaxFile = sizeof(fileBuf) / sizeof(fileBuf[0]); + ofn.nMaxFile = ARRAY_SIZE(fileBuf); fileBuf[0] = 0; if (GetSaveFileNameW(&ofn)) SendMessageW(GetDlgItem(hwnd, IDC_EXPORT_FILENAME), WM_SETTEXT, @@ -6381,8 +6334,7 @@ static void show_export_details(HWND lv, const struct ExportWizData *data) { item.iItem = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0); item.iSubItem = 0; - LoadStringW(hInstance, IDS_IMPORT_FILE, text, - sizeof(text)/ sizeof(text[0])); + LoadStringW(hInstance, IDS_IMPORT_FILE, text, ARRAY_SIZE(text)); item.pszText = text; SendMessageW(lv, LVM_INSERTITEMW, 0, (LPARAM)&item); item.iSubItem = 1; @@ -6403,32 +6355,27 @@ static void show_export_details(HWND lv, const struct ExportWizData *data) { item.iItem = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0); item.iSubItem = 0; - LoadStringW(hInstance, IDS_EXPORT_INCLUDE_CHAIN, text, - sizeof(text) / sizeof(text[0])); + LoadStringW(hInstance, IDS_EXPORT_INCLUDE_CHAIN, text, ARRAY_SIZE(text)); SendMessageW(lv, LVM_INSERTITEMW, item.iItem, (LPARAM)&item); item.iSubItem = 1; - LoadStringW(hInstance, - data->contextInfo.fExportChain ? IDS_YES : IDS_NO, text, - sizeof(text) / sizeof(text[0])); + LoadStringW(hInstance, data->contextInfo.fExportChain ? IDS_YES : IDS_NO, text, + ARRAY_SIZE(text)); SendMessageW(lv, LVM_SETITEMTEXTW, item.iItem, (LPARAM)&item); item.iItem = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0); item.iSubItem = 0; - LoadStringW(hInstance, IDS_EXPORT_KEYS, text, - sizeof(text) / sizeof(text[0])); + LoadStringW(hInstance, IDS_EXPORT_KEYS, text, ARRAY_SIZE(text)); SendMessageW(lv, LVM_INSERTITEMW, item.iItem, (LPARAM)&item); item.iSubItem = 1; - LoadStringW(hInstance, - data->contextInfo.fExportPrivateKeys ? IDS_YES : IDS_NO, text, - sizeof(text) / sizeof(text[0])); + LoadStringW(hInstance, data->contextInfo.fExportPrivateKeys ? IDS_YES : IDS_NO, text, + ARRAY_SIZE(text)); SendMessageW(lv, LVM_SETITEMTEXTW, item.iItem, (LPARAM)&item); } } item.iItem = SendMessageW(lv, LVM_GETITEMCOUNT, 0, 0); item.iSubItem = 0; - LoadStringW(hInstance, IDS_EXPORT_FORMAT, text, - sizeof(text)/ sizeof(text[0])); + LoadStringW(hInstance, IDS_EXPORT_FORMAT, text, ARRAY_SIZE(text)); SendMessageW(lv, LVM_INSERTITEMW, 0, (LPARAM)&item); item.iSubItem = 1; @@ -6459,7 +6406,7 @@ static void show_export_details(HWND lv, const struct ExportWizData *data) contentID = IDS_EXPORT_FILTER_CERT; } } - LoadStringW(hInstance, contentID, text, sizeof(text) / sizeof(text[0])); + LoadStringW(hInstance, contentID, text, ARRAY_SIZE(text)); SendMessageW(lv, LVM_SETITEMTEXTW, item.iItem, (LPARAM)&item); } @@ -6831,12 +6778,10 @@ static LRESULT CALLBACK export_finish_dlg_proc(HWND hwnd, UINT msg, WPARAM wp, pTitle = data->pwszWizardTitle; else { - LoadStringW(hInstance, IDS_EXPORT_WIZARD, title, - sizeof(title) / sizeof(title[0])); + LoadStringW(hInstance, IDS_EXPORT_WIZARD, title, ARRAY_SIZE(title)); pTitle = title; } - LoadStringW(hInstance, messageID, message, - sizeof(message) / sizeof(message[0])); + LoadStringW(hInstance, messageID, message, ARRAY_SIZE(message)); MessageBoxW(hwnd, message, pTitle, mbFlags); break; } diff --git a/media/doc/README.WINE b/media/doc/README.WINE index f102b5aa95..ee52066a8b 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -62,7 +62,7 @@ reactos/dll/win32/crypt32 # Synced to WineStaging-3.17 reactos/dll/win32/cryptdlg # Synced to WineStaging-3.3 reactos/dll/win32/cryptdll # Synced to WineStaging-3.3 reactos/dll/win32/cryptnet # Synced to WineStaging-3.3 -reactos/dll/win32/cryptui # Synced to WineStaging-3.3 +reactos/dll/win32/cryptui # Synced to WineStaging-3.17 reactos/dll/win32/dbghelp # Synced to WineStaging-3.9 reactos/dll/win32/dciman32 # Synced to WineStaging-3.3 reactos/dll/win32/faultrep # Synced to WineStaging-2.9
6 years, 2 months
1
0
0
0
01/01: [CRYPT32_WINETEST] Sync with Wine Staging 3.17. CORE-15127
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=06fdb3e6abc71aa668718…
commit 06fdb3e6abc71aa66871851b25ef03741ee9dd22 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Oct 1 12:48:33 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Oct 1 12:48:33 2018 +0100 [CRYPT32_WINETEST] Sync with Wine Staging 3.17. CORE-15127 --- modules/rostests/winetests/crypt32/base64.c | 350 +++++++++++++++------ modules/rostests/winetests/crypt32/cert.c | 2 +- modules/rostests/winetests/crypt32/chain.c | 451 ++++++++++++---------------- modules/rostests/winetests/crypt32/encode.c | 276 ++++------------- modules/rostests/winetests/crypt32/main.c | 8 +- modules/rostests/winetests/crypt32/msg.c | 6 +- modules/rostests/winetests/crypt32/oid.c | 101 +++---- modules/rostests/winetests/crypt32/sip.c | 9 +- modules/rostests/winetests/crypt32/store.c | 6 +- modules/rostests/winetests/crypt32/str.c | 17 +- 10 files changed, 557 insertions(+), 669 deletions(-) diff --git a/modules/rostests/winetests/crypt32/base64.c b/modules/rostests/winetests/crypt32/base64.c index e127fc3891..4ff76272e3 100644 --- a/modules/rostests/winetests/crypt32/base64.c +++ b/modules/rostests/winetests/crypt32/base64.c @@ -20,11 +20,10 @@ */ #include <stdio.h> #include <stdarg.h> -#include <windef.h> -#include <winbase.h> -#include <winerror.h> +#include <windows.h> #include <wincrypt.h> +#include "wine/heap.h" #include "wine/test.h" #define CERT_HEADER "-----BEGIN CERTIFICATE-----\r\n" @@ -56,6 +55,8 @@ static const BYTE toEncode4[] = "abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890" "abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890" "abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890"; +static const BYTE toEncode5[] = + "abcdefghijlkmnopqrstuvwxyz01234567890ABCDEFGHI"; static const struct BinTests tests[] = { { toEncode1, sizeof(toEncode1), "AA==\r\n", }, @@ -67,6 +68,8 @@ static const struct BinTests tests[] = { "d3h5ejAxMjM0NTY3ODkwQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVowMTIzNDU2\r\n" "Nzg5MGFiY2RlZmdoaWpsa21ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OTBBQkNERUZH\r\n" "SElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTY3ODkwAA==\r\n" }, + { toEncode5, sizeof(toEncode5), + "YWJjZGVmZ2hpamxrbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5MEFCQ0RFRkdISQA=\r\n" }, }; static const struct BinTests testsNoCR[] = { @@ -79,131 +82,284 @@ static const struct BinTests testsNoCR[] = { "d3h5ejAxMjM0NTY3ODkwQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVowMTIzNDU2\n" "Nzg5MGFiY2RlZmdoaWpsa21ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OTBBQkNERUZH\n" "SElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTY3ODkwAA==\n" }, + { toEncode5, sizeof(toEncode5), + "YWJjZGVmZ2hpamxrbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5MEFCQ0RFRkdISQA=\n" }, }; +static WCHAR *strdupAtoW(const char *str) +{ + WCHAR *ret = NULL; + DWORD len; + + if (!str) return ret; + len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); + ret = heap_alloc(len * sizeof(WCHAR)); + if (ret) + MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); + return ret; +} + static void encodeAndCompareBase64_A(const BYTE *toEncode, DWORD toEncodeLen, DWORD format, const char *expected, const char *header, const char *trailer) { - DWORD strLen = 0; + DWORD strLen, strLen2, required; + const char *ptr; LPSTR str = NULL; BOOL ret; + required = strlen(expected) + 1; + if (header) + required += strlen(header); + if (trailer) + required += strlen(trailer); + + strLen = 0; ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, NULL, &strLen); ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); - str = HeapAlloc(GetProcessHeap(), 0, strLen); - if (str) + ok(strLen == required, "Unexpected required length %u, expected %u.\n", required, strLen); + + strLen2 = strLen; + ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, NULL, &strLen2); + ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); + ok(strLen == strLen2, "Unexpected required length.\n"); + + strLen2 = strLen - 1; + ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, NULL, &strLen2); + ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); + ok(strLen == strLen2, "Unexpected required length.\n"); + + str = heap_alloc(strLen); + + /* Partially filled output buffer. */ + strLen2 = strLen - 1; + str[0] = 0x12; + ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, str, &strLen2); +todo_wine + ok((!ret && GetLastError() == ERROR_MORE_DATA) || broken(ret) /* XP */, "CryptBinaryToStringA failed %d, error %d.\n", + ret, GetLastError()); + ok(strLen2 == strLen || broken(strLen2 == strLen - 1), "Expected length %d, got %d\n", strLen - 1, strLen); +todo_wine { + if (header) + ok(str[0] == header[0], "Unexpected buffer contents %#x.\n", str[0]); + else + ok(str[0] == expected[0], "Unexpected buffer contents %#x.\n", str[0]); +} + strLen2 = strLen; + ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, str, &strLen2); + ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); + ok(strLen2 == strLen - 1, "Expected length %d, got %d\n", strLen - 1, strLen); + + ptr = str; + if (header) { - DWORD strLen2 = strLen; - LPCSTR ptr = str; + ok(!strncmp(header, ptr, strlen(header)), "Expected header %s, got %s\n", header, ptr); + ptr += strlen(header); + } + ok(!strncmp(expected, ptr, strlen(expected)), "Expected %s, got %s\n", expected, ptr); + ptr += strlen(expected); + if (trailer) + ok(!strncmp(trailer, ptr, strlen(trailer)), "Expected trailer %s, got %s\n", trailer, ptr); - ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, str, - &strLen2); - ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); - ok(strLen2 == strLen - 1, "Expected length %d, got %d\n", - strLen - 1, strLen); - if (header) - { - ok(!strncmp(header, ptr, strlen(header)), - "Expected header %s, got %s\n", header, ptr); - ptr += strlen(header); - } - ok(!strncmp(expected, ptr, strlen(expected)), - "Expected %s, got %s\n", expected, ptr); - ptr += strlen(expected); - if (trailer) - ok(!strncmp(trailer, ptr, strlen(trailer)), - "Expected trailer %s, got %s\n", trailer, ptr); - HeapFree(GetProcessHeap(), 0, str); + heap_free(str); +} + +static void encode_compare_base64_W(const BYTE *toEncode, DWORD toEncodeLen, DWORD format, + const WCHAR *expected, const char *header, const char *trailer) +{ + WCHAR *headerW, *trailerW, required; + DWORD strLen, strLen2; + WCHAR *strW = NULL; + const WCHAR *ptr; + BOOL ret; + + required = lstrlenW(expected) + 1; + if (header) + required += strlen(header); + if (trailer) + required += strlen(trailer); + + strLen = 0; + ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, NULL, &strLen); + ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError()); + ok(strLen == required, "Unexpected required length %u, expected %u.\n", strLen, required); + + /* Same call with non-zero length value. */ + strLen2 = strLen; + ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, NULL, &strLen2); + ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError()); + ok(strLen == strLen2, "Unexpected required length.\n"); + + strLen2 = strLen - 1; + ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, NULL, &strLen2); + ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError()); + ok(strLen == strLen2, "Unexpected required length.\n"); + + strLen2 = strLen - 1; + ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, NULL, &strLen2); + ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError()); + ok(strLen == strLen2, "Unexpected required length.\n"); + + strW = heap_alloc(strLen * sizeof(WCHAR)); + + headerW = strdupAtoW(header); + trailerW = strdupAtoW(trailer); + + strLen2 = strLen - 1; + strW[0] = 0x1234; + ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, strW, &strLen2); +todo_wine + ok((!ret && GetLastError() == ERROR_MORE_DATA) || broken(ret) /* XP */, "CryptBinaryToStringW failed, %d, error %d\n", + ret, GetLastError()); + if (headerW) + ok(strW[0] == 0x1234, "Unexpected buffer contents %#x.\n", strW[0]); + else + ok(strW[0] == 0x1234 || broken(strW[0] != 0x1234) /* XP */, "Unexpected buffer contents %#x.\n", strW[0]); + + strLen2 = strLen; + ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, strW, &strLen2); + ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError()); + + ok(strLen2 == strLen - 1, "Expected length %d, got %d\n", strLen - 1, strLen); + + ptr = strW; + if (headerW) + { + ok(!memcmp(headerW, ptr, lstrlenW(headerW)), "Expected header %s, got %s.\n", wine_dbgstr_w(headerW), + wine_dbgstr_w(ptr)); + ptr += lstrlenW(headerW); } + ok(!memcmp(expected, ptr, lstrlenW(expected)), "Expected %s, got %s.\n", wine_dbgstr_w(expected), + wine_dbgstr_w(ptr)); + ptr += lstrlenW(expected); + if (trailerW) + ok(!memcmp(trailerW, ptr, lstrlenW(trailerW)), "Expected trailer %s, got %s.\n", wine_dbgstr_w(trailerW), + wine_dbgstr_w(ptr)); + + heap_free(strW); + heap_free(headerW); + heap_free(trailerW); } -static void testBinaryToStringA(void) +static void test_CryptBinaryToString(void) { + DWORD strLen, strLen2, i; BOOL ret; - DWORD strLen = 0, i; ret = CryptBinaryToStringA(NULL, 0, 0, NULL, NULL); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); + + strLen = 123; ret = CryptBinaryToStringA(NULL, 0, 0, NULL, &strLen); ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); - for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) + ok(strLen == 123, "Unexpected length.\n"); + + if (0) + ret = CryptBinaryToStringW(NULL, 0, 0, NULL, NULL); + + strLen = 123; + ret = CryptBinaryToStringW(NULL, 0, 0, NULL, &strLen); + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Unexpected error %d\n", GetLastError()); + ok(strLen == 123, "Unexpected length.\n"); + + for (i = 0; i < ARRAY_SIZE(tests); i++) { - DWORD strLen = 0; + WCHAR *strW, *encodedW; LPSTR str = NULL; BOOL ret; - ret = CryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen, - CRYPT_STRING_BINARY, NULL, &strLen); + strLen = 0; + ret = CryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, NULL, &strLen); ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); - str = HeapAlloc(GetProcessHeap(), 0, strLen); - if (str) - { - DWORD strLen2 = strLen; - - ret = CryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen, - CRYPT_STRING_BINARY, str, &strLen2); - ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); - ok(strLen == strLen2, "Expected length %d, got %d\n", strLen, - strLen2); - ok(!memcmp(str, tests[i].toEncode, tests[i].toEncodeLen), - "Unexpected value\n"); - HeapFree(GetProcessHeap(), 0, str); - } - encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen, - CRYPT_STRING_BASE64, tests[i].base64, NULL, NULL); - encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen, - CRYPT_STRING_BASE64HEADER, tests[i].base64, CERT_HEADER, - CERT_TRAILER); - encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen, - CRYPT_STRING_BASE64REQUESTHEADER, tests[i].base64, - CERT_REQUEST_HEADER, CERT_REQUEST_TRAILER); - encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen, - CRYPT_STRING_BASE64X509CRLHEADER, tests[i].base64, X509_HEADER, - X509_TRAILER); + ok(strLen == tests[i].toEncodeLen, "Unexpected required length %u.\n", strLen); + + strLen2 = strLen; + str = heap_alloc(strLen); + ret = CryptBinaryToStringA(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, str, &strLen2); + ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); + ok(strLen == strLen2, "Expected length %u, got %u\n", strLen, strLen2); + ok(!memcmp(str, tests[i].toEncode, tests[i].toEncodeLen), "Unexpected value\n"); + heap_free(str); + + strLen = 0; + ret = CryptBinaryToStringW(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, NULL, &strLen); + ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError()); + ok(strLen == tests[i].toEncodeLen, "Unexpected required length %u.\n", strLen); + + strLen2 = strLen; + strW = heap_alloc(strLen); + ret = CryptBinaryToStringW(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BINARY, strW, &strLen2); + ok(ret, "CryptBinaryToStringW failed: %d\n", GetLastError()); + ok(strLen == strLen2, "Expected length %u, got %u\n", strLen, strLen2); + ok(!memcmp(strW, tests[i].toEncode, tests[i].toEncodeLen), "Unexpected value\n"); + heap_free(strW); + + encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BASE64, + tests[i].base64, NULL, NULL); + encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BASE64HEADER, + tests[i].base64, CERT_HEADER, CERT_TRAILER); + encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BASE64REQUESTHEADER, + tests[i].base64, CERT_REQUEST_HEADER, CERT_REQUEST_TRAILER); + encodeAndCompareBase64_A(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BASE64X509CRLHEADER, + tests[i].base64, X509_HEADER, X509_TRAILER); + + encodedW = strdupAtoW(tests[i].base64); + + encode_compare_base64_W(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BASE64, encodedW, NULL, NULL); + encode_compare_base64_W(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BASE64HEADER, encodedW, + CERT_HEADER, CERT_TRAILER); + encode_compare_base64_W(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BASE64REQUESTHEADER, + encodedW, CERT_REQUEST_HEADER, CERT_REQUEST_TRAILER); + encode_compare_base64_W(tests[i].toEncode, tests[i].toEncodeLen, CRYPT_STRING_BASE64X509CRLHEADER, encodedW, + X509_HEADER, X509_TRAILER); + + heap_free(encodedW); } - for (i = 0; i < sizeof(testsNoCR) / sizeof(testsNoCR[0]); i++) + + for (i = 0; i < ARRAY_SIZE(testsNoCR); i++) { - DWORD strLen = 0; LPSTR str = NULL; + WCHAR *encodedW; BOOL ret; - ret = CryptBinaryToStringA(testsNoCR[i].toEncode, - testsNoCR[i].toEncodeLen, CRYPT_STRING_BINARY | CRYPT_STRING_NOCR, - NULL, &strLen); + ret = CryptBinaryToStringA(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen, + CRYPT_STRING_BINARY | CRYPT_STRING_NOCR, NULL, &strLen); ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); - str = HeapAlloc(GetProcessHeap(), 0, strLen); - if (str) - { - DWORD strLen2 = strLen; - - ret = CryptBinaryToStringA(testsNoCR[i].toEncode, - testsNoCR[i].toEncodeLen, CRYPT_STRING_BINARY | CRYPT_STRING_NOCR, - str, &strLen2); - ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); - ok(strLen == strLen2, "Expected length %d, got %d\n", strLen, - strLen2); - ok(!memcmp(str, testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen), - "Unexpected value\n"); - HeapFree(GetProcessHeap(), 0, str); - } - encodeAndCompareBase64_A(testsNoCR[i].toEncode, - testsNoCR[i].toEncodeLen, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCR, - testsNoCR[i].base64, NULL, NULL); - encodeAndCompareBase64_A(testsNoCR[i].toEncode, - testsNoCR[i].toEncodeLen, - CRYPT_STRING_BASE64HEADER | CRYPT_STRING_NOCR, testsNoCR[i].base64, - CERT_HEADER_NOCR, CERT_TRAILER_NOCR); - encodeAndCompareBase64_A(testsNoCR[i].toEncode, - testsNoCR[i].toEncodeLen, - CRYPT_STRING_BASE64REQUESTHEADER | CRYPT_STRING_NOCR, - testsNoCR[i].base64, CERT_REQUEST_HEADER_NOCR, - CERT_REQUEST_TRAILER_NOCR); - encodeAndCompareBase64_A(testsNoCR[i].toEncode, - testsNoCR[i].toEncodeLen, - CRYPT_STRING_BASE64X509CRLHEADER | CRYPT_STRING_NOCR, - testsNoCR[i].base64, X509_HEADER_NOCR, X509_TRAILER_NOCR); + + strLen2 = strLen; + str = heap_alloc(strLen); + ret = CryptBinaryToStringA(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen, + CRYPT_STRING_BINARY | CRYPT_STRING_NOCR, str, &strLen2); + ok(ret, "CryptBinaryToStringA failed: %d\n", GetLastError()); + ok(strLen == strLen2, "Expected length %d, got %d\n", strLen, strLen2); + ok(!memcmp(str, testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen), "Unexpected value\n"); + heap_free(str); + + encodeAndCompareBase64_A(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCR, + testsNoCR[i].base64, NULL, NULL); + encodeAndCompareBase64_A(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen, + CRYPT_STRING_BASE64HEADER | CRYPT_STRING_NOCR, testsNoCR[i].base64, CERT_HEADER_NOCR, CERT_TRAILER_NOCR); + encodeAndCompareBase64_A(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen, + CRYPT_STRING_BASE64REQUESTHEADER | CRYPT_STRING_NOCR, testsNoCR[i].base64, CERT_REQUEST_HEADER_NOCR, + CERT_REQUEST_TRAILER_NOCR); + encodeAndCompareBase64_A(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen, + CRYPT_STRING_BASE64X509CRLHEADER | CRYPT_STRING_NOCR, testsNoCR[i].base64, X509_HEADER_NOCR, X509_TRAILER_NOCR); + + encodedW = strdupAtoW(testsNoCR[i].base64); + + encode_compare_base64_W(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen, + CRYPT_STRING_BASE64 | CRYPT_STRING_NOCR, encodedW, NULL, NULL); + encode_compare_base64_W(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen, + CRYPT_STRING_BASE64HEADER | CRYPT_STRING_NOCR, encodedW, CERT_HEADER_NOCR, CERT_TRAILER_NOCR); + encode_compare_base64_W(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen, + CRYPT_STRING_BASE64REQUESTHEADER | CRYPT_STRING_NOCR, encodedW, CERT_REQUEST_HEADER_NOCR, + CERT_REQUEST_TRAILER_NOCR); + encode_compare_base64_W(testsNoCR[i].toEncode, testsNoCR[i].toEncodeLen, + CRYPT_STRING_BASE64X509CRLHEADER | CRYPT_STRING_NOCR, encodedW, + X509_HEADER_NOCR, X509_TRAILER_NOCR); + + heap_free(encodedW); } } @@ -380,7 +536,7 @@ static void testStringToBinaryA(void) ok(!ret && GetLastError() == ERROR_INVALID_DATA, "Expected ERROR_INVALID_DATA, got ret=%d le=%u\n", ret, GetLastError()); /* Bad strings */ - for (i = 0; i < sizeof(badStrings) / sizeof(badStrings[0]); i++) + for (i = 0; i < ARRAY_SIZE(badStrings); i++) { bufLen = 0; ret = CryptStringToBinaryA(badStrings[i].str, 0, badStrings[i].format, @@ -447,7 +603,7 @@ static void testStringToBinaryA(void) ret, bufLen, buf[0]); /* Good strings */ - for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) + for (i = 0; i < ARRAY_SIZE(tests); i++) { bufLen = 0; /* Bogus length--oddly enough, that succeeds, even though it's not @@ -504,7 +660,7 @@ static void testStringToBinaryA(void) */ } /* And again, with no CR--decoding handles this automatically */ - for (i = 0; i < sizeof(testsNoCR) / sizeof(testsNoCR[0]); i++) + for (i = 0; i < ARRAY_SIZE(testsNoCR); i++) { bufLen = 0; /* Bogus length--oddly enough, that succeeds, even though it's not @@ -545,6 +701,6 @@ static void testStringToBinaryA(void) START_TEST(base64) { - testBinaryToStringA(); + test_CryptBinaryToString(); testStringToBinaryA(); } diff --git a/modules/rostests/winetests/crypt32/cert.c b/modules/rostests/winetests/crypt32/cert.c index e49b2a9798..bb0cc525e7 100644 --- a/modules/rostests/winetests/crypt32/cert.c +++ b/modules/rostests/winetests/crypt32/cert.c @@ -3177,7 +3177,7 @@ static void testCompareIntegerBlob(void) DWORD i; BOOL ret; - for (i = 0; i < sizeof(intBlobs) / sizeof(intBlobs[0]); i++) + for (i = 0; i < ARRAY_SIZE(intBlobs); i++) { ret = CertCompareIntegerBlob(&intBlobs[i].blob1, &intBlobs[i].blob2); ok(ret == intBlobs[i].areEqual, diff --git a/modules/rostests/winetests/crypt32/chain.c b/modules/rostests/winetests/crypt32/chain.c index e3b280b088..e2a7633526 100644 --- a/modules/rostests/winetests/crypt32/chain.c +++ b/modules/rostests/winetests/crypt32/chain.c @@ -2889,59 +2889,6 @@ static const BYTE chain31_1[] = { 0x43,0x08,0xe5,0x78,0x2b,0x95,0xf3,0x75,0xb6,0x88,0xf0,0x6b,0x5c,0x5b,0x50, 0x04,0x91,0x3b,0x89,0x5a,0x60,0x1f,0xfc,0x36,0x53,0x32,0x36,0x0a,0x4d,0x03, 0x2c,0xd7 }; -static const BYTE ecc_crt[] = { -0x30,0x82,0x01,0x46,0x30,0x81,0xec,0x02,0x09,0x00,0xe7,0x6b,0x26,0x86,0x0a, -0x82,0xff,0xe9,0x30,0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x04,0x03,0x02, -0x30,0x2b,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x44,0x45, -0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x0a,0x0c,0x04,0x57,0x69,0x6e,0x65, -0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x03,0x0c,0x04,0x57,0x69,0x6e,0x65, -0x30,0x1e,0x17,0x0d,0x31,0x37,0x30,0x39,0x32,0x37,0x31,0x33,0x34,0x31,0x30, -0x34,0x5a,0x17,0x0d,0x32,0x37,0x30,0x39,0x32,0x35,0x31,0x33,0x34,0x31,0x30, -0x34,0x5a,0x30,0x2b,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02, -0x44,0x45,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x0a,0x0c,0x04,0x54,0x65, -0x73,0x74,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x03,0x0c,0x04,0x54,0x65, -0x73,0x74,0x30,0x59,0x30,0x13,0x06,0x07,0x2a,0x86,0x48,0xce,0x3d,0x02,0x01, -0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x03,0x01,0x07,0x03,0x42,0x00,0x04,0xed, -0xfc,0x77,0xd8,0xb9,0xe7,0xf3,0xf8,0xce,0x13,0xb8,0x7f,0x0f,0x78,0xea,0x73, -0x87,0x29,0x10,0xe1,0x6d,0x10,0xce,0x57,0x60,0x3b,0x3e,0xb4,0x5f,0x0d,0x20, -0xc1,0xeb,0x6d,0x74,0xe9,0x7b,0x11,0x51,0x9a,0x00,0xe8,0xe9,0x12,0x84,0xb9, -0x07,0x7e,0x7b,0x62,0x67,0x12,0x67,0x08,0xe5,0x2e,0x27,0xce,0xa2,0x57,0x15, -0xad,0xc5,0x1f,0x30,0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x04,0x03,0x02, -0x03,0x49,0x00,0x30,0x46,0x02,0x21,0x00,0xd7,0x29,0xce,0x5a,0xef,0x74,0x85, -0xd1,0x18,0x5f,0x6e,0xf1,0xba,0x53,0xd4,0xcd,0xdd,0xe0,0x5d,0xf1,0x5e,0x48, -0x51,0xea,0x63,0xc0,0xe8,0xe2,0xf6,0xfa,0x4c,0xaf,0x02,0x21,0x00,0xe3,0x94, -0x15,0x3b,0x6c,0x71,0x6e,0x44,0x22,0xcb,0xa0,0x88,0xcd,0x0a,0x5a,0x50,0x29, -0x7c,0x5c,0xd6,0x6c,0xd2,0xe0,0x7f,0xcd,0x02,0x92,0x21,0x4c,0x2c,0x92,0xee }; -static const BYTE ecc_ca[] = { -0x30,0x82,0x01,0x9f,0x30,0x82,0x01,0x46,0xa0,0x03,0x02,0x01,0x02,0x02,0x09, -0x00,0xf1,0x54,0xae,0x21,0x2e,0x4d,0x31,0x9f,0x30,0x0a,0x06,0x08,0x2a,0x86, -0x48,0xce,0x3d,0x04,0x03,0x02,0x30,0x2b,0x31,0x0b,0x30,0x09,0x06,0x03,0x55, -0x04,0x06,0x13,0x02,0x44,0x45,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x0a, -0x0c,0x04,0x57,0x69,0x6e,0x65,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x03, -0x0c,0x04,0x57,0x69,0x6e,0x65,0x30,0x1e,0x17,0x0d,0x31,0x37,0x30,0x39,0x32, -0x37,0x31,0x33,0x33,0x39,0x31,0x35,0x5a,0x17,0x0d,0x32,0x37,0x30,0x39,0x32, -0x35,0x31,0x33,0x33,0x39,0x31,0x35,0x5a,0x30,0x2b,0x31,0x0b,0x30,0x09,0x06, -0x03,0x55,0x04,0x06,0x13,0x02,0x44,0x45,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55, -0x04,0x0a,0x0c,0x04,0x57,0x69,0x6e,0x65,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55, -0x04,0x03,0x0c,0x04,0x57,0x69,0x6e,0x65,0x30,0x59,0x30,0x13,0x06,0x07,0x2a, -0x86,0x48,0xce,0x3d,0x02,0x01,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x03,0x01, -0x07,0x03,0x42,0x00,0x04,0x3b,0x3c,0x34,0xc8,0x3f,0x15,0xea,0x02,0x68,0x46, -0x69,0xdf,0x0c,0xa6,0xee,0x7a,0xd9,0x82,0x08,0x9b,0x37,0x53,0x42,0xf3,0x13, -0x63,0xda,0x65,0x79,0xe8,0x04,0x9e,0x8c,0x77,0xc4,0x33,0x77,0xd9,0x5a,0x7f, -0x60,0x7b,0x98,0xce,0xf3,0x96,0x56,0xd6,0xb5,0x8d,0x87,0x7a,0x00,0x2b,0xf3, -0x70,0xb3,0x90,0x73,0xa0,0x56,0x06,0x3b,0x22,0xa3,0x53,0x30,0x51,0x30,0x1d, -0x06,0x03,0x55,0x1d,0x0e,0x04,0x16,0x04,0x14,0x26,0xef,0x6f,0xe4,0xb5,0x24, -0x2f,0x68,0x49,0x84,0xd9,0x89,0xa6,0xab,0x0c,0xf8,0x6d,0xf5,0xe5,0x0c,0x30, -0x1f,0x06,0x03,0x55,0x1d,0x23,0x04,0x18,0x30,0x16,0x80,0x14,0x26,0xef,0x6f, -0xe4,0xb5,0x24,0x2f,0x68,0x49,0x84,0xd9,0x89,0xa6,0xab,0x0c,0xf8,0x6d,0xf5, -0xe5,0x0c,0x30,0x0f,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,0xff,0x04,0x05,0x30, -0x03,0x01,0x01,0xff,0x30,0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x04,0x03, -0x02,0x03,0x47,0x00,0x30,0x44,0x02,0x20,0x2b,0x6b,0x23,0x42,0x32,0xf2,0xcb, -0x71,0xd7,0x5c,0xfa,0x5e,0x6c,0x19,0x31,0xd6,0x74,0xf7,0xc0,0xf8,0xc6,0x39, -0x38,0xe9,0x79,0x4d,0x84,0x44,0x40,0x13,0x8e,0x43,0x02,0x20,0x34,0xc7,0x61, -0xbb,0x18,0x1c,0x85,0x34,0xe3,0x4c,0x30,0x28,0x42,0x0e,0x06,0x65,0x68,0x1d, -0x76,0x53,0x24,0xa0,0x27,0xa5,0x84,0x3b,0x2d,0xf3,0xec,0x27,0x60,0xb2 }; - typedef struct _CONST_DATA_BLOB { @@ -3139,8 +3086,6 @@ static SYSTEMTIME jun2013 = { 2013, 6, 5, 6, 0, 0, 0, 0 }; static SYSTEMTIME oct2016 = { 2016, 10, 6, 1, 0, 0, 0, 0 }; /* Wednesday, Nov 17, 2016 */ static SYSTEMTIME nov2016 = { 2016, 11, 3, 17, 0, 0, 0, 0 }; -/* Wednesday, Nov 17, 2017 */ -static SYSTEMTIME nov2017 = { 2017, 11, 3, 17, 0, 0, 0, 0 }; typedef struct _ChainCheck { @@ -3160,7 +3105,7 @@ static const CERT_TRUST_STATUS elementStatus0[] = { CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED }, }; static const SimpleChainStatusCheck simpleStatus0[] = { - { sizeof(elementStatus0) / sizeof(elementStatus0[0]), elementStatus0 }, + { ARRAY_SIZE(elementStatus0), elementStatus0 }, }; static CONST_DATA_BLOB chain1[] = { { sizeof(chain0_0), chain0_0 }, @@ -3173,7 +3118,7 @@ static const CERT_TRUST_STATUS elementStatus1[] = { CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED }, }; static const SimpleChainStatusCheck simpleStatus1[] = { - { sizeof(elementStatus1) / sizeof(elementStatus1[0]), elementStatus1 }, + { ARRAY_SIZE(elementStatus1), elementStatus1 }, }; static CONST_DATA_BLOB chain2[] = { { sizeof(chain2_0), chain2_0 }, @@ -3185,7 +3130,7 @@ static const CERT_TRUST_STATUS elementStatus2[] = { CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED }, }; static const SimpleChainStatusCheck simpleStatus2[] = { - { sizeof(elementStatus2) / sizeof(elementStatus2[0]), elementStatus2 }, + { ARRAY_SIZE(elementStatus2), elementStatus2 }, }; static CONST_DATA_BLOB chain3[] = { { sizeof(chain3_0), chain3_0 }, @@ -3197,7 +3142,7 @@ static const CERT_TRUST_STATUS elementStatus3[] = { CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED }, }; static const SimpleChainStatusCheck simpleStatus3[] = { - { sizeof(elementStatus3) / sizeof(elementStatus3[0]), elementStatus3 }, + { ARRAY_SIZE(elementStatus3), elementStatus3 }, }; static CONST_DATA_BLOB chain4[] = { { sizeof(chain4_0), chain4_0 }, @@ -3211,7 +3156,7 @@ static const CERT_TRUST_STATUS elementStatus4[] = { CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED }, }; static const SimpleChainStatusCheck simpleStatus4[] = { - { sizeof(elementStatus4) / sizeof(elementStatus4[0]), elementStatus4 }, + { ARRAY_SIZE(elementStatus4), elementStatus4 }, }; static CONST_DATA_BLOB chain5[] = { { sizeof(chain5_0), chain5_0 }, @@ -3224,7 +3169,7 @@ static const CERT_TRUST_STATUS elementStatus5[] = { CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED }, }; static const SimpleChainStatusCheck simpleStatus5[] = { - { sizeof(elementStatus5) / sizeof(elementStatus5[0]), elementStatus5 }, + { ARRAY_SIZE(elementStatus5), elementStatus5 }, }; static CONST_DATA_BLOB chain6[] = { { sizeof(chain0_0), chain0_0 }, @@ -3236,7 +3181,7 @@ static const CERT_TRUST_STATUS elementStatus6[] = { CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED }, }; static const SimpleChainStatusCheck simpleStatus6[] = { - { sizeof(elementStatus6) / sizeof(elementStatus6[0]), elementStatus6 }, + { ARRAY_SIZE(elementStatus6), elementStatus6 }, }; static CONST_DATA_BLOB chain7[] = { { sizeof(chain0_0), chain0_0 }, @@ -3248,7 +3193,7 @@ static const CERT_TRUST_STATUS elementStatus7[] = { CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED }, }; static const SimpleChainStatusCheck simpleStatus7[] = { - { sizeof(elementStatus7) / sizeof(elementStatus7[0]), elementStatus7 }, + { ARRAY_SIZE(elementStatus7), elementStatus7 }, }; static CONST_DATA_BLOB chain8[] = { { sizeof(chain8_0), chain8_0 }, @@ -3262,7 +3207,7 @@ static const CERT_TRUST_STATUS elementStatus8[] = { CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED }, }; static const SimpleChainStatusCheck simpleStatus8[] = { - { sizeof(elementStatus8) / sizeof(elementStatus8[0]), elementStatus8 }, + { ARRAY_SIZE(elementStatus8), elementStatus8 }, }; static CONST_DATA_BLOB chain9[] = { { sizeof(chain9_0), chain9_0 }, @@ -3275,7 +3220,7 @@ static const CERT_TRUST_STATUS elementStatus9[] = { CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus9[] = { - { sizeof(elementStatus9) / sizeof(elementStatus9[0]), elementStatus9 }, + { ARRAY_SIZE(elementStatus9), elementStatus9 }, }; static CONST_DATA_BLOB chain10[] = { { sizeof(chain0_0), chain0_0 }, @@ -3288,7 +3233,7 @@ static const CERT_TRUST_STATUS elementStatus10[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus10[] = { - { sizeof(elementStatus10) / sizeof(elementStatus10[0]), elementStatus10 }, + { ARRAY_SIZE(elementStatus10), elementStatus10 }, }; static CONST_DATA_BLOB chain11[] = { { sizeof(chain0_0), chain0_0 }, @@ -3305,7 +3250,7 @@ static const CERT_TRUST_STATUS elementStatus12[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus12[] = { - { sizeof(elementStatus12) / sizeof(elementStatus12[0]), elementStatus12 }, + { ARRAY_SIZE(elementStatus12), elementStatus12 }, }; static CONST_DATA_BLOB chain13[] = { { sizeof(chain0_0), chain0_0 }, @@ -3317,7 +3262,7 @@ static const CERT_TRUST_STATUS elementStatus13[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus13[] = { - { sizeof(elementStatus13) / sizeof(elementStatus13[0]), elementStatus13 }, + { ARRAY_SIZE(elementStatus13), elementStatus13 }, }; static CONST_DATA_BLOB chain14[] = { { sizeof(chain14_0), chain14_0 }, @@ -3329,7 +3274,7 @@ static const CERT_TRUST_STATUS elementStatus14[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus14[] = { - { sizeof(elementStatus14) / sizeof(elementStatus14[0]), elementStatus14 }, + { ARRAY_SIZE(elementStatus14), elementStatus14 }, }; static CONST_DATA_BLOB chain15[] = { { sizeof(chain15_0), chain15_0 }, @@ -3341,7 +3286,7 @@ static const CERT_TRUST_STATUS elementStatus15[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus15[] = { - { sizeof(elementStatus15) / sizeof(elementStatus15[0]), elementStatus15 }, + { ARRAY_SIZE(elementStatus15), elementStatus15 }, }; static CONST_DATA_BLOB chain16[] = { { sizeof(chain0_0), chain0_0 }, @@ -3354,7 +3299,7 @@ static const CERT_TRUST_STATUS elementStatus16[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus16[] = { - { sizeof(elementStatus16) / sizeof(elementStatus16[0]), elementStatus16 }, + { ARRAY_SIZE(elementStatus16), elementStatus16 }, }; static CONST_DATA_BLOB chain17[] = { { sizeof(chain0_0), chain0_0 }, @@ -3368,7 +3313,7 @@ static const CERT_TRUST_STATUS elementStatus17[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus17[] = { - { sizeof(elementStatus17) / sizeof(elementStatus17[0]), elementStatus17 }, + { ARRAY_SIZE(elementStatus17), elementStatus17 }, }; static CONST_DATA_BLOB chain18[] = { { sizeof(chain0_0), chain0_0 }, @@ -3382,7 +3327,7 @@ static const CERT_TRUST_STATUS elementStatus18[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus18[] = { - { sizeof(elementStatus18) / sizeof(elementStatus18[0]), elementStatus18 }, + { ARRAY_SIZE(elementStatus18), elementStatus18 }, }; static CONST_DATA_BLOB chain19[] = { { sizeof(chain19_0), chain19_0 }, @@ -3395,7 +3340,7 @@ static const CERT_TRUST_STATUS elementStatus19[] = { CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS }, }; static const SimpleChainStatusCheck simpleStatus19[] = { - { sizeof(elementStatus19) / sizeof(elementStatus19[0]), elementStatus19 }, + { ARRAY_SIZE(elementStatus19), elementStatus19 }, }; static CONST_DATA_BLOB chain20[] = { { sizeof(chain20_0), chain20_0 }, @@ -3407,7 +3352,7 @@ static const CERT_TRUST_STATUS elementStatus20[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus20[] = { - { sizeof(elementStatus20) / sizeof(elementStatus20[0]), elementStatus20 }, + { ARRAY_SIZE(elementStatus20), elementStatus20 }, }; static CONST_DATA_BLOB chain21[] = { { sizeof(chain21_0), chain21_0 }, @@ -3420,7 +3365,7 @@ static const CERT_TRUST_STATUS elementStatus21[] = { CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS }, }; static const SimpleChainStatusCheck simpleStatus21[] = { - { sizeof(elementStatus21) / sizeof(elementStatus21[0]), elementStatus21 }, + { ARRAY_SIZE(elementStatus21), elementStatus21 }, }; static CONST_DATA_BLOB chain22[] = { { sizeof(chain22_0), chain22_0 }, @@ -3432,7 +3377,7 @@ static const CERT_TRUST_STATUS elementStatus22[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus22[] = { - { sizeof(elementStatus22) / sizeof(elementStatus22[0]), elementStatus22 }, + { ARRAY_SIZE(elementStatus22), elementStatus22 }, }; static CONST_DATA_BLOB chain23[] = { { sizeof(chain23_0), chain23_0 }, @@ -3444,7 +3389,7 @@ static const CERT_TRUST_STATUS elementStatus23[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus23[] = { - { sizeof(elementStatus23) / sizeof(elementStatus23[0]), elementStatus23 }, + { ARRAY_SIZE(elementStatus23), elementStatus23 }, }; static CONST_DATA_BLOB chain24[] = { { sizeof(chain24_0), chain24_0 }, @@ -3456,7 +3401,7 @@ static const CERT_TRUST_STATUS elementStatus24[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus24[] = { - { sizeof(elementStatus24) / sizeof(elementStatus24[0]), elementStatus24 }, + { ARRAY_SIZE(elementStatus24), elementStatus24 }, }; static CONST_DATA_BLOB chain25[] = { { sizeof(chain25_0), chain25_0 }, @@ -3468,7 +3413,7 @@ static const CERT_TRUST_STATUS elementStatus25[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus25[] = { - { sizeof(elementStatus25) / sizeof(elementStatus25[0]), elementStatus25 }, + { ARRAY_SIZE(elementStatus25), elementStatus25 }, }; static CONST_DATA_BLOB chain26[] = { { sizeof(chain26_0), chain26_0 }, @@ -3480,7 +3425,7 @@ static const CERT_TRUST_STATUS elementStatus26[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus26[] = { - { sizeof(elementStatus26) / sizeof(elementStatus26[0]), elementStatus26 }, + { ARRAY_SIZE(elementStatus26), elementStatus26 }, }; static CONST_DATA_BLOB chain27[] = { { sizeof(chain27_0), chain27_0 }, @@ -3493,7 +3438,7 @@ static const CERT_TRUST_STATUS elementStatus27[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus27[] = { - { sizeof(elementStatus27) / sizeof(elementStatus27[0]), elementStatus27 }, + { ARRAY_SIZE(elementStatus27), elementStatus27 }, }; static const CERT_TRUST_STATUS elementStatus27Broken[] = { { CERT_TRUST_NO_ERROR, CERT_TRUST_HAS_NAME_MATCH_ISSUER }, @@ -3502,7 +3447,7 @@ static const CERT_TRUST_STATUS elementStatus27Broken[] = { CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS }, }; static const SimpleChainStatusCheck simpleStatus27Broken[] = { - { sizeof(elementStatus27Broken) / sizeof(elementStatus27Broken[0]), + { ARRAY_SIZE(elementStatus27Broken), elementStatus27Broken }, }; static CONST_DATA_BLOB chain28[] = { @@ -3515,7 +3460,7 @@ static const CERT_TRUST_STATUS elementStatus28[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus28[] = { - { sizeof(elementStatus28) / sizeof(elementStatus28[0]), elementStatus28 }, + { ARRAY_SIZE(elementStatus28), elementStatus28 }, }; static CONST_DATA_BLOB chain29[] = { { sizeof(chain0_0), chain0_0 }, @@ -3534,7 +3479,7 @@ static const CERT_TRUST_STATUS elementStatus30[] = { CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus30[] = { - { sizeof(elementStatus30) / sizeof(elementStatus30[0]), elementStatus30 }, + { ARRAY_SIZE(elementStatus30), elementStatus30 }, }; static CONST_DATA_BLOB chain31[] = { { sizeof(chain0_0), chain0_0 }, @@ -3548,7 +3493,7 @@ static const CERT_TRUST_STATUS selfSignedElementStatus[] = { CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED }, }; static const SimpleChainStatusCheck selfSignedSimpleStatus[] = { - { sizeof(selfSignedElementStatus) / sizeof(selfSignedElementStatus[0]), + { ARRAY_SIZE(selfSignedElementStatus), selfSignedElementStatus }, }; static CONST_DATA_BLOB googleChain[] = { @@ -3567,7 +3512,7 @@ static const CERT_TRUST_STATUS googleElementStatus[] = { CERT_TRUST_HAS_KEY_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED | CERT_TRUST_HAS_PREFERRED_ISSUER}, }; static const SimpleChainStatusCheck googleSimpleStatus[] = { - { sizeof(googleElementStatus) / sizeof(googleElementStatus[0]), + { ARRAY_SIZE(googleElementStatus), googleElementStatus }, }; static CONST_DATA_BLOB battlenetChain[] = { @@ -3590,7 +3535,7 @@ static const CERT_TRUST_STATUS opensslElementStatus[] = { CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED}, }; static const SimpleChainStatusCheck opensslSimpleStatus[] = { - { sizeof(opensslElementStatus) / sizeof(opensslElementStatus[0]), + { ARRAY_SIZE(opensslElementStatus), opensslElementStatus }, }; /* The OpenSSL chain may not have its root trusted, in which case the chain @@ -3605,7 +3550,7 @@ static const CERT_TRUST_STATUS incompleteOpensslElementStatus[] = { { CERT_TRUST_NO_ERROR, CERT_TRUST_HAS_KEY_MATCH_ISSUER }, }; static const SimpleChainStatusCheck incompleteOpensslSimpleStatus[] = { - { sizeof(incompleteOpensslElementStatus) / sizeof(incompleteOpensslElementStatus[0]), + { ARRAY_SIZE(incompleteOpensslElementStatus), incompleteOpensslElementStatus }, }; /* @@ -3625,7 +3570,7 @@ static const CERT_TRUST_STATUS stanfordElementStatus[] = { CERT_TRUST_HAS_NAME_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED}, }; static const SimpleChainStatusCheck stanfordSimpleStatus[] = { - { sizeof(stanfordElementStatus) / sizeof(stanfordElementStatus[0]), + { ARRAY_SIZE(stanfordElementStatus), stanfordElementStatus }, }; static ChainCheck chainCheck[] = { @@ -3634,23 +3579,23 @@ static ChainCheck chainCheck[] = { * Windows 98/NT4 also set CERT_TRUST_IS_NOT_TIME_NESTED on chains they * shouldn't, so ignore those too. */ - { { sizeof(chain0) / sizeof(chain0[0]), chain0 }, + { { ARRAY_SIZE(chain0), chain0 }, { { CERT_TRUST_IS_NOT_TIME_NESTED, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_IS_NOT_TIME_VALID, 0 }, 1, simpleStatus0 }, 0, &oct2007 }, - { { sizeof(chain1) / sizeof(chain1[0]), chain1 }, + { { ARRAY_SIZE(chain1), chain1 }, { { CERT_TRUST_IS_NOT_TIME_NESTED, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_IS_NOT_SIGNATURE_VALID | CERT_TRUST_IS_NOT_TIME_VALID, 0 }, 1, simpleStatus1 }, 0, &oct2007 }, - { { sizeof(chain2) / sizeof(chain2[0]), chain2 }, + { { ARRAY_SIZE(chain2), chain2 }, { { CERT_TRUST_IS_NOT_TIME_NESTED, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_IS_NOT_TIME_VALID, 0 }, 1, simpleStatus2 }, 0, &oct2007 }, /* Earlier versions of Windows incorrectly don't set * CERT_TRUST_INVALID_BASIC_CONSTRAINTS on this chain. */ - { { sizeof(chain3) / sizeof(chain3[0]), chain3 }, + { { ARRAY_SIZE(chain3), chain3 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_INVALID_BASIC_CONSTRAINTS, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_INVALID_BASIC_CONSTRAINTS | CERT_TRUST_IS_UNTRUSTED_ROOT | @@ -3659,7 +3604,7 @@ static ChainCheck chainCheck[] = { /* Earlier versions of Windows incorrectly don't set * CERT_TRUST_INVALID_BASIC_CONSTRAINTS on this chain. */ - { { sizeof(chain4) / sizeof(chain4[0]), chain4 }, + { { ARRAY_SIZE(chain4), chain4 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_INVALID_BASIC_CONSTRAINTS, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_INVALID_BASIC_CONSTRAINTS | CERT_TRUST_IS_UNTRUSTED_ROOT | @@ -3670,22 +3615,22 @@ static ChainCheck chainCheck[] = { * Similarly, some older versions of Windows incorrectly set * CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, ignore that too. */ - { { sizeof(chain5) / sizeof(chain5[0]), chain5 }, + { { ARRAY_SIZE(chain5), chain5 }, { { CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT | CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT | CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, simpleStatus5 }, 0, &oct2007 }, - { { sizeof(chain6) / sizeof(chain6[0]), chain6 }, + { { ARRAY_SIZE(chain6), chain6 }, { { 0, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, simpleStatus6 }, 0, &oct2007 }, - { { sizeof(chain7) / sizeof(chain7[0]), chain7 }, + { { ARRAY_SIZE(chain7), chain7 }, { { 0, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, simpleStatus7 }, 0, &oct2007 }, /* Earlier versions of Windows incorrectly don't set * CERT_TRUST_INVALID_BASIC_CONSTRAINTS on this chain. */ - { { sizeof(chain8) / sizeof(chain8[0]), chain8 }, + { { ARRAY_SIZE(chain8), chain8 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_INVALID_BASIC_CONSTRAINTS, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_INVALID_BASIC_CONSTRAINTS | CERT_TRUST_IS_UNTRUSTED_ROOT | @@ -3694,50 +3639,50 @@ static ChainCheck chainCheck[] = { /* Earlier versions of Windows incorrectly don't set * CERT_TRUST_INVALID_BASIC_CONSTRAINTS on this chain. */ - { { sizeof(chain9) / sizeof(chain9[0]), chain9 }, + { { ARRAY_SIZE(chain9), chain9 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_INVALID_BASIC_CONSTRAINTS, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_PARTIAL_CHAIN | CERT_TRUST_INVALID_BASIC_CONSTRAINTS | CERT_TRUST_IS_CYCLIC, 0 }, 1, simpleStatus9 }, 0, &oct2007 }, - { { sizeof(chain10) / sizeof(chain10[0]), chain10 }, + { { ARRAY_SIZE(chain10), chain10 }, { { 0, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, simpleStatus10 }, 0, &oct2007 }, - { { sizeof(chain11) / sizeof(chain11[0]), chain11 }, + { { ARRAY_SIZE(chain11), chain11 }, { { 0, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, simpleStatus10 }, 0, &oct2007 }, - { { sizeof(chain12) / sizeof(chain12[0]), chain12 }, + { { ARRAY_SIZE(chain12), chain12 }, { { 0, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_IS_NOT_SIGNATURE_VALID, 0 }, 1, simpleStatus12 }, 0, &oct2007 }, - { { sizeof(chain13) / sizeof(chain13[0]), chain13 }, + { { ARRAY_SIZE(chain13), chain13 }, { { CERT_TRUST_IS_NOT_TIME_NESTED, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, simpleStatus13 }, 0, &oct2007 }, - { { sizeof(chain14) / sizeof(chain14[0]), chain14 }, + { { ARRAY_SIZE(chain14), chain14 }, { { CERT_TRUST_IS_NOT_TIME_NESTED, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, simpleStatus14 }, 0, &oct2007 }, /* Earlier versions of crypt32 incorrectly do not complain that the end cert's * key usage is invalid, so ignore that error. */ - { { sizeof(chain15) / sizeof(chain15[0]), chain15 }, + { { ARRAY_SIZE(chain15), chain15 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_IS_NOT_VALID_FOR_USAGE, 0 }, 1, simpleStatus15 }, 0, &oct2007 }, - { { sizeof(chain16) / sizeof(chain16[0]), chain16 }, + { { ARRAY_SIZE(chain16), chain16 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_IS_NOT_VALID_FOR_USAGE, 0 }, 1, simpleStatus16 }, 0, &oct2007 }, - { { sizeof(chain17) / sizeof(chain17[0]), chain17 }, + { { ARRAY_SIZE(chain17), chain17 }, { { CERT_TRUST_IS_NOT_TIME_NESTED, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, simpleStatus17 }, 0, &oct2007 }, - { { sizeof(chain18) / sizeof(chain18[0]), chain18 }, + { { ARRAY_SIZE(chain18), chain18 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_IS_NOT_VALID_FOR_USAGE, 0 }, @@ -3748,7 +3693,7 @@ static ChainCheck chainCheck[] = { * They also do not set CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS, since they * incorrectly find a name constraint error. */ - { { sizeof(chain19) / sizeof(chain19[0]), chain19 }, + { { ARRAY_SIZE(chain19), chain19 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE | CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT, CERT_TRUST_HAS_PREFERRED_ISSUER | CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS @@ -3760,7 +3705,7 @@ static ChainCheck chainCheck[] = { * CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, though they should. So * ignore it (on Windows) but require it (on Wine.) */ - { { sizeof(chain20) / sizeof(chain20[0]), chain20 }, + { { ARRAY_SIZE(chain20), chain20 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE | CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT | CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, @@ -3769,7 +3714,7 @@ static ChainCheck chainCheck[] = { CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, 0 }, 1, simpleStatus20 }, 0, &oct2007 }, - { { sizeof(chain21) / sizeof(chain21[0]), chain21 }, + { { ARRAY_SIZE(chain21), chain21 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE | CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT, CERT_TRUST_HAS_PREFERRED_ISSUER | CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS @@ -3777,7 +3722,7 @@ static ChainCheck chainCheck[] = { { CERT_TRUST_IS_UNTRUSTED_ROOT, CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS }, 1, simpleStatus21 }, 0, &oct2007 }, - { { sizeof(chain22) / sizeof(chain22[0]), chain22 }, + { { ARRAY_SIZE(chain22), chain22 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE | CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT | CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, @@ -3786,7 +3731,7 @@ static ChainCheck chainCheck[] = { CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, 0 }, 1, simpleStatus22 }, 0, &oct2007 }, - { { sizeof(chain23) / sizeof(chain23[0]), chain23 }, + { { ARRAY_SIZE(chain23), chain23 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE | CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT | CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, @@ -3795,7 +3740,7 @@ static ChainCheck chainCheck[] = { CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, 0 }, 1, simpleStatus23 }, 0, &oct2007 }, - { { sizeof(chain24) / sizeof(chain24[0]), chain24 }, + { { ARRAY_SIZE(chain24), chain24 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE | CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT | CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, @@ -3804,7 +3749,7 @@ static ChainCheck chainCheck[] = { CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, 0 }, 1, simpleStatus24 }, 0, &oct2007 }, - { { sizeof(chain25) / sizeof(chain25[0]), chain25 }, + { { ARRAY_SIZE(chain25), chain25 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE | CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT | CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, @@ -3813,7 +3758,7 @@ static ChainCheck chainCheck[] = { CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, 0 }, 1, simpleStatus25 }, 0, &oct2007 }, - { { sizeof(chain26) / sizeof(chain26[0]), chain26 }, + { { ARRAY_SIZE(chain26), chain26 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE | CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT | CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, @@ -3823,7 +3768,7 @@ static ChainCheck chainCheck[] = { 1, simpleStatus26 }, 0, &oct2007 }, /* chain27 is handled separately elsewhere */ - { { sizeof(chain28) / sizeof(chain28[0]), chain28 }, + { { ARRAY_SIZE(chain28), chain28 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE | CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT | CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT, @@ -3836,7 +3781,7 @@ static ChainCheck chainCheck[] = { /* Microsoft incorrectly ignores unknown/unsupported critical extensions on * older Windows versions, so ignore the error on Windows. */ - { { sizeof(chain30) / sizeof(chain30[0]), chain30 }, + { { ARRAY_SIZE(chain30), chain30 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE | CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT | CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT | @@ -3847,7 +3792,7 @@ static ChainCheck chainCheck[] = { CERT_TRUST_HAS_NOT_SUPPORTED_CRITICAL_EXT, 0 }, 1, simpleStatus30 }, 0, &oct2007 }, - { { sizeof(selfSignedChain) / sizeof(selfSignedChain[0]), selfSignedChain }, + { { ARRAY_SIZE(selfSignedChain), selfSignedChain }, { { 0, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_NOT_TIME_VALID | CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, selfSignedSimpleStatus }, 0, &oct2007 }, @@ -3858,14 +3803,14 @@ static ChainCheck chainCheck[] = { * e.g. has always CERT_TRUST_HAS_NAME_MATCH_ISSUER flag * @see CRYPT_CheckSimpleChain */ - { { sizeof(googleChain) / sizeof(googleChain[0]), googleChain }, + { { ARRAY_SIZE(googleChain), googleChain }, { { CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_IS_NOT_TIME_NESTED, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_NOT_TIME_VALID, 0 }, 1, googleSimpleStatus }, TODO_INFO, &oct2016 }, /* The stanford chain may or may not have its root trusted, so ignore the error */ - { { sizeof(stanfordChain) / sizeof(stanfordChain[0]), stanfordChain }, + { { ARRAY_SIZE(stanfordChain), stanfordChain }, { { CERT_TRUST_IS_UNTRUSTED_ROOT, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_NOT_TIME_VALID, 0 }, 1, stanfordSimpleStatus }, 0, &oct2016 }, @@ -3875,16 +3820,16 @@ static const CERT_TRUST_STATUS elementStatus8NoStore[] = { { CERT_TRUST_NO_ERROR, CERT_TRUST_HAS_NAME_MATCH_ISSUER }, }; static const SimpleChainStatusCheck simpleStatus8NoStore[] = { - { sizeof(elementStatus8NoStore) / sizeof(elementStatus8NoStore[0]), + { ARRAY_SIZE(elementStatus8NoStore), elementStatus8NoStore }, }; static ChainCheck chainCheckNoStore[] = { - { { sizeof(selfSignedChain) / sizeof(selfSignedChain[0]), selfSignedChain }, + { { ARRAY_SIZE(selfSignedChain), selfSignedChain }, { { 0, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_NOT_TIME_VALID | CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, 1, selfSignedSimpleStatus }, 0 }, - { { sizeof(chain8) / sizeof(chain8[0]), chain8 }, + { { ARRAY_SIZE(chain8), chain8 }, { { 0, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_PARTIAL_CHAIN, 0 }, 1, simpleStatus8NoStore }, @@ -3894,12 +3839,12 @@ static ChainCheck chainCheckNoStore[] = { /* The openssl chain may or may not have its root trusted, so ignore the error */ static ChainCheck opensslChainCheck = - { { sizeof(opensslChain) / sizeof(opensslChain[0]), opensslChain }, + { { ARRAY_SIZE(opensslChain), opensslChain }, { { CERT_TRUST_IS_UNTRUSTED_ROOT, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_NOT_TIME_VALID, 0 }, 1, opensslSimpleStatus }, 0 }; static ChainCheck incompleteOpensslChainCheck = - { { sizeof(incompleteOpensslChain) / sizeof(incompleteOpensslChain[0]), + { { ARRAY_SIZE(incompleteOpensslChain), incompleteOpensslChain }, { { CERT_TRUST_IS_UNTRUSTED_ROOT, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_NOT_TIME_VALID | CERT_TRUST_IS_PARTIAL_CHAIN, 0 }, @@ -3912,7 +3857,7 @@ static ChainCheck incompleteOpensslChainCheck = * on the chain's error status. */ static ChainCheck chainCheckEmbeddedNull = { - { sizeof(chain27) / sizeof(chain27[0]), chain27 }, + { ARRAY_SIZE(chain27), chain27 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE, CERT_TRUST_HAS_PREFERRED_ISSUER }, { CERT_TRUST_IS_UNTRUSTED_ROOT | CERT_TRUST_INVALID_NAME_CONSTRAINTS | @@ -3920,7 +3865,7 @@ static ChainCheck chainCheckEmbeddedNull = { 1, simpleStatus27 }, 0 }; static ChainCheck chainCheckEmbeddedNullBroken = { - { sizeof(chain27) / sizeof(chain27[0]), chain27 }, + { ARRAY_SIZE(chain27), chain27 }, { { CERT_TRUST_IS_NOT_TIME_NESTED | CERT_TRUST_IS_NOT_VALID_FOR_USAGE | CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT, CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS | CERT_TRUST_HAS_PREFERRED_ISSUER }, @@ -3928,25 +3873,6 @@ static ChainCheck chainCheckEmbeddedNullBroken = { CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS }, 1, simpleStatus27Broken }, 0 }; -static CONST_DATA_BLOB chainECDSA[] = { - { sizeof(ecc_ca), ecc_ca }, - { sizeof(ecc_crt), ecc_crt }, -}; -static const CERT_TRUST_STATUS elementStatusECDSA[] = { - { CERT_TRUST_NO_ERROR, CERT_TRUST_HAS_NAME_MATCH_ISSUER }, - { CERT_TRUST_IS_UNTRUSTED_ROOT, CERT_TRUST_HAS_KEY_MATCH_ISSUER | CERT_TRUST_IS_SELF_SIGNED }, -}; -static const SimpleChainStatusCheck simpleStatusECDSA[] = { - { sizeof(elementStatusECDSA) / sizeof(elementStatusECDSA[0]), elementStatusECDSA }, -}; -static ChainCheck chainCheckECDSA = { - { sizeof(chainECDSA) / sizeof(chainECDSA[0]), chainECDSA }, - { - { CERT_TRUST_IS_UNTRUSTED_ROOT, CERT_TRUST_HAS_PREFERRED_ISSUER }, - { CERT_TRUST_IS_UNTRUSTED_ROOT, 0 }, - 1, simpleStatusECDSA - }, 0 -}; #define test_name_blob(a,b) _test_name_blob(__LINE__,a,b) static void _test_name_blob(unsigned line, CERT_NAME_BLOB *blob, const char *exdata) @@ -4091,7 +4017,7 @@ static void testGetCertChain(void) CertCloseStore(store, 0); CertFreeCertificateContext(cert); - for (i = 0; i < sizeof(chainCheck) / sizeof(chainCheck[0]); i++) + for (i = 0; i < ARRAY_SIZE(chainCheck); i++) { chain = getChain(NULL, &chainCheck[i].certs, 0, TRUE, chainCheck[i].validfor, chainCheck[i].todo, i); @@ -4124,8 +4050,7 @@ static void testGetCertChain(void) 0); pCertFreeCertificateChain(chain); } - for (i = 0; i < sizeof(chainCheckNoStore) / sizeof(chainCheckNoStore[0]); - i++) + for (i = 0; i < ARRAY_SIZE(chainCheckNoStore); i++) { chain = getChain(NULL, &chainCheckNoStore[i].certs, 0, FALSE, &oct2007, chainCheckNoStore[i].todo, i); @@ -4222,15 +4147,25 @@ static void testGetCertChain(void) pCertFreeCertificateChain(chain); - /* Test with ECDSA certificate */ - chain = getChain(NULL, &chainCheckECDSA.certs, 0, TRUE, &nov2017, FALSE, 0); - if (chain) - { - ok(chain->TrustStatus.dwErrorStatus == CERT_TRUST_IS_UNTRUSTED_ROOT, - "unexpected chain error status %08x\n", chain->TrustStatus.dwErrorStatus); - checkChainStatus(chain, &chainCheckECDSA.status, chainCheckECDSA.todo, "chainCheckECDSA", 0); - pCertFreeCertificateChain(chain); - } + /* Test revocation flags */ + ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, CERT_CHAIN_REVOCATION_CHECK_END_CERT, NULL, + &chain); + ok(ret, "CertGetCertificateChain failed: %u\n", GetLastError()); + ok(!chain->TrustStatus.dwErrorStatus, "chain->TrustStatus.dwErrorStatus = %x\n", chain->TrustStatus.dwErrorStatus); + pCertFreeCertificateChain(chain); + + ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, CERT_CHAIN_REVOCATION_CHECK_CHAIN, NULL, &chain); + ok(ret, "CertGetCertificateChain failed: %u\n", GetLastError()); + ok(!chain->TrustStatus.dwErrorStatus + || broken(chain->TrustStatus.dwErrorStatus == CERT_TRUST_REVOCATION_STATUS_UNKNOWN), /* XP */ + "chain->TrustStatus.dwErrorStatus = %x\n", chain->TrustStatus.dwErrorStatus); + pCertFreeCertificateChain(chain); + + ret = CertGetCertificateChain(NULL, cert, &fileTime, store, ¶, CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT, + NULL, &chain); + ok(ret, "CertGetCertificateChain failed: %u\n", GetLastError()); + ok(!chain->TrustStatus.dwErrorStatus, "chain->TrustStatus.dwErrorStatus = %x\n", chain->TrustStatus.dwErrorStatus); + pCertFreeCertificateChain(chain); /* Test HCCE_LOCAL_MACHINE */ ret = CertGetCertificateChain(HCCE_LOCAL_MACHINE, cert, &fileTime, store, ¶, 0, NULL, &chain); @@ -4288,45 +4223,45 @@ typedef struct _ChainPolicyCheck } ChainPolicyCheck; static const ChainPolicyCheck basePolicyCheck[] = { - { { sizeof(chain0) / sizeof(chain0[0]), chain0 }, + { { ARRAY_SIZE(chain0), chain0 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain1) / sizeof(chain1[0]), chain1 }, + { { ARRAY_SIZE(chain1), chain1 }, { 0, TRUST_E_CERT_SIGNATURE, 0, 0, NULL }, NULL, 0 }, - { { sizeof(chain2) / sizeof(chain2[0]), chain2 }, + { { ARRAY_SIZE(chain2), chain2 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain3) / sizeof(chain3[0]), chain3 }, + { { ARRAY_SIZE(chain3), chain3 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain4) / sizeof(chain4[0]), chain4 }, + { { ARRAY_SIZE(chain4), chain4 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 }, - { { sizeof(chain5) / sizeof(chain5[0]), chain5 }, + { { ARRAY_SIZE(chain5), chain5 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain6) / sizeof(chain6[0]), chain6 }, + { { ARRAY_SIZE(chain6), chain6 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain7) / sizeof(chain7[0]), chain7 }, + { { ARRAY_SIZE(chain7), chain7 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain8) / sizeof(chain8[0]), chain8 }, + { { ARRAY_SIZE(chain8), chain8 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 }, - { { sizeof(chain9) / sizeof(chain9[0]), chain9 }, + { { ARRAY_SIZE(chain9), chain9 }, { 0, CERT_E_CHAINING, 0, -1, NULL }, NULL, 0 }, - { { sizeof(chain10) / sizeof(chain10[0]), chain10 }, + { { ARRAY_SIZE(chain10), chain10 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain11) / sizeof(chain11[0]), chain11 }, + { { ARRAY_SIZE(chain11), chain11 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain12) / sizeof(chain12[0]), chain12 }, + { { ARRAY_SIZE(chain12), chain12 }, { 0, TRUST_E_CERT_SIGNATURE, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain13) / sizeof(chain13[0]), chain13 }, + { { ARRAY_SIZE(chain13), chain13 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain14) / sizeof(chain14[0]), chain14 }, + { { ARRAY_SIZE(chain14), chain14 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain15) / sizeof(chain15[0]), chain15 }, + { { ARRAY_SIZE(chain15), chain15 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain16) / sizeof(chain16[0]), chain16 }, + { { ARRAY_SIZE(chain16), chain16 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain17) / sizeof(chain17[0]), chain17 }, + { { ARRAY_SIZE(chain17), chain17 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 }, - { { sizeof(chain18) / sizeof(chain18[0]), chain18 }, + { { ARRAY_SIZE(chain18), chain18 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 }, - { { sizeof(selfSignedChain) / sizeof(selfSignedChain[0]), selfSignedChain }, + { { ARRAY_SIZE(selfSignedChain), selfSignedChain }, { 0, CERT_E_UNTRUSTEDROOT, 0, 0, NULL }, NULL, 0 }, }; @@ -4338,75 +4273,75 @@ static const CERT_CHAIN_POLICY_STATUS badDateNestingStatus = { 0, CERT_E_VALIDITYPERIODNESTING, 0, 0, NULL }; static const ChainPolicyCheck ignoredBadDateNestingBasePolicyCheck = { - { sizeof(chain2) / sizeof(chain2[0]), chain2 }, + { ARRAY_SIZE(chain2), chain2 }, { 0, CERT_E_EXPIRED, 0, 1, NULL}, &badDateNestingStatus, TODO_ELEMENTS }; static const ChainPolicyCheck ignoredInvalidDateBasePolicyCheck = { - { sizeof(googleChain) / sizeof(googleChain[0]), googleChain }, + { ARRAY_SIZE(googleChain), googleChain }, { 0, CERT_E_EXPIRED, 0, 1, NULL}, &badDateNestingStatus, TODO_ELEMENTS }; static const ChainPolicyCheck ignoredInvalidUsageBasePolicyCheck = { - { sizeof(chain15) / sizeof(chain15[0]), chain15 }, + { ARRAY_SIZE(chain15), chain15 }, { 0, CERT_E_EXPIRED, 0, 1, NULL}, NULL, TODO_ERROR }; static const ChainPolicyCheck invalidUsageBasePolicyCheck = { - { sizeof(chain15) / sizeof(chain15[0]), chain15 }, + { ARRAY_SIZE(chain15), chain15 }, { 0, CERT_E_WRONG_USAGE, 0, 1, NULL}, NULL, 0 }; static const ChainPolicyCheck sslPolicyCheck[] = { - { { sizeof(chain0) / sizeof(chain0[0]), chain0 }, + { { ARRAY_SIZE(chain0), chain0 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain1) / sizeof(chain1[0]), chain1 }, + { { ARRAY_SIZE(chain1), chain1 }, { 0, TRUST_E_CERT_SIGNATURE, 0, 0, NULL }, NULL, 0 }, - { { sizeof(chain2) / sizeof(chain2[0]), chain2 }, + { { ARRAY_SIZE(chain2), chain2 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain3) / sizeof(chain3[0]), chain3 }, + { { ARRAY_SIZE(chain3), chain3 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain4) / sizeof(chain4[0]), chain4 }, + { { ARRAY_SIZE(chain4), chain4 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 }, - { { sizeof(chain5) / sizeof(chain5[0]), chain5 }, + { { ARRAY_SIZE(chain5), chain5 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain6) / sizeof(chain6[0]), chain6 }, + { { ARRAY_SIZE(chain6), chain6 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain7) / sizeof(chain7[0]), chain7 }, + { { ARRAY_SIZE(chain7), chain7 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain8) / sizeof(chain8[0]), chain8 }, + { { ARRAY_SIZE(chain8), chain8 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 }, - { { sizeof(chain9) / sizeof(chain9[0]), chain9 }, + { { ARRAY_SIZE(chain9), chain9 }, { 0, CERT_E_UNTRUSTEDROOT, 0, -1, NULL }, NULL, 0 }, - { { sizeof(chain10) / sizeof(chain10[0]), chain10 }, + { { ARRAY_SIZE(chain10), chain10 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain11) / sizeof(chain11[0]), chain11 }, + { { ARRAY_SIZE(chain11), chain11 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain12) / sizeof(chain12[0]), chain12 }, + { { ARRAY_SIZE(chain12), chain12 }, { 0, TRUST_E_CERT_SIGNATURE, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain13) / sizeof(chain13[0]), chain13 }, + { { ARRAY_SIZE(chain13), chain13 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain14) / sizeof(chain14[0]), chain14 }, + { { ARRAY_SIZE(chain14), chain14 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain15) / sizeof(chain15[0]), chain15 }, + { { ARRAY_SIZE(chain15), chain15 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain16) / sizeof(chain16[0]), chain16 }, + { { ARRAY_SIZE(chain16), chain16 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain17) / sizeof(chain17[0]), chain17 }, + { { ARRAY_SIZE(chain17), chain17 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 }, - { { sizeof(chain18) / sizeof(chain18[0]), chain18 }, + { { ARRAY_SIZE(chain18), chain18 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 }, - { { sizeof(selfSignedChain) / sizeof(selfSignedChain[0]), selfSignedChain }, + { { ARRAY_SIZE(selfSignedChain), selfSignedChain }, { 0, CERT_E_UNTRUSTEDROOT, 0, 0, NULL }, NULL, 0 }, }; static const ChainPolicyCheck ignoredUnknownCAPolicyCheck = { - { sizeof(chain0) / sizeof(chain0[0]), chain0 }, + { ARRAY_SIZE(chain0), chain0 }, { 0, CERT_E_EXPIRED, 0, 0, NULL }, NULL, 0 }; static const ChainPolicyCheck googlePolicyCheckWithMatchingNameExpired = { - { sizeof(googleChain) / sizeof(googleChain[0]), googleChain }, + { ARRAY_SIZE(googleChain), googleChain }, { 0, CERT_E_EXPIRED, 0, 0, NULL}, NULL, 0 }; @@ -4415,7 +4350,7 @@ static const CERT_CHAIN_POLICY_STATUS expiredStatus = { 0, CERT_E_EXPIRED, 0, 0, NULL }; static const ChainPolicyCheck googlePolicyCheckWithMatchingName = { - { sizeof(googleChain) / sizeof(googleChain[0]), googleChain }, + { ARRAY_SIZE(googleChain), googleChain }, { 0, 0, -1, -1, NULL}, &expiredStatus, 0 }; @@ -4424,95 +4359,95 @@ static const CERT_CHAIN_POLICY_STATUS untrustedRootStatus = { 0, CERT_E_UNTRUSTEDROOT, 0, 0, NULL }; static const ChainPolicyCheck opensslPolicyCheckWithMatchingName = { - { sizeof(opensslChain) / sizeof(opensslChain[0]), opensslChain }, + { ARRAY_SIZE(opensslChain), opensslChain }, { 0, 0, -1, -1, NULL}, &untrustedRootStatus, 0 }; static const ChainPolicyCheck opensslPolicyCheckWithoutMatchingName = { - { sizeof(opensslChain) / sizeof(opensslChain[0]), opensslChain }, + { ARRAY_SIZE(opensslChain), opensslChain }, { 0, CERT_E_CN_NO_MATCH, 0, 0, NULL}, &untrustedRootStatus, 0 }; static const ChainPolicyCheck winehqPolicyCheckWithMatchingName = { - { sizeof(chain29) / sizeof(chain29[0]), chain29 }, + { ARRAY_SIZE(chain29), chain29 }, { 0, 0, -1, -1, NULL}, NULL, 0 }; static const ChainPolicyCheck winehqPolicyCheckWithoutMatchingName = { - { sizeof(chain29) / sizeof(chain29[0]), chain29 }, + { ARRAY_SIZE(chain29), chain29 }, { 0, CERT_E_CN_NO_MATCH, 0, 0, NULL}, NULL, 0 }; static const ChainPolicyCheck stanfordPolicyCheckWithMatchingName = { - { sizeof(stanfordChain) / sizeof(stanfordChain[0]), stanfordChain }, + { ARRAY_SIZE(stanfordChain), stanfordChain }, { 0, 0, -1, -1, NULL}, &untrustedRootStatus, 0 }; static const ChainPolicyCheck stanfordPolicyCheckWithoutMatchingName = { - { sizeof(stanfordChain) / sizeof(stanfordChain[0]), stanfordChain }, + { ARRAY_SIZE(stanfordChain), stanfordChain }, { 0, CERT_E_CN_NO_MATCH, 0, 0, NULL}, &untrustedRootStatus, 0 }; static const ChainPolicyCheck nullTerminatedDomainComponentPolicyCheck = { - { sizeof(battlenetChain) / sizeof(battlenetChain[0]), battlenetChain }, + { ARRAY_SIZE(battlenetChain), battlenetChain }, { 0, 0, -1, -1, NULL}, &untrustedRootStatus, 0 }; static const ChainPolicyCheck invalidExtensionPolicyCheck = { - { sizeof(chain30) / sizeof(chain30[0]), chain30 }, + { ARRAY_SIZE(chain30), chain30 }, { 0, CERT_E_CRITICAL, 0, 1, NULL}, &badDateNestingStatus, 0 }; static const ChainPolicyCheck fooPolicyCheckWithMatchingName = { - { sizeof(chain31) / sizeof(chain31[0]), chain31 }, + { ARRAY_SIZE(chain31), chain31 }, { 0, 0, -1, -1, NULL}, NULL, 0 }; static const ChainPolicyCheck fooPolicyCheckWithoutMatchingName = { - { sizeof(chain31) / sizeof(chain31[0]), chain31 }, + { ARRAY_SIZE(chain31), chain31 }, { 0, CERT_E_CN_NO_MATCH, 0, 0, NULL}, NULL, 0 }; static const ChainPolicyCheck authenticodePolicyCheck[] = { - { { sizeof(chain0) / sizeof(chain0[0]), chain0 }, + { { ARRAY_SIZE(chain0), chain0 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain1) / sizeof(chain1[0]), chain1 }, + { { ARRAY_SIZE(chain1), chain1 }, { 0, TRUST_E_CERT_SIGNATURE, 0, 0, NULL }, NULL, 0 }, - { { sizeof(chain2) / sizeof(chain2[0]), chain2 }, + { { ARRAY_SIZE(chain2), chain2 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain3) / sizeof(chain3[0]), chain3 }, + { { ARRAY_SIZE(chain3), chain3 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain4) / sizeof(chain4[0]), chain4 }, + { { ARRAY_SIZE(chain4), chain4 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 }, - { { sizeof(chain5) / sizeof(chain5[0]), chain5 }, + { { ARRAY_SIZE(chain5), chain5 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain6) / sizeof(chain6[0]), chain6 }, + { { ARRAY_SIZE(chain6), chain6 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain7) / sizeof(chain7[0]), chain7 }, + { { ARRAY_SIZE(chain7), chain7 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain8) / sizeof(chain8[0]), chain8 }, + { { ARRAY_SIZE(chain8), chain8 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 }, - { { sizeof(chain9) / sizeof(chain9[0]), chain9 }, + { { ARRAY_SIZE(chain9), chain9 }, { 0, CERT_E_CHAINING, 0, -1, NULL }, NULL, 0 }, - { { sizeof(chain10) / sizeof(chain10[0]), chain10 }, + { { ARRAY_SIZE(chain10), chain10 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain11) / sizeof(chain11[0]), chain11 }, + { { ARRAY_SIZE(chain11), chain11 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain12) / sizeof(chain12[0]), chain12 }, + { { ARRAY_SIZE(chain12), chain12 }, { 0, TRUST_E_CERT_SIGNATURE, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain13) / sizeof(chain13[0]), chain13 }, + { { ARRAY_SIZE(chain13), chain13 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain14) / sizeof(chain14[0]), chain14 }, + { { ARRAY_SIZE(chain14), chain14 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain15) / sizeof(chain15[0]), chain15 }, + { { ARRAY_SIZE(chain15), chain15 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain16) / sizeof(chain16[0]), chain16 }, + { { ARRAY_SIZE(chain16), chain16 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain17) / sizeof(chain17[0]), chain17 }, + { { ARRAY_SIZE(chain17), chain17 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 }, - { { sizeof(chain18) / sizeof(chain18[0]), chain18 }, + { { ARRAY_SIZE(chain18), chain18 }, { 0, CERT_E_UNTRUSTEDROOT, 0, 2, NULL }, NULL, 0 }, - { { sizeof(selfSignedChain) / sizeof(selfSignedChain[0]), selfSignedChain }, + { { ARRAY_SIZE(selfSignedChain), selfSignedChain }, { 0, CERT_E_UNTRUSTEDROOT, 0, 0, NULL }, NULL, 0 }, }; @@ -4524,45 +4459,45 @@ static const CERT_CHAIN_POLICY_STATUS chain4BrokenStatus = { 0, TRUST_E_BASIC_CONSTRAINTS, 0, 2, NULL }; static const ChainPolicyCheck basicConstraintsPolicyCheck[] = { - { { sizeof(chain0) / sizeof(chain0[0]), chain0 }, + { { ARRAY_SIZE(chain0), chain0 }, { 0, 0, -1, -1, NULL }, NULL, 0 }, - { { sizeof(chain1) / sizeof(chain1[0]), chain1 }, + { { ARRAY_SIZE(chain1), chain1 }, { 0, 0, -1, -1, NULL }, NULL, 0 }, - { { sizeof(chain2) / sizeof(chain2[0]), chain2 }, + { { ARRAY_SIZE(chain2), chain2 }, { 0, 0, -1, -1, NULL }, NULL, 0 }, - { { sizeof(chain3) / sizeof(chain3[0]), chain3 }, + { { ARRAY_SIZE(chain3), chain3 }, { 0, TRUST_E_BASIC_CONSTRAINTS, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain4) / sizeof(chain4[0]), chain4 }, + { { ARRAY_SIZE(chain4), chain4 }, { 0, TRUST_E_BASIC_CONSTRAINTS, 0, 1, NULL }, &chain4BrokenStatus, 0 }, - { { sizeof(chain5) / sizeof(chain5[0]), chain5 }, + { { ARRAY_SIZE(chain5), chain5 }, { 0, 0, -1, -1, NULL }, NULL, 0 }, - { { sizeof(chain6) / sizeof(chain6[0]), chain6 }, + { { ARRAY_SIZE(chain6), chain6 }, { 0, 0, -1, -1, NULL }, NULL, 0 }, - { { sizeof(chain7) / sizeof(chain7[0]), chain7 }, + { { ARRAY_SIZE(chain7), chain7 }, { 0, 0, -1, -1, NULL }, NULL, 0 }, - { { sizeof(chain8) / sizeof(chain8[0]), chain8 }, + { { ARRAY_SIZE(chain8), chain8 }, { 0, TRUST_E_BASIC_CONSTRAINTS, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain9) / sizeof(chain9[0]), chain9 }, + { { ARRAY_SIZE(chain9), chain9 }, { 0, TRUST_E_BASIC_CONSTRAINTS, 0, 1, NULL }, NULL, 0 }, - { { sizeof(chain10) / sizeof(chain10[0]), chain10 }, + { { ARRAY_SIZE(chain10), chain10 }, { 0, 0, -1, -1, NULL }, NULL, 0 }, - { { sizeof(chain11) / sizeof(chain11[0]), chain11 }, + { { ARRAY_SIZE(chain11), chain11 }, { 0, 0, -1, -1, NULL }, NULL, 0 }, - { { sizeof(chain12) / sizeof(chain12[0]), chain12 }, + { { ARRAY_SIZE(chain12), chain12 }, { 0, 0, -1, -1, NULL }, NULL, 0 }, - { { sizeof(chain13) / sizeof(chain13[0]), chain13 }, + { { ARRAY_SIZE(chain13), chain13 }, { 0, 0, -1, -1, NULL }, NULL, 0 }, - { { sizeof(chain14) / sizeof(chain14[0]), chain14 }, + { { ARRAY_SIZE(chain14), chain14 }, { 0, 0, -1, -1, NULL }, NULL, 0 }, - { { sizeof(chain15) / sizeof(chain15[0]), chain15 }, + { { ARRAY_SIZE(chain15), chain15 }, { 0, 0, -1, -1, NULL }, NULL, 0 }, - { { sizeof(chain16) / sizeof(chain16[0]), chain16 }, + { { ARRAY_SIZE(chain16), chain16 }, { 0, 0, -1, -1, NULL }, NULL, 0 }, - { { sizeof(chain17) / sizeof(chain17[0]), chain17 }, + { { ARRAY_SIZE(chain17), chain17 }, { 0, 0, -1, -1, NULL }, NULL, 0 }, - { { sizeof(chain18) / sizeof(chain18[0]), chain18 }, + { { ARRAY_SIZE(chain18), chain18 }, { 0, 0, -1, -1, NULL }, NULL, 0 }, - { { sizeof(selfSignedChain) / sizeof(selfSignedChain[0]), selfSignedChain }, + { { ARRAY_SIZE(selfSignedChain), selfSignedChain }, { 0, 0, -1, -1, NULL }, NULL, 0 }, }; @@ -4652,7 +4587,7 @@ static void checkChainPolicyStatus(LPCSTR policy, HCERTCHAINENGINE engine, #define CHECK_CHAIN_POLICY_STATUS_ARRAY(policy, engine, array, date, para) \ do { \ DWORD i; \ - for (i = 0; i < sizeof(array) / sizeof(array)[0]; i++) \ + for (i = 0; i < ARRAY_SIZE(array); i++) \ checkChainPolicyStatus((policy), (engine), &(array)[i], \ #array, i, (date), (para)); \ } while(0) diff --git a/modules/rostests/winetests/crypt32/encode.c b/modules/rostests/winetests/crypt32/encode.c index ad39a35606..4a6626ab00 100644 --- a/modules/rostests/winetests/crypt32/encode.c +++ b/modules/rostests/winetests/crypt32/encode.c @@ -113,7 +113,7 @@ static void test_encodeInt(DWORD dwEncoding) ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", GetLastError()); } - for (i = 0; i < sizeof(ints) / sizeof(ints[0]); i++) + for (i = 0; i < ARRAY_SIZE(ints); i++) { /* encode as normal integer */ ret = pCryptEncodeObjectEx(dwEncoding, X509_INTEGER, &ints[i].val, 0, @@ -155,7 +155,7 @@ static void test_encodeInt(DWORD dwEncoding) /* encode a couple bigger ints, just to show it's little-endian and leading * sign bytes are dropped */ - for (i = 0; i < sizeof(bigInts) / sizeof(bigInts[0]); i++) + for (i = 0; i < ARRAY_SIZE(bigInts); i++) { blob.cbData = strlen((const char*)bigInts[i].val); blob.pbData = (BYTE *)bigInts[i].val; @@ -178,7 +178,7 @@ static void test_encodeInt(DWORD dwEncoding) } } /* and, encode some uints */ - for (i = 0; i < sizeof(bigUInts) / sizeof(bigUInts[0]); i++) + for (i = 0; i < ARRAY_SIZE(bigUInts); i++) { blob.cbData = strlen((const char*)bigUInts[i].val); blob.pbData = (BYTE*)bigUInts[i].val; @@ -242,7 +242,7 @@ static void test_decodeInt(DWORD dwEncoding) GetLastError() == OSS_PDU_MISMATCH /* Win9x */ ), "Expected CRYPT_E_ASN1_BADTAG or OSS_PDU_MISMATCH, got %08x\n", GetLastError()); - for (i = 0; i < sizeof(ints) / sizeof(ints[0]); i++) + for (i = 0; i < ARRAY_SIZE(ints); i++) { /* When the output buffer is NULL, this always succeeds */ SetLastError(0xdeadbeef); @@ -264,7 +264,7 @@ static void test_decodeInt(DWORD dwEncoding) LocalFree(buf); } } - for (i = 0; i < sizeof(bigInts) / sizeof(bigInts[0]); i++) + for (i = 0; i < ARRAY_SIZE(bigInts); i++) { ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_INTEGER, bigInts[i].encoded, bigInts[i].encoded[1] + 2, 0, NULL, NULL, @@ -289,7 +289,7 @@ static void test_decodeInt(DWORD dwEncoding) LocalFree(buf); } } - for (i = 0; i < sizeof(bigUInts) / sizeof(bigUInts[0]); i++) + for (i = 0; i < ARRAY_SIZE(bigUInts); i++) { ret = pCryptDecodeObjectEx(dwEncoding, X509_MULTI_BYTE_UINT, bigUInts[i].encoded, bigUInts[i].encoded[1] + 2, 0, NULL, NULL, @@ -377,9 +377,9 @@ static void test_encodeEnumerated(DWORD dwEncoding) { DWORD i, j; - for (i = 0; i < sizeof(enumeratedTypes) / sizeof(enumeratedTypes[0]); i++) + for (i = 0; i < ARRAY_SIZE(enumeratedTypes); i++) { - for (j = 0; j < sizeof(enums) / sizeof(enums[0]); j++) + for (j = 0; j < ARRAY_SIZE(enums); j++) { BOOL ret; BYTE *buf = NULL; @@ -410,9 +410,9 @@ static void test_decodeEnumerated(DWORD dwEncoding) { DWORD i, j; - for (i = 0; i < sizeof(enumeratedTypes) / sizeof(enumeratedTypes[0]); i++) + for (i = 0; i < ARRAY_SIZE(enumeratedTypes); i++) { - for (j = 0; j < sizeof(enums) / sizeof(enums[0]); j++) + for (j = 0; j < ARRAY_SIZE(enums); j++) { BOOL ret; DWORD bufSize = sizeof(int); @@ -563,7 +563,7 @@ static void test_encodeFiletime(DWORD dwEncoding) { DWORD i; - for (i = 0; i < sizeof(times) / sizeof(times[0]); i++) + for (i = 0; i < ARRAY_SIZE(times); i++) { testTimeEncoding(dwEncoding, X509_CHOICE_OF_TIME, ×[i]); testTimeEncoding(dwEncoding, PKCS_UTC_TIME, ×[i]); @@ -645,19 +645,19 @@ static void test_decodeFiletime(DWORD dwEncoding) ok(!ret && GetLastError() == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", GetLastError()); /* Normal tests */ - for (i = 0; i < sizeof(times) / sizeof(times[0]); i++) + for (i = 0; i < ARRAY_SIZE(times); i++) { testTimeDecoding(dwEncoding, X509_CHOICE_OF_TIME, ×[i]); testTimeDecoding(dwEncoding, PKCS_UTC_TIME, ×[i]); testTimeDecoding(dwEncoding, szOID_RSA_signingTime, ×[i]); } - for (i = 0; i < sizeof(otherTimes) / sizeof(otherTimes[0]); i++) + for (i = 0; i < ARRAY_SIZE(otherTimes); i++) { testTimeDecoding(dwEncoding, X509_CHOICE_OF_TIME, &otherTimes[i]); testTimeDecoding(dwEncoding, PKCS_UTC_TIME, &otherTimes[i]); testTimeDecoding(dwEncoding, szOID_RSA_signingTime, &otherTimes[i]); } - for (i = 0; i < sizeof(bogusTimes) / sizeof(bogusTimes[0]); i++) + for (i = 0; i < ARRAY_SIZE(bogusTimes); i++) { size = sizeof(ft1); ret = pCryptDecodeObjectEx(dwEncoding, X509_CHOICE_OF_TIME, @@ -861,7 +861,7 @@ static void test_encodeName(DWORD dwEncoding) ok(!ret && GetLastError() == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", GetLastError()); /* Test a more complex name */ - rdn.cRDNAttr = sizeof(rdnAttrs) / sizeof(rdnAttrs[0]); + rdn.cRDNAttr = ARRAY_SIZE(rdnAttrs); rdn.rgRDNAttr = rdnAttrs; info.cRDN = 1; info.rgRDN = &rdn; @@ -1139,7 +1139,7 @@ static void test_decodeName(DWORD dwEncoding) (BYTE *)commonName } }, }; - rdn.cRDNAttr = sizeof(attrs) / sizeof(attrs[0]); + rdn.cRDNAttr = ARRAY_SIZE(attrs); rdn.rgRDNAttr = attrs; compareNames(&info, (CERT_NAME_INFO *)buf); LocalFree(buf); @@ -1157,7 +1157,7 @@ static void test_decodeName(DWORD dwEncoding) ok(ret, "CryptDecodeObjectEx failed: %08x\n", GetLastError()); if (ret) { - rdn.cRDNAttr = sizeof(decodedRdnAttrs) / sizeof(decodedRdnAttrs[0]); + rdn.cRDNAttr = ARRAY_SIZE(decodedRdnAttrs); rdn.rgRDNAttr = decodedRdnAttrs; compareNames(&info, (CERT_NAME_INFO *)buf); LocalFree(buf); @@ -1223,7 +1223,7 @@ static void test_decodeUnicodeName(DWORD dwEncoding) { lstrlenW(commonNameW) * sizeof(WCHAR), (BYTE *)commonNameW } }, }; - rdn.cRDNAttr = sizeof(attrs) / sizeof(attrs[0]); + rdn.cRDNAttr = ARRAY_SIZE(attrs); rdn.rgRDNAttr = attrs; compareNames(&info, (CERT_NAME_INFO *)buf); LocalFree(buf); @@ -1332,7 +1332,7 @@ static void test_encodeNameValue(DWORD dwEncoding) "Unexpected encoding\n"); LocalFree(buf); } - for (i = 0; i < sizeof(nameValues) / sizeof(nameValues[0]); i++) + for (i = 0; i < ARRAY_SIZE(nameValues); i++) { ret = pCryptEncodeObjectEx(dwEncoding, X509_NAME_VALUE, &nameValues[i].value, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); @@ -1370,7 +1370,7 @@ static void test_decodeNameValue(DWORD dwEncoding) DWORD bufSize = 0; BOOL ret; - for (i = 0; i < sizeof(nameValues) / sizeof(nameValues[0]); i++) + for (i = 0; i < ARRAY_SIZE(nameValues); i++) { ret = pCryptDecodeObjectEx(dwEncoding, X509_NAME_VALUE, nameValues[i].encoded, nameValues[i].encoded[1] + 2, @@ -1866,7 +1866,7 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) "Expected CRYPT_E_NOT_CHAR_STRING, got %08x\n", GetLastError()); /* More failure checking */ value.Value.cbData = 0; - for (i = 0; i < sizeof(unicodeErrors) / sizeof(unicodeErrors[0]); i++) + for (i = 0; i < ARRAY_SIZE(unicodeErrors); i++) { value.Value.pbData = (LPBYTE)unicodeErrors[i].str; value.dwValueType = unicodeErrors[i].valueType; @@ -1881,7 +1881,7 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) } /* cbData can be zero if the string is NULL-terminated */ value.Value.cbData = 0; - for (i = 0; i < sizeof(unicodeResults) / sizeof(unicodeResults[0]); i++) + for (i = 0; i < ARRAY_SIZE(unicodeResults); i++) { value.Value.pbData = (LPBYTE)unicodeResults[i].str; value.dwValueType = unicodeResults[i].valueType; @@ -1903,7 +1903,7 @@ static void test_encodeUnicodeNameValue(DWORD dwEncoding) * rather than properly encoding it. Kept separate from the proper results, * because the encoded forms won't decode to their original strings. */ - for (i = 0; i < sizeof(unicodeWeirdness) / sizeof(unicodeWeirdness[0]); i++) + for (i = 0; i < ARRAY_SIZE(unicodeWeirdness); i++) { value.Value.pbData = (LPBYTE)unicodeWeirdness[i].str; value.dwValueType = unicodeWeirdness[i].valueType; @@ -1933,7 +1933,7 @@ static void test_decodeUnicodeNameValue(DWORD dwEncoding) { DWORD i; - for (i = 0; i < sizeof(unicodeResults) / sizeof(unicodeResults[0]); i++) + for (i = 0; i < ARRAY_SIZE(unicodeResults); i++) { BYTE *buf = NULL; BOOL ret; @@ -1991,7 +1991,7 @@ static void test_encodeOctets(DWORD dwEncoding) } }; - for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) + for (i = 0; i < ARRAY_SIZE(tests); i++) { BYTE *buf = NULL; BOOL ret; @@ -2065,7 +2065,7 @@ static void test_decodeOctets(DWORD dwEncoding) } }; - for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) + for (i = 0; i < ARRAY_SIZE(tests); i++) { BYTE *buf = NULL; BOOL ret; @@ -2127,7 +2127,7 @@ static void test_encodeBits(DWORD dwEncoding) { DWORD i; - for (i = 0; i < sizeof(bits) / sizeof(bits[0]); i++) + for (i = 0; i < ARRAY_SIZE(bits); i++) { CRYPT_BIT_BLOB blob; BOOL ret; @@ -2162,7 +2162,7 @@ static void test_decodeBits(DWORD dwEncoding) DWORD bufSize = 0; /* normal cases */ - for (i = 0; i < sizeof(bits) / sizeof(bits[0]); i++) + for (i = 0; i < ARRAY_SIZE(bits); i++) { ret = pCryptDecodeObjectEx(dwEncoding, X509_BITS, bits[i].encoded, bits[i].encoded[1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, @@ -2249,7 +2249,7 @@ static void test_encodeBasicConstraints(DWORD dwEncoding) BYTE *buf = NULL; /* First test with the simpler info2 */ - for (i = 0; i < sizeof(constraints2) / sizeof(constraints2[0]); i++) + for (i = 0; i < ARRAY_SIZE(constraints2); i++) { ret = pCryptEncodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, &constraints2[i].info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, @@ -2312,7 +2312,7 @@ static void test_decodeBasicConstraints(DWORD dwEncoding) DWORD bufSize = 0; /* First test with simpler info2 */ - for (i = 0; i < sizeof(constraints2) / sizeof(constraints2[0]); i++) + for (i = 0; i < ARRAY_SIZE(constraints2); i++) { ret = pCryptDecodeObjectEx(dwEncoding, X509_BASIC_CONSTRAINTS2, constraints2[i].encoded, constraints2[i].encoded[1] + 2, @@ -2494,7 +2494,7 @@ static void test_encodeRsaPublicKey(DWORD dwEncoding) "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); /* Finally, all valid */ hdr->aiKeyAlg = CALG_RSA_KEYX; - for (i = 0; i < sizeof(rsaPubKeys) / sizeof(rsaPubKeys[0]); i++) + for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++) { memcpy(toEncode + sizeof(BLOBHEADER) + sizeof(RSAPUBKEY), rsaPubKeys[i].modulus, rsaPubKeys[i].modulusLen); @@ -2540,7 +2540,7 @@ static void test_decodeRsaPublicKey(DWORD dwEncoding) ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %08x\n", GetLastError()); /* Now try success cases */ - for (i = 0; i < sizeof(rsaPubKeys) / sizeof(rsaPubKeys[0]); i++) + for (i = 0; i < ARRAY_SIZE(rsaPubKeys); i++) { bufSize = 0; ret = pCryptDecodeObjectEx(dwEncoding, RSA_CSP_PUBLICKEYBLOB, @@ -2590,7 +2590,7 @@ static const BYTE mixedSequence[] = { 0x30, 0x27, 0x17, 0x0d, 0x30, 0x35, 0x30, static void test_encodeSequenceOfAny(DWORD dwEncoding) { - CRYPT_DER_BLOB blobs[sizeof(ints) / sizeof(ints[0])]; + CRYPT_DER_BLOB blobs[ARRAY_SIZE(ints)]; CRYPT_SEQUENCE_OF_ANY seq; DWORD i; BOOL ret; @@ -2598,12 +2598,12 @@ static void test_encodeSequenceOfAny(DWORD dwEncoding) DWORD bufSize = 0; /* Encode a homogeneous sequence */ - for (i = 0; i < sizeof(ints) / sizeof(ints[0]); i++) + for (i = 0; i < ARRAY_SIZE(ints); i++) { blobs[i].cbData = ints[i].encoded[1] + 2; blobs[i].pbData = (BYTE *)ints[i].encoded; } - seq.cValue = sizeof(ints) / sizeof(ints[0]); + seq.cValue = ARRAY_SIZE(ints); seq.rgValue = blobs; ret = pCryptEncodeObjectEx(dwEncoding, X509_SEQUENCE_OF_ANY, &seq, @@ -2646,9 +2646,8 @@ static void test_decodeSequenceOfAny(DWORD dwEncoding) CRYPT_SEQUENCE_OF_ANY *seq = (CRYPT_SEQUENCE_OF_ANY *)buf; DWORD i; - ok(seq->cValue == sizeof(ints) / sizeof(ints[0]), - "Wrong elements %d\n", seq->cValue); - for (i = 0; i < min(seq->cValue, sizeof(ints) / sizeof(ints[0])); i++) + ok(seq->cValue == ARRAY_SIZE(ints), "Wrong elements %d\n", seq->cValue); + for (i = 0; i < min(seq->cValue, ARRAY_SIZE(ints)); i++) { ok(seq->rgValue[i].cbData == ints[i].encoded[1] + 2, "Expected %d bytes, got %d\n", ints[i].encoded[1] + 2, @@ -2666,8 +2665,7 @@ static void test_decodeSequenceOfAny(DWORD dwEncoding) { CRYPT_SEQUENCE_OF_ANY *seq = (CRYPT_SEQUENCE_OF_ANY *)buf; - ok(seq->cValue == sizeof(ints) / sizeof(ints[0]), - "Wrong elements %d\n", seq->cValue); + ok(seq->cValue == ARRAY_SIZE(ints), "Wrong elements %d\n", seq->cValue); /* Just check the first element since it's all that changed */ ok(seq->rgValue[0].cbData == times[0].encodedTime[1] + 2, "Expected %d bytes, got %d\n", times[0].encodedTime[1] + 2, @@ -2713,7 +2711,7 @@ static void test_encodeExtensions(DWORD dwEncoding) { DWORD i; - for (i = 0; i < sizeof(exts) / sizeof(exts[i]); i++) + for (i = 0; i < ARRAY_SIZE(exts); i++) { BOOL ret; BYTE *buf = NULL; @@ -2737,7 +2735,7 @@ static void test_decodeExtensions(DWORD dwEncoding) { DWORD i; - for (i = 0; i < sizeof(exts) / sizeof(exts[i]); i++) + for (i = 0; i < ARRAY_SIZE(exts); i++) { BOOL ret; BYTE *buf = NULL; @@ -2851,7 +2849,7 @@ static void test_encodePublicKeyInfo(DWORD dwEncoding) { DWORD i; - for (i = 0; i < sizeof(pubKeys) / sizeof(pubKeys[0]); i++) + for (i = 0; i < ARRAY_SIZE(pubKeys); i++) { BOOL ret; BYTE *buf = NULL; @@ -2907,7 +2905,7 @@ static void test_decodePublicKeyInfo(DWORD dwEncoding) BYTE *buf = NULL; DWORD bufSize = 0; - for (i = 0; i < sizeof(pubKeys) / sizeof(pubKeys[0]); i++) + for (i = 0; i < ARRAY_SIZE(pubKeys); i++) { /* The NULL form decodes to the decoded member */ ret = pCryptDecodeObjectEx(dwEncoding, X509_PUBLIC_KEY_INFO, @@ -3260,7 +3258,7 @@ static void test_decodeCertToBeSigned(DWORD dwEncoding) * CRYPT_E_ASN1_BADTAG, because at a minimum a cert must have a non-zero * serial number, an issuer, a subject, and a public key. */ - for (i = 0; i < sizeof(corruptCerts) / sizeof(corruptCerts[0]); i++) + for (i = 0; i < ARRAY_SIZE(corruptCerts); i++) { ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_TO_BE_SIGNED, corruptCerts[i], corruptCerts[i][1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, @@ -4688,7 +4686,7 @@ static void test_decodeCRLToBeSigned(DWORD dwEncoding) BYTE *buf = NULL; DWORD size = 0, i; - for (i = 0; i < sizeof(corruptCRLs) / sizeof(corruptCRLs[0]); i++) + for (i = 0; i < ARRAY_SIZE(corruptCRLs); i++) { ret = pCryptDecodeObjectEx(dwEncoding, X509_CERT_CRL_TO_BE_SIGNED, corruptCRLs[i], corruptCRLs[i][1] + 2, CRYPT_DECODE_ALLOC_FLAG, NULL, @@ -4854,7 +4852,7 @@ static void test_encodeEnhancedKeyUsage(DWORD dwEncoding) LocalFree(buf); } /* Test with a few usages */ - usage.cUsageIdentifier = sizeof(keyUsages) / sizeof(keyUsages[0]); + usage.cUsageIdentifier = ARRAY_SIZE(keyUsages); usage.rgpszUsageIdentifier = (LPSTR *)keyUsages; ret = pCryptEncodeObjectEx(dwEncoding, X509_ENHANCED_KEY_USAGE, &usage, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size); @@ -4898,8 +4896,8 @@ static void test_decodeEnhancedKeyUsage(DWORD dwEncoding) ok(size >= sizeof(CERT_ENHKEY_USAGE), "Wrong size %d\n", size); - ok(usage->cUsageIdentifier == sizeof(keyUsages) / sizeof(keyUsages[0]), - "Wrong CRL entries count %d\n", usage->cUsageIdentifier); + ok(usage->cUsageIdentifier == ARRAY_SIZE(keyUsages), + "Wrong CRL entries count %d\n", usage->cUsageIdentifier); for (i = 0; i < usage->cUsageIdentifier; i++) ok(!strcmp(usage->rgpszUsageIdentifier[i], keyUsages[i]), "Expected OID %s, got %s\n", keyUsages[i], @@ -6109,7 +6107,7 @@ static void test_decodePKCSContentInfo(DWORD dwEncoding) "1.2.3", content_constructed_abcd + 8, 10 } }; - for (i = 0; i < sizeof(tests)/sizeof(*tests); i++) + for (i = 0; i < ARRAY_SIZE(tests); i++) { ret = pCryptDecodeObjectEx(dwEncoding, PKCS_CONTENT_INFO, tests[i].encoded, tests[i].encoded_size, CRYPT_DECODE_ALLOC_FLAG, NULL, &buf, &size); @@ -7397,9 +7395,7 @@ static void test_decodeNameConstraints(DWORD dwEncoding) U(IPAddressWithMinSubtree.Base).IPAddress.pbData = (LPBYTE)encodedIPAddr; U(IPAddressWithMinMaxSubtree.Base).IPAddress.cbData = sizeof(encodedIPAddr); U(IPAddressWithMinMaxSubtree.Base).IPAddress.pbData = (LPBYTE)encodedIPAddr; - for (i = 0; - i < sizeof(encodedNameConstraints) / sizeof(encodedNameConstraints[0]); - i++) + for (i = 0; i < ARRAY_SIZE(encodedNameConstraints); i++) { DWORD size; @@ -7749,7 +7745,7 @@ static void test_encodeCertPolicyMappings(DWORD dwEncoding) DWORD size, i; /* Each of the mapping OIDs is equivalent, so check with all of them */ - for (i = 0; i < sizeof(mappingOids) / sizeof(mappingOids[0]); i++) + for (i = 0; i < ARRAY_SIZE(mappingOids); i++) { memset(&info, 0, sizeof(info)); ret = pCryptEncodeObjectEx(dwEncoding, mappingOids[i], &info, @@ -7814,7 +7810,7 @@ static void test_decodeCertPolicyMappings(DWORD dwEncoding) BOOL ret; /* Each of the mapping OIDs is equivalent, so check with all of them */ - for (i = 0; i < sizeof(mappingOids) / sizeof(mappingOids[0]); i++) + for (i = 0; i < ARRAY_SIZE(mappingOids); i++) { ret = pCryptDecodeObjectEx(dwEncoding, mappingOids[i], emptySequence, sizeof(emptySequence), CRYPT_DECODE_ALLOC_FLAG, NULL, @@ -8509,173 +8505,6 @@ static void testPortPublicKeyInfo(void) ok(ret,"CryptAcquireContextA failed\n"); } -static const BYTE eccCert[] = { -0x30,0x82,0x01,0x46,0x30,0x81,0xec,0x02,0x09,0x00,0xe7,0x6b, -0x26,0x86,0x0a,0x82,0xff,0xe9,0x30,0x0a,0x06,0x08,0x2a,0x86, -0x48,0xce,0x3d,0x04,0x03,0x02,0x30,0x2b,0x31,0x0b,0x30,0x09, -0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x44,0x45,0x31,0x0d,0x30, -0x0b,0x06,0x03,0x55,0x04,0x0a,0x0c,0x04,0x57,0x69,0x6e,0x65, -0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x03,0x0c,0x04,0x57, -0x69,0x6e,0x65,0x30,0x1e,0x17,0x0d,0x31,0x37,0x30,0x39,0x32, -0x37,0x31,0x33,0x34,0x31,0x30,0x34,0x5a,0x17,0x0d,0x32,0x37, -0x30,0x39,0x32,0x35,0x31,0x33,0x34,0x31,0x30,0x34,0x5a,0x30, -0x2b,0x31,0x0b,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02, -0x44,0x45,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55,0x04,0x0a,0x0c, -0x04,0x54,0x65,0x73,0x74,0x31,0x0d,0x30,0x0b,0x06,0x03,0x55, -0x04,0x03,0x0c,0x04,0x54,0x65,0x73,0x74,0x30,0x59,0x30,0x13, -0x06,0x07,0x2a,0x86,0x48,0xce,0x3d,0x02,0x01,0x06,0x08,0x2a, -0x86,0x48,0xce,0x3d,0x03,0x01,0x07,0x03,0x42,0x00,0x04,0xed, -0xfc,0x77,0xd8,0xb9,0xe7,0xf3,0xf8,0xce,0x13,0xb8,0x7f,0x0f, -0x78,0xea,0x73,0x87,0x29,0x10,0xe1,0x6d,0x10,0xce,0x57,0x60, -0x3b,0x3e,0xb4,0x5f,0x0d,0x20,0xc1,0xeb,0x6d,0x74,0xe9,0x7b, -0x11,0x51,0x9a,0x00,0xe8,0xe9,0x12,0x84,0xb9,0x07,0x7e,0x7b, -0x62,0x67,0x12,0x67,0x08,0xe5,0x2e,0x27,0xce,0xa2,0x57,0x15, -0xad,0xc5,0x1f,0x30,0x0a,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d, -0x04,0x03,0x02,0x03,0x49,0x00,0x30,0x46,0x02,0x21,0x00,0xd7, -0x29,0xce,0x5a,0xef,0x74,0x85,0xd1,0x18,0x5f,0x6e,0xf1,0xba, -0x53,0xd4,0xcd,0xdd,0xe0,0x5d,0xf1,0x5e,0x48,0x51,0xea,0x63, -0xc0,0xe8,0xe2,0xf6,0xfa,0x4c,0xaf,0x02,0x21,0x00,0xe3,0x94, -0x15,0x3b,0x6c,0x71,0x6e,0x44,0x22,0xcb,0xa0,0x88,0xcd,0x0a, -0x5a,0x50,0x29,0x7c,0x5c,0xd6,0x6c,0xd2,0xe0,0x7f,0xcd,0x02, -0x92,0x21,0x4c,0x2c,0x92,0xee }; -static const BYTE ecdsaSig[] = { -0x30,0x46,0x02,0x21,0x00,0xd7,0x29,0xce,0x5a,0xef,0x74,0x85, -0xd1,0x18,0x5f,0x6e,0xf1,0xba,0x53,0xd4,0xcd,0xdd,0xe0,0x5d, -0xf1,0x5e,0x48,0x51,0xea,0x63,0xc0,0xe8,0xe2,0xf6,0xfa,0x4c, -0xaf,0x02,0x21,0x00,0xe3,0x94,0x15,0x3b,0x6c,0x71,0x6e,0x44, -0x22,0xcb,0xa0,0x88,0xcd,0x0a,0x5a,0x50,0x29,0x7c,0x5c,0xd6, -0x6c,0xd2,0xe0,0x7f,0xcd,0x02,0x92,0x21,0x4c,0x2c,0x92,0xee }; -static const BYTE eccPubKey[] = { -0x30,0x59,0x30,0x13,0x06,0x07,0x2a,0x86,0x48,0xce,0x3d,0x02, -0x01,0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x03,0x01,0x07,0x03, -0x42,0x00,0x04,0xed,0xfc,0x77,0xd8,0xb9,0xe7,0xf3,0xf8,0xce, -0x13,0xb8,0x7f,0x0f,0x78,0xea,0x73,0x87,0x29,0x10,0xe1,0x6d, -0x10,0xce,0x57,0x60,0x3b,0x3e,0xb4,0x5f,0x0d,0x20,0xc1,0xeb, -0x6d,0x74,0xe9,0x7b,0x11,0x51,0x9a,0x00,0xe8,0xe9,0x12,0x84, -0xb9,0x07,0x7e,0x7b,0x62,0x67,0x12,0x67,0x08,0xe5,0x2e,0x27, -0xce,0xa2,0x57,0x15,0xad,0xc5,0x1f }; - -static void testECDSACert(void) -{ - DWORD decode_flags = CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG; - CERT_SIGNED_CONTENT_INFO *info; - CERT_PUBLIC_KEY_INFO *pubkey; - CERT_ECC_SIGNATURE *ecc_sig; - LPSTR *ecc_curve; - DWORD size; - BOOL ret; - int i; - - info = NULL; - ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_CERT, eccCert, sizeof(eccCert), decode_flags, - NULL, &info, &size); - ok(ret, "CryptDecodeObjectEx failed with %d\n", GetLastError()); - - ok(!strcmp(info->SignatureAlgorithm.pszObjId, szOID_ECDSA_SHA256), - "Expected 1.2.840.10045.4.3.2, got %s\n", info->SignatureAlgorithm.pszObjId); - ok(!info->SignatureAlgorithm.Parameters.cbData, - "Expected no parameter data, got %d bytes\n", info->SignatureAlgorithm.Parameters.cbData); - ok(!info->SignatureAlgorithm.Parameters.pbData, - "Expected no parameter data, got %p pointer\n", info->SignatureAlgorithm.Parameters.pbData); - - ok(info->Signature.cbData == sizeof(ecdsaSig), - "Expected %d bytes, got %d\n", (int)sizeof(ecdsaSig), info->Signature.cbData); - ok(info->Signature.pbData != NULL, "Got NULL pointer\n"); - ok(!info->Signature.cUnusedBits, "Expected no unused bytes, got %d\n", info->Signature.cUnusedBits); - for (i = 0; i < info->Signature.cbData; i++) - { - ok(ecdsaSig[i] == info->Signature.pbData[i], "Expected %02x, got %02x at offset %d\n", - ecdsaSig[i], info->Signature.pbData[i], i); - } - - ecc_sig = NULL; - ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_ECC_SIGNATURE, info->Signature.pbData, - info->Signature.cbData, decode_flags, NULL, &ecc_sig, &size); - ok(ret, "CryptDecodeObjectEx failed with %d\n", GetLastError()); - if (ret) - { - ok(ecc_sig->r.cbData == 32, "Expected 32 bytes, got %d\n", ecc_sig->r.cbData); - ok(ecc_sig->r.pbData != NULL, "Got NULL pointer\n"); - ok(ecc_sig->s.cbData == 32, "Expected 32 bytes, got %d\n", ecc_sig->s.cbData); - ok(ecc_sig->s.pbData != NULL, "Got NULL pointer\n"); - for (i = 0; i < ecc_sig->r.cbData; i++) - { - ok(ecdsaSig[4+32-i] == ecc_sig->r.pbData[i], "Expected %02x, got %02x at offset %d\n", - ecdsaSig[4+32-i], ecc_sig->r.pbData[i], i); - } - for (i = 0; i < ecc_sig->s.cbData; i++) - { - ok(ecdsaSig[4+35+32-i] == ecc_sig->s.pbData[i], "Expected %02x, got %02x at offset %d\n", - ecdsaSig[4+35+32-i], ecc_sig->s.pbData[i], i); - } - LocalFree(ecc_sig); - } - - LocalFree(info); - - info = NULL; - decode_flags &= ~CRYPT_DECODE_NO_SIGNATURE_BYTE_REVERSAL_FLAG; - ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_CERT, eccCert, sizeof(eccCert), decode_flags, - NULL, &info, &size); - ok(ret, "CryptDecodeObjectEx failed with %d\n", GetLastError()); - - ok(info->Signature.cbData == sizeof(ecdsaSig), - "Expected %d bytes, got %d\n", (int)sizeof(ecdsaSig), info->Signature.cbData); - ok(info->Signature.pbData != NULL, "Got NULL pointer\n"); - ok(!info->Signature.cUnusedBits, "Expected no unused bytes, got %d\n", info->Signature.cUnusedBits); - for (i = 0; i < info->Signature.cbData; i++) - { - ok(ecdsaSig[sizeof(ecdsaSig)-i-1] == info->Signature.pbData[i], "Expected %02x, got %02x at offset %d\n", - ecdsaSig[sizeof(ecdsaSig)-i-1], info->Signature.pbData[i], i); - } - - LocalFree(info); - - pubkey = NULL; - ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_PUBLIC_KEY_INFO, eccPubKey, sizeof(eccPubKey), - decode_flags, NULL, &pubkey, &size); - ok(ret, "CryptDecodeObjectEx failed with %d\n", GetLastError()); - - ok(!strcmp(pubkey->Algorithm.pszObjId, szOID_ECC_PUBLIC_KEY), - "Expected 1.2.840.10045.2.1, got %s\n", pubkey->Algorithm.pszObjId); - ok(pubkey->Algorithm.Parameters.cbData == 10, - "Expected 10 bytes parameters, got %d bytes\n", pubkey->Algorithm.Parameters.cbData); - ok(pubkey->Algorithm.Parameters.pbData != NULL, - "Expected pointer to parameters, got NULL\n"); - - ecc_curve = NULL; - ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, X509_OBJECT_IDENTIFIER, pubkey->Algorithm.Parameters.pbData, - pubkey->Algorithm.Parameters.cbData, decode_flags, NULL, &ecc_curve, &size); - ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND /* < Vista */), - "CryptDecodeObjectEx failed with %d\n", GetLastError()); - if (ret) - { - ok(!strcmp(*ecc_curve, szOID_ECC_CURVE_P256), "Expected 1.2.840.10045.3.1.7, got %s\n", *ecc_curve); - LocalFree(ecc_curve); - } - - ecc_curve = NULL; - ret = pCryptDecodeObjectEx(X509_ASN_ENCODING, szOID_ECC_PUBLIC_KEY, pubkey->Algorithm.Parameters.pbData, - pubkey->Algorithm.Parameters.cbData, decode_flags, NULL, &ecc_curve, &size); - ok(ret || broken(GetLastError() == ERROR_FILE_NOT_FOUND /* < Vista */), - "CryptDecodeObjectEx failed with %d\n", GetLastError()); - if (ret) - { - ok(!strcmp(*ecc_curve, szOID_ECC_CURVE_P256), "Expected 1.2.840.10045.3.1.7, got %s\n", *ecc_curve); - LocalFree(ecc_curve); - } - - ok(pubkey->PublicKey.cbData == 65, "Expected 32 bytes parameters, got %d bytes\n", pubkey->PublicKey.cbData); - ok(pubkey->PublicKey.pbData != NULL, "Expected pointer to parameters, got NULL\n"); - for (i = 0; i < pubkey->PublicKey.cbData; i++) - { - ok(eccPubKey[26+i] == pubkey->PublicKey.pbData[i], "Expected %02x, got %02x at offset %d\n", - eccPubKey[26+i], pubkey->PublicKey.pbData[i], i); - } - - LocalFree(pubkey); -} - START_TEST(encode) { static const DWORD encodings[] = { X509_ASN_ENCODING, PKCS_7_ASN_ENCODING, @@ -8692,7 +8521,7 @@ START_TEST(encode) return; } - for (i = 0; i < sizeof(encodings) / sizeof(encodings[0]); i++) + for (i = 0; i < ARRAY_SIZE(encodings); i++) { test_encodeInt(encodings[i]); test_decodeInt(encodings[i]); @@ -8769,5 +8598,4 @@ START_TEST(encode) test_decodeRsaPrivateKey(encodings[i]); } testPortPublicKeyInfo(); - testECDSACert(); } diff --git a/modules/rostests/winetests/crypt32/main.c b/modules/rostests/winetests/crypt32/main.c index a0019b5869..11beff11c4 100644 --- a/modules/rostests/winetests/crypt32/main.c +++ b/modules/rostests/winetests/crypt32/main.c @@ -36,7 +36,7 @@ static void test_findAttribute(void) BYTE blobbin[] = {0x02,0x01,0x01}; static CHAR oid[] = "1.2.3"; CRYPT_ATTR_BLOB blobs[] = { { sizeof blobbin, blobbin }, }; - CRYPT_ATTRIBUTE attr = { oid, sizeof(blobs) / sizeof(blobs[0]), blobs }; + CRYPT_ATTRIBUTE attr = { oid, ARRAY_SIZE(blobs), blobs }; /* returns NULL, last error not set */ SetLastError(0xdeadbeef); @@ -128,10 +128,8 @@ static void test_findRDNAttr(void) CERT_RDN_ATTR attrs[] = { { oid, CERT_RDN_IA5_STRING, { sizeof bin, bin } }, }; - CERT_RDN rdns[] = { - { sizeof(attrs) / sizeof(attrs[0]), attrs }, - }; - CERT_NAME_INFO nameInfo = { sizeof(rdns) / sizeof(rdns[0]), rdns }; + CERT_RDN rdns[] = { { ARRAY_SIZE(attrs), attrs } }; + CERT_NAME_INFO nameInfo = { ARRAY_SIZE(rdns), rdns }; if (0) { diff --git a/modules/rostests/winetests/crypt32/msg.c b/modules/rostests/winetests/crypt32/msg.c index c2405335b9..b6921273ee 100644 --- a/modules/rostests/winetests/crypt32/msg.c +++ b/modules/rostests/winetests/crypt32/msg.c @@ -575,7 +575,7 @@ static CRYPT_DATA_BLOB b1[] = { { sizeof(u2), u2 }, { sizeof(u2), u2 }, }; -static const struct update_accum a1 = { sizeof(b1) / sizeof(b1[0]), b1 }; +static const struct update_accum a1 = { ARRAY_SIZE(b1), b1 }; /* The updates of a definite-length encoded message */ static BYTE u3[] = { 0x30,0x13,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01, 0x07,0x01,0xa0,0x06,0x04,0x04 }; @@ -583,7 +583,7 @@ static CRYPT_DATA_BLOB b2[] = { { sizeof(u3), u3 }, { sizeof(u2), u2 }, }; -static const struct update_accum a2 = { sizeof(b2) / sizeof(b2[0]), b2 }; +static const struct update_accum a2 = { ARRAY_SIZE(b2), b2 }; /* The updates of an indefinite-length encoded message */ static BYTE u4[] = { 0x30,0x80,0x06,0x09,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x01, 0x07,0x01,0xa0,0x80,0x24,0x80 }; @@ -597,7 +597,7 @@ static CRYPT_DATA_BLOB b3[] = { { sizeof(u2), u2 }, { sizeof(u6), u6 }, }; -static const struct update_accum a3 = { sizeof(b3) / sizeof(b3[0]), b3 }; +static const struct update_accum a3 = { ARRAY_SIZE(b3), b3 }; static void check_updates(LPCSTR header, const struct update_accum *expected, const struct update_accum *got) diff --git a/modules/rostests/winetests/crypt32/oid.c b/modules/rostests/winetests/crypt32/oid.c index 89d58b77f8..d6a03c5d1d 100644 --- a/modules/rostests/winetests/crypt32/oid.c +++ b/modules/rostests/winetests/crypt32/oid.c @@ -106,7 +106,7 @@ static void testOIDToAlgID(void) alg = CertOIDToAlgId("1.2.3"); ok(!alg, "Expected failure, got %d\n", alg); - for (i = 0; i < sizeof(oidToAlgID) / sizeof(oidToAlgID[0]); i++) + for (i = 0; i < ARRAY_SIZE(oidToAlgID); i++) { alg = CertOIDToAlgId(oidToAlgID[i].oid); ok(alg == oidToAlgID[i].algID || (oidToAlgID[i].altAlgID && alg == oidToAlgID[i].altAlgID), @@ -124,7 +124,7 @@ static void testAlgIDToOID(void) oid = CertAlgIdToOID(ALG_CLASS_SIGNATURE | ALG_TYPE_ANY | 80); ok(!oid && GetLastError() == 0xdeadbeef, "Didn't expect last error (%08x) to be set\n", GetLastError()); - for (i = 0; i < sizeof(algIDToOID) / sizeof(algIDToOID[0]); i++) + for (i = 0; i < ARRAY_SIZE(algIDToOID); i++) { oid = CertAlgIdToOID(algIDToOID[i].algID); /* Allow failure, not every version of Windows supports every algo */ @@ -424,7 +424,7 @@ static void test_registerDefaultOIDFunction(void) DWORD type, size; LPSTR ptr; - size = sizeof(dllBuf) / sizeof(dllBuf[0]); + size = ARRAY_SIZE(dllBuf); rc = RegQueryValueExA(key, dllA, NULL, &type, (LPBYTE)dllBuf, &size); ok(rc == 0, "Expected Dll value to exist, RegQueryValueExA failed: %d\n", rc); @@ -547,86 +547,63 @@ static void test_findOIDInfo(void) static WCHAR sha256ECDSA[] = { 's','h','a','2','5','6','E','C','D','S','A',0 }; static WCHAR sha1[] = { 's','h','a','1',0 }; static CHAR oid_rsa_md5[] = szOID_RSA_MD5, oid_sha256[] = szOID_NIST_sha256; - static CHAR oid_ecda_sha25[] = szOID_ECDSA_SHA256; + static CHAR oid_ecdsa_sha256[] = szOID_ECDSA_SHA256; ALG_ID alg = CALG_SHA1; ALG_ID algs[2] = { CALG_MD5, CALG_RSA_SIGN }; + const struct oid_info + { + DWORD key_type; + void *key; + const char *oid; + ALG_ID algid; + ALG_ID broken_algid; + } oid_test_info [] = + { + { CRYPT_OID_INFO_OID_KEY, oid_rsa_md5, szOID_RSA_MD5, CALG_MD5 }, + { CRYPT_OID_INFO_NAME_KEY, sha1, szOID_OIWSEC_sha1, CALG_SHA1 }, + { CRYPT_OID_INFO_ALGID_KEY, &alg, szOID_OIWSEC_sha1, CALG_SHA1 }, + { CRYPT_OID_INFO_SIGN_KEY, algs, szOID_RSA_MD5RSA, CALG_MD5 }, + { CRYPT_OID_INFO_OID_KEY, oid_sha256, szOID_NIST_sha256, CALG_SHA_256, -1 }, + }; PCCRYPT_OID_INFO info; - - static const WCHAR sha256W[] = {'s','h','a','2','5','6',0}; + int i; info = CryptFindOIDInfo(0, NULL, 0); ok(info == NULL, "Expected NULL\n"); - info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_rsa_md5, 0); - ok(info != NULL, "Expected to find szOID_RSA_MD5\n"); - if (info) - { - ok(!strcmp(info->pszOID, szOID_RSA_MD5), "Expected %s, got %s\n", - szOID_RSA_MD5, info->pszOID); - ok(U(*info).Algid == CALG_MD5, "Expected CALG_MD5, got %d\n", - U(*info).Algid); - } - info = CryptFindOIDInfo(CRYPT_OID_INFO_NAME_KEY, sha1, 0); - ok(info != NULL, "Expected to find sha1\n"); - if (info) - { - ok(!strcmp(info->pszOID, szOID_OIWSEC_sha1), "Expected %s, got %s\n", - szOID_OIWSEC_sha1, info->pszOID); - ok(U(*info).Algid == CALG_SHA1, "Expected CALG_SHA1, got %d\n", - U(*info).Algid); - } - info = CryptFindOIDInfo(CRYPT_OID_INFO_ALGID_KEY, &alg, 0); - ok(info != NULL, "Expected to find sha1\n"); - if (info) - { - ok(!strcmp(info->pszOID, szOID_OIWSEC_sha1), "Expected %s, got %s\n", - szOID_OIWSEC_sha1, info->pszOID); - ok(U(*info).Algid == CALG_SHA1, "Expected CALG_SHA1, got %d\n", - U(*info).Algid); - } - info = CryptFindOIDInfo(CRYPT_OID_INFO_SIGN_KEY, algs, 0); - ok(info != NULL, "Expected to find md5RSA\n"); - if (info) - { - ok(!strcmp(info->pszOID, szOID_RSA_MD5RSA), "Expected %s, got %s\n", - szOID_RSA_MD5RSA, info->pszOID); - ok(U(*info).Algid == CALG_MD5, "Expected CALG_MD5, got %d\n", - U(*info).Algid); - } - info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_sha256, 0); - ok(info != NULL, "Expected to find szOID_RSA_MD5\n"); - if (info) + for (i = 0; i < ARRAY_SIZE(oid_test_info); i++) { - ok(!strcmp(info->pszOID, szOID_NIST_sha256), "Expected %s, got %s\n", - szOID_NIST_sha256, info->pszOID); - ok(!lstrcmpW(info->pwszName, sha256W), "pwszName = %s\n", wine_dbgstr_w(info->pwszName)); - ok(U(*info).Algid == CALG_SHA_256 || U(*info).Algid == -1, - "Expected CALG_MD5 or -1, got %d\n", U(*info).Algid); + const struct oid_info *test = &oid_test_info[i]; + + info = CryptFindOIDInfo(test->key_type, test->key, 0); + ok(info != NULL, "Failed to find %s.\n", test->oid); + if (info) + { + ok(!strcmp(info->pszOID, test->oid), "Unexpected OID %s, expected %s\n", info->pszOID, test->oid); + ok(U(*info).Algid == test->algid || broken(U(*info).Algid == test->broken_algid), + "Unexpected Algid %d, expected %d\n", U(*info).Algid, test->algid); + } } - info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_ecda_sha25, 0); + info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, oid_ecdsa_sha256, 0); if (info) { DWORD *data; - ok(info->cbSize == sizeof(*info), - "Expected %d, got %d\n", (int)sizeof(*info), info->cbSize); - ok(!strcmp(info->pszOID, oid_ecda_sha25), - "Expected %s, got %s\n", oid_ecda_sha25, info->pszOID); - ok(!lstrcmpW(info->pwszName, sha256ECDSA), - "Expected %s, got %s\n", wine_dbgstr_w(sha256ECDSA), wine_dbgstr_w(info->pwszName)); + ok(info->cbSize == sizeof(*info), "Unexpected structure size %d.\n", info->cbSize); + ok(!strcmp(info->pszOID, oid_ecdsa_sha256), "Expected %s, got %s\n", oid_ecdsa_sha256, info->pszOID); + ok(!lstrcmpW(info->pwszName, sha256ECDSA), "Expected %s, got %s\n", + wine_dbgstr_w(sha256ECDSA), wine_dbgstr_w(info->pwszName)); ok(info->dwGroupId == CRYPT_SIGN_ALG_OID_GROUP_ID, "Expected CRYPT_SIGN_ALG_OID_GROUP_ID, got %u\n", info->dwGroupId); ok(U(*info).Algid == CALG_OID_INFO_CNG_ONLY, "Expected CALG_OID_INFO_CNG_ONLY, got %d\n", U(*info).Algid); data = (DWORD *)info->ExtraInfo.pbData; - ok(info->ExtraInfo.cbData == 8, - "Expected 8, got %d\n", info->ExtraInfo.cbData); - ok(data[0] == CALG_OID_INFO_PARAMETERS, - "Expected CALG_OID_INFO_PARAMETERS, got %x\n", data[0]); + ok(info->ExtraInfo.cbData == 8, "Expected 8, got %d\n", info->ExtraInfo.cbData); + ok(data[0] == CALG_OID_INFO_PARAMETERS, "Expected CALG_OID_INFO_PARAMETERS, got %x\n", data[0]); ok(data[1] == CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG, - "Expected CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG, got %x\n", data[1]); + "Expected CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG, got %x\n", data[1]); ok(!lstrcmpW(info->pwszCNGAlgid, BCRYPT_SHA256_ALGORITHM), "Expected %s, got %s\n", wine_dbgstr_w(BCRYPT_SHA256_ALGORITHM), wine_dbgstr_w(info->pwszCNGAlgid)); diff --git a/modules/rostests/winetests/crypt32/sip.c b/modules/rostests/winetests/crypt32/sip.c index e2ec2f411d..d8d6a87445 100644 --- a/modules/rostests/winetests/crypt32/sip.c +++ b/modules/rostests/winetests/crypt32/sip.c @@ -187,9 +187,8 @@ static void test_SIPRetrieveSubjectGUID(void) ok (ret > 0, "expected GEVA(windir) to succeed, last error %d\n", GetLastError()); strcat(regeditPath, "\\"); strcat(regeditPath, regeditExe); - MultiByteToWideChar( CP_ACP, 0, regeditPath, - strlen(regeditPath)+1, regeditPathW, - sizeof(regeditPathW)/sizeof(regeditPathW[0]) ); + MultiByteToWideChar(CP_ACP, 0, regeditPath, strlen(regeditPath)+1, regeditPathW, + ARRAY_SIZE(regeditPathW)); SetLastError(0xdeadbeef); memset(&subject, 1, sizeof(GUID)); @@ -221,9 +220,7 @@ static void test_SIPRetrieveSubjectGUID(void) /* Now with an empty file */ GetTempPathA(sizeof(path), path); GetTempFileNameA(path, "sip", 0 , tempfile); - MultiByteToWideChar( CP_ACP, 0, tempfile, - strlen(tempfile)+1, tempfileW, - sizeof(tempfileW)/sizeof(tempfileW[0]) ); + MultiByteToWideChar(CP_ACP, 0, tempfile, strlen(tempfile)+1, tempfileW, ARRAY_SIZE(tempfileW)); SetLastError(0xdeadbeef); memset(&subject, 1, sizeof(GUID)); diff --git a/modules/rostests/winetests/crypt32/store.c b/modules/rostests/winetests/crypt32/store.c index 47cd0b38cd..9915482277 100644 --- a/modules/rostests/winetests/crypt32/store.c +++ b/modules/rostests/winetests/crypt32/store.c @@ -385,7 +385,7 @@ static void testRegStoreSavedCerts(void) BOOL ret; DWORD res,i; - for (i = 0; i < sizeof(reg_store_saved_certs) / sizeof(reg_store_saved_certs[0]); i++) + for (i = 0; i < ARRAY_SIZE(reg_store_saved_certs); i++) { DWORD err; @@ -2081,7 +2081,7 @@ static void testCertRegisterSystemStore(void) const CERT_CONTEXT *cert, *cert2; unsigned int i; - for (i = 0; i < sizeof(reg_system_store_test_data) / sizeof(reg_system_store_test_data[0]); i++) { + for (i = 0; i < ARRAY_SIZE(reg_system_store_test_data); i++) { cur_flag = reg_system_store_test_data[i].cert_store; ret = CertRegisterSystemStore(WineTestW, cur_flag, NULL, NULL); if (!ret) @@ -2469,7 +2469,7 @@ static void delete_test_key(void) RegQueryInfoKeyW(test_key, NULL, NULL, NULL, &num_subkeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL); for (idx = num_subkeys; idx-- > 0;) { - subkey_name_len = sizeof(subkey_name)/sizeof(WCHAR); + subkey_name_len = ARRAY_SIZE(subkey_name); RegEnumKeyExW(test_key, idx, subkey_name, &subkey_name_len, NULL, NULL, NULL, NULL); RegDeleteKeyW(test_key, subkey_name); } diff --git a/modules/rostests/winetests/crypt32/str.c b/modules/rostests/winetests/crypt32/str.c index 5245885503..d382c0e6b0 100644 --- a/modules/rostests/winetests/crypt32/str.c +++ b/modules/rostests/winetests/crypt32/str.c @@ -250,7 +250,7 @@ static void test_CertRDNValueToStrA(void) ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n"); ok(!buffer[0], "Expected empty string\n"); - for (i = 0; i < sizeof(attrs) / sizeof(attrs[0]); i++) + for (i = 0; i < ARRAY_SIZE(attrs); i++) { ret = pCertRDNValueToStrA(attrs[i].dwValueType, &attrs[i].Value, buffer, sizeof(buffer)); @@ -341,15 +341,13 @@ static void test_CertRDNValueToStrW(void) SetLastError(0xdeadbeef); ret = pCertRDNValueToStrW(0, &blob, NULL, 0); ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n"); - ret = pCertRDNValueToStrW(0, &blob, buffer, - sizeof(buffer) / sizeof(buffer[0])); + ret = pCertRDNValueToStrW(0, &blob, buffer, ARRAY_SIZE(buffer)); ok(ret == 1 && GetLastError() == 0xdeadbeef, "Expected empty string\n"); ok(!buffer[0], "Expected empty string\n"); - for (i = 0; i < sizeof(attrs) / sizeof(attrs[0]); i++) + for (i = 0; i < ARRAY_SIZE(attrs); i++) { - ret = pCertRDNValueToStrW(attrs[i].dwValueType, &attrs[i].Value, - buffer, sizeof(buffer) / sizeof(buffer[0])); + ret = pCertRDNValueToStrW(attrs[i].dwValueType, &attrs[i].Value, buffer, ARRAY_SIZE(buffer)); todo_wine_if (attrs[i].todo) { ok(ret == lstrlenW(attrs[i].str) + 1, @@ -550,8 +548,7 @@ static void test_NameToStrConversionW(PCERT_NAME_BLOB pName, DWORD dwStrType, todo_wine_if (todo) ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %d\n", lstrlenW(expected) + 1, i); - i = pCertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, buffer, - sizeof(buffer) / sizeof(buffer[0])); + i = pCertNameToStrW(X509_ASN_ENCODING,pName, dwStrType, buffer, ARRAY_SIZE(buffer)); todo_wine_if (todo) ok(i == lstrlenW(expected) + 1, "Expected %d chars, got %d\n", lstrlenW(expected) + 1, i); @@ -795,7 +792,7 @@ static void test_CertStrToNameA(void) &size, NULL); ok(!ret && GetLastError() == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %08x\n", GetLastError()); - for (i = 0; i < sizeof(namesA) / sizeof(namesA[0]); i++) + for (i = 0; i < ARRAY_SIZE(namesA); i++) { size = sizeof(buf); ret = pCertStrToNameA(X509_ASN_ENCODING, namesA[i].x500, 0, NULL, buf, @@ -889,7 +886,7 @@ static void test_CertStrToNameW(void) ok(!ret && GetLastError() == CRYPT_E_INVALID_X500_STRING, "Expected CRYPT_E_INVALID_X500_STRING, got %08x\n", GetLastError()); ok(errorPtr && *errorPtr == '1', "Expected first error character was 1\n"); - for (i = 0; i < sizeof(namesW) / sizeof(namesW[0]); i++) + for (i = 0; i < ARRAY_SIZE(namesW); i++) { size = sizeof(buf); ret = pCertStrToNameW(X509_ASN_ENCODING, namesW[i].x500, 0, NULL, buf,
6 years, 2 months
1
0
0
0
01/01: [CRYPT32] Sync with Wine Staging 3.17. CORE-15127
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=997d44c915cb584c1fe67…
commit 997d44c915cb584c1fe67f707728cc704e0aafd7 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Oct 1 12:47:51 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Oct 1 12:47:51 2018 +0100 [CRYPT32] Sync with Wine Staging 3.17. CORE-15127 --- dll/win32/crypt32/base64.c | 158 +++++++++++++++++++++--------------- dll/win32/crypt32/cert.c | 152 +++++++++++++++------------------- dll/win32/crypt32/chain.c | 101 +++++++++-------------- dll/win32/crypt32/crypt32_private.h | 2 +- dll/win32/crypt32/decode.c | 95 +++++++++++----------- dll/win32/crypt32/encode.c | 52 +++++------- dll/win32/crypt32/filestore.c | 3 +- dll/win32/crypt32/main.c | 3 +- dll/win32/crypt32/msg.c | 2 +- dll/win32/crypt32/object.c | 155 ++++++++++++----------------------- dll/win32/crypt32/oid.c | 19 ++--- dll/win32/crypt32/regstore.c | 9 +- dll/win32/crypt32/rootstore.c | 6 +- dll/win32/crypt32/sip.c | 5 +- dll/win32/crypt32/store.c | 7 +- dll/win32/crypt32/str.c | 6 +- media/doc/README.WINE | 2 +- 17 files changed, 346 insertions(+), 431 deletions(-) diff --git a/dll/win32/crypt32/base64.c b/dll/win32/crypt32/base64.c index 4a904d41cc..d158c1aceb 100644 --- a/dll/win32/crypt32/base64.c +++ b/dll/win32/crypt32/base64.c @@ -53,10 +53,10 @@ static const WCHAR CERT_TRAILER_START_W[] = { '-','-','-','-','-','E','N','D',' ',0 }; static const WCHAR CERT_REQUEST_HEADER_W[] = { '-','-','-','-','-','B','E','G','I','N',' ','N','E','W',' ','C','E','R','T', -'I','F','I','C','A','T','E','R','E','Q','U','E','S','T','-','-','-','-','-',0 }; +'I','F','I','C','A','T','E',' ','R','E','Q','U','E','S','T','-','-','-','-','-',0 }; static const WCHAR CERT_REQUEST_TRAILER_W[] = { '-','-','-','-','-','E','N','D',' ','N','E','W',' ','C','E','R','T','I','F', -'I','C','A','T','E','R','E','Q','U','E','S','T','-','-','-','-','-',0 }; +'I','C','A','T','E',' ','R','E','Q','U','E','S','T','-','-','-','-','-',0 }; static const WCHAR X509_HEADER_W[] = { '-','-','-','-','-','B','E','G','I','N',' ','X','5','0','9',' ','C','R','L', '-','-','-','-','-',0 }; @@ -77,23 +77,19 @@ static BOOL EncodeBinaryToBinaryA(const BYTE *pbBinary, { BOOL ret = TRUE; - if (*pcchString < cbBinary) + if (pszString) { - if (!pszString) - *pcchString = cbBinary; - else + if (*pcchString < cbBinary) { SetLastError(ERROR_INSUFFICIENT_BUFFER); - *pcchString = cbBinary; ret = FALSE; } + else if (cbBinary) + memcpy(pszString, pbBinary, cbBinary); } else - { - if (cbBinary) - memcpy(pszString, pbBinary, cbBinary); *pcchString = cbBinary; - } + return ret; } @@ -107,8 +103,9 @@ static LONG encodeBase64A(const BYTE *in_buf, int in_len, LPCSTR sep, LPSTR ptr; TRACE("bytes is %d, pad bytes is %d\n", bytes, pad_bytes); - needed = bytes + pad_bytes + 1; - needed += (needed / 64 + 1) * strlen(sep); + needed = bytes + pad_bytes; + needed += (needed / 64 + (needed % 64 ? 1 : 0)) * strlen(sep); + needed++; if (needed > *out_len) { @@ -215,36 +212,41 @@ static BOOL BinaryToBase64A(const BYTE *pbBinary, charsNeeded += strlen(header) + strlen(sep); if (trailer) charsNeeded += strlen(trailer) + strlen(sep); - if (charsNeeded <= *pcchString) - { - LPSTR ptr = pszString; - DWORD size = charsNeeded; - if (header) + if (pszString) + { + if (charsNeeded <= *pcchString) { - strcpy(ptr, header); - ptr += strlen(ptr); - strcpy(ptr, sep); - ptr += strlen(sep); + LPSTR ptr = pszString; + DWORD size = charsNeeded; + + if (header) + { + strcpy(ptr, header); + ptr += strlen(ptr); + strcpy(ptr, sep); + ptr += strlen(sep); + } + encodeBase64A(pbBinary, cbBinary, sep, ptr, &size); + ptr += size - 1; + if (trailer) + { + strcpy(ptr, trailer); + ptr += strlen(ptr); + strcpy(ptr, sep); + } + *pcchString = charsNeeded - 1; } - encodeBase64A(pbBinary, cbBinary, sep, ptr, &size); - ptr += size - 1; - if (trailer) + else { - strcpy(ptr, trailer); - ptr += strlen(ptr); - strcpy(ptr, sep); + *pcchString = charsNeeded; + SetLastError(ERROR_INSUFFICIENT_BUFFER); + ret = FALSE; } - *pcchString = charsNeeded - 1; - } - else if (pszString) - { - *pcchString = charsNeeded; - SetLastError(ERROR_INSUFFICIENT_BUFFER); - ret = FALSE; } else *pcchString = charsNeeded; + return ret; } @@ -291,6 +293,26 @@ BOOL WINAPI CryptBinaryToStringA(const BYTE *pbBinary, return encoder(pbBinary, cbBinary, dwFlags, pszString, pcchString); } +static BOOL EncodeBinaryToBinaryW(const BYTE *in_buf, DWORD in_len, DWORD flags, WCHAR *out_buf, DWORD *out_len) +{ + BOOL ret = TRUE; + + if (out_buf) + { + if (*out_len < in_len) + { + SetLastError(ERROR_INSUFFICIENT_BUFFER); + ret = FALSE; + } + else if (in_len) + memcpy(out_buf, in_buf, in_len); + } + else + *out_len = in_len; + + return ret; +} + static LONG encodeBase64W(const BYTE *in_buf, int in_len, LPCWSTR sep, WCHAR* out_buf, DWORD *out_len) { @@ -301,8 +323,9 @@ static LONG encodeBase64W(const BYTE *in_buf, int in_len, LPCWSTR sep, LPWSTR ptr; TRACE("bytes is %d, pad bytes is %d\n", bytes, pad_bytes); - needed = bytes + pad_bytes + 1; - needed += (needed / 64 + 1) * strlenW(sep); + needed = bytes + pad_bytes; + needed += (needed / 64 + (needed % 64 ? 1 : 0)) * strlenW(sep); + needed++; if (needed > *out_len) { @@ -409,36 +432,41 @@ static BOOL BinaryToBase64W(const BYTE *pbBinary, charsNeeded += strlenW(header) + strlenW(sep); if (trailer) charsNeeded += strlenW(trailer) + strlenW(sep); - if (charsNeeded <= *pcchString) - { - LPWSTR ptr = pszString; - DWORD size = charsNeeded; - if (header) + if (pszString) + { + if (charsNeeded <= *pcchString) { - strcpyW(ptr, header); - ptr += strlenW(ptr); - strcpyW(ptr, sep); - ptr += strlenW(sep); + LPWSTR ptr = pszString; + DWORD size = charsNeeded; + + if (header) + { + strcpyW(ptr, header); + ptr += strlenW(ptr); + strcpyW(ptr, sep); + ptr += strlenW(sep); + } + encodeBase64W(pbBinary, cbBinary, sep, ptr, &size); + ptr += size - 1; + if (trailer) + { + strcpyW(ptr, trailer); + ptr += strlenW(ptr); + strcpyW(ptr, sep); + } + *pcchString = charsNeeded - 1; } - encodeBase64W(pbBinary, cbBinary, sep, ptr, &size); - ptr += size - 1; - if (trailer) + else { - strcpyW(ptr, trailer); - ptr += strlenW(ptr); - strcpyW(ptr, sep); + *pcchString = charsNeeded; + SetLastError(ERROR_INSUFFICIENT_BUFFER); + ret = FALSE; } - *pcchString = charsNeeded - 1; - } - else if (pszString) - { - *pcchString = charsNeeded; - SetLastError(ERROR_INSUFFICIENT_BUFFER); - ret = FALSE; } else *pcchString = charsNeeded; + return ret; } @@ -463,13 +491,15 @@ BOOL WINAPI CryptBinaryToStringW(const BYTE *pbBinary, switch (dwFlags & 0x0fffffff) { + case CRYPT_STRING_BINARY: + encoder = EncodeBinaryToBinaryW; + break; case CRYPT_STRING_BASE64: case CRYPT_STRING_BASE64HEADER: case CRYPT_STRING_BASE64REQUESTHEADER: case CRYPT_STRING_BASE64X509CRLHEADER: encoder = BinaryToBase64W; break; - case CRYPT_STRING_BINARY: case CRYPT_STRING_HEX: case CRYPT_STRING_HEXASCII: case CRYPT_STRING_HEXADDR: @@ -622,7 +652,7 @@ static LONG Base64WithHeaderAndTrailerToBinaryA(LPCSTR pszString, if (!(headerBegins = strstr(pszString, header))) { - TRACE("Can't find %s in %s.\n", header, pszString); + TRACE("Can't find %s in %s.\n", header, debugstr_an(pszString, cchString)); return ERROR_INVALID_DATA; } @@ -746,7 +776,7 @@ BOOL WINAPI CryptStringToBinaryA(LPCSTR pszString, StringToBinaryAFunc decoder; LONG ret; - TRACE("(%s, %d, %08x, %p, %p, %p, %p)\n", debugstr_a(pszString), + TRACE("(%s, %d, %08x, %p, %p, %p, %p)\n", debugstr_an(pszString, cchString ? cchString : -1), cchString, dwFlags, pbBinary, pcbBinary, pdwSkip, pdwFlags); if (!pszString) @@ -833,7 +863,7 @@ static LONG Base64WithHeaderAndTrailerToBinaryW(LPCWSTR pszString, if (!(headerBegins = strstrW(pszString, header))) { - TRACE("Can't find %s in %s.\n", debugstr_w(header), debugstr_w(pszString)); + TRACE("Can't find %s in %s.\n", debugstr_w(header), debugstr_wn(pszString, cchString)); return ERROR_INVALID_DATA; } @@ -957,7 +987,7 @@ BOOL WINAPI CryptStringToBinaryW(LPCWSTR pszString, StringToBinaryWFunc decoder; LONG ret; - TRACE("(%s, %d, %08x, %p, %p, %p, %p)\n", debugstr_w(pszString), + TRACE("(%s, %d, %08x, %p, %p, %p, %p)\n", debugstr_wn(pszString, cchString ? cchString : -1), cchString, dwFlags, pbBinary, pcbBinary, pdwSkip, pdwFlags); if (!pszString) diff --git a/dll/win32/crypt32/cert.c b/dll/win32/crypt32/cert.c index e379dc8a03..0088f006d3 100644 --- a/dll/win32/crypt32/cert.c +++ b/dll/win32/crypt32/cert.c @@ -992,8 +992,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. @@ -1889,7 +1888,7 @@ PCCERT_CONTEXT WINAPI CertGetIssuerCertificateFromStore(HCERTSTORE hCertStore, CertFreeCertificateContext(ret); ret = NULL; } - if (CRYPT_IsCertificateSelfSigned(pSubjectContext, NULL)) + if (CRYPT_IsCertificateSelfSigned(pSubjectContext)) { CertFreeCertificateContext(ret); ret = NULL; @@ -2414,29 +2413,27 @@ BOOL WINAPI CryptVerifyCertificateSignature(HCRYPTPROV_LEGACY hCryptProv, CRYPT_VERIFY_CERT_SIGN_ISSUER_PUBKEY, pPublicKey, 0, NULL); } -static BOOL verify_signature_crypt(HCRYPTPROV_LEGACY hCryptProv, - DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pubKeyInfo, - const CERT_SIGNED_CONTENT_INFO *signedCert, PCCRYPT_OID_INFO info) +static BOOL CRYPT_VerifySignature(HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType, + CERT_PUBLIC_KEY_INFO *pubKeyInfo, const CERT_SIGNED_CONTENT_INFO *signedCert, const CRYPT_OID_INFO *info) { - ALG_ID pubKeyID, hashID; - HCRYPTHASH hash; - HCRYPTKEY key; BOOL ret; + HCRYPTKEY key; + ALG_ID pubKeyID, hashID; hashID = info->u.Algid; if (info->ExtraInfo.cbData >= sizeof(ALG_ID)) pubKeyID = *(ALG_ID *)info->ExtraInfo.pbData; else pubKeyID = hashID; - /* Load the default provider if necessary */ if (!hCryptProv) hCryptProv = CRYPT_GetDefaultProvider(); - ret = CryptImportPublicKeyInfoEx(hCryptProv, dwCertEncodingType, pubKeyInfo, pubKeyID, 0, NULL, &key); if (ret) { + HCRYPTHASH hash; + ret = CryptCreateHash(hCryptProv, hashID, 0, 0, &hash); if (ret) { @@ -2452,14 +2449,13 @@ static BOOL verify_signature_crypt(HCRYPTPROV_LEGACY hCryptProv, return ret; } -static BOOL calculate_hash_bcrypt(const WCHAR *algorithm, - const CERT_SIGNED_CONTENT_INFO *signedCert, BYTE **hash_value, DWORD *hash_len) +static BOOL CNG_CalcHash(const WCHAR *algorithm, const CERT_SIGNED_CONTENT_INFO *signedCert, + BYTE **hash_value, DWORD *hash_len) { BCRYPT_HASH_HANDLE hash = NULL; BCRYPT_ALG_HANDLE alg = NULL; NTSTATUS status; DWORD size; - BOOL ret = FALSE; if ((status = BCryptOpenAlgorithmProvider(&alg, algorithm, NULL, 0))) goto done; @@ -2485,23 +2481,21 @@ static BOOL calculate_hash_bcrypt(const WCHAR *algorithm, goto done; } - ret = TRUE; - done: if (hash) BCryptDestroyHash(hash); if (alg) BCryptCloseAlgorithmProvider(alg, 0); if (status) SetLastError(RtlNtStatusToDosError(status)); - return ret; + return status == 0; } -static BOOL import_bcrypt_pubkey_ecc(PCERT_PUBLIC_KEY_INFO pubKeyInfo, BCRYPT_KEY_HANDLE *key) +static BOOL CNG_ImportECCPubKey(CERT_PUBLIC_KEY_INFO *pubKeyInfo, BCRYPT_KEY_HANDLE *key) { DWORD blob_magic, ecckey_len, size; - NTSTATUS status = STATUS_SUCCESS; + BCRYPT_ALG_HANDLE alg = NULL; BCRYPT_ECCKEY_BLOB *ecckey; const WCHAR *sign_algo; - BCRYPT_ALG_HANDLE alg; - LPSTR *ecc_curve; + char **ecc_curve; + NTSTATUS status; if (!pubKeyInfo->PublicKey.cbData) { @@ -2516,10 +2510,8 @@ static BOOL import_bcrypt_pubkey_ecc(PCERT_PUBLIC_KEY_INFO pubKeyInfo, BCRYPT_KE return FALSE; } - if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_OBJECT_IDENTIFIER, - pubKeyInfo->Algorithm.Parameters.pbData, - pubKeyInfo->Algorithm.Parameters.cbData, - CRYPT_DECODE_ALLOC_FLAG, NULL, &ecc_curve, &size)) + if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_OBJECT_IDENTIFIER, pubKeyInfo->Algorithm.Parameters.pbData, + pubKeyInfo->Algorithm.Parameters.cbData, CRYPT_DECODE_ALLOC_FLAG, NULL, &ecc_curve, &size)) return FALSE; if (!strcmp(*ecc_curve, szOID_ECC_CURVE_P256)) @@ -2527,7 +2519,7 @@ static BOOL import_bcrypt_pubkey_ecc(PCERT_PUBLIC_KEY_INFO pubKeyInfo, BCRYPT_KE sign_algo = BCRYPT_ECDSA_P256_ALGORITHM; blob_magic = BCRYPT_ECDSA_PUBLIC_P256_MAGIC; } - else if(!strcmp(*ecc_curve, szOID_ECC_CURVE_P384)) + else if (!strcmp(*ecc_curve, szOID_ECC_CURVE_P384)) { sign_algo = BCRYPT_ECDSA_P384_ALGORITHM; blob_magic = BCRYPT_ECDSA_PUBLIC_P384_MAGIC; @@ -2547,17 +2539,13 @@ static BOOL import_bcrypt_pubkey_ecc(PCERT_PUBLIC_KEY_INFO pubKeyInfo, BCRYPT_KE } if ((status = BCryptOpenAlgorithmProvider(&alg, sign_algo, NULL, 0))) - { - SetLastError(RtlNtStatusToDosError(status)); - return FALSE; - } + goto done; ecckey_len = sizeof(BCRYPT_ECCKEY_BLOB) + pubKeyInfo->PublicKey.cbData - 1; if (!(ecckey = CryptMemAlloc(ecckey_len))) { - BCryptCloseAlgorithmProvider(alg, 0); - SetLastError(ERROR_OUTOFMEMORY); - return FALSE; + status = STATUS_NO_MEMORY; + goto done; } ecckey->dwMagic = blob_magic; @@ -2565,36 +2553,32 @@ static BOOL import_bcrypt_pubkey_ecc(PCERT_PUBLIC_KEY_INFO pubKeyInfo, BCRYPT_KE memcpy(ecckey + 1, pubKeyInfo->PublicKey.pbData + 1, pubKeyInfo->PublicKey.cbData - 1); status = BCryptImportKeyPair(alg, NULL, BCRYPT_ECCPUBLIC_BLOB, key, (BYTE*)ecckey, ecckey_len, 0); - BCryptCloseAlgorithmProvider(alg, 0); - if (status) - { - SetLastError(RtlNtStatusToDosError(status)); - return FALSE; - } + CryptMemFree(ecckey); - return TRUE; +done: + if (alg) BCryptCloseAlgorithmProvider(alg, 0); + if (status) SetLastError(RtlNtStatusToDosError(status)); + return !status; } -static BOOL import_bcrypt_pubkey(PCERT_PUBLIC_KEY_INFO pubKeyInfo, BCRYPT_KEY_HANDLE *key) +static BOOL CNG_ImportPubKey(CERT_PUBLIC_KEY_INFO *pubKeyInfo, BCRYPT_KEY_HANDLE *key) { if (!strcmp(pubKeyInfo->Algorithm.pszObjId, szOID_ECC_PUBLIC_KEY)) - return import_bcrypt_pubkey_ecc(pubKeyInfo, key); + return CNG_ImportECCPubKey(pubKeyInfo, key); FIXME("Unsupported public key type: %s\n", debugstr_a(pubKeyInfo->Algorithm.pszObjId)); SetLastError(NTE_BAD_ALGID); return FALSE; } -static BOOL prepare_bcrypt_signature_ecc(BYTE *encoded_sig, DWORD encoded_size, - BYTE **sig_value, DWORD *sig_len) +static BOOL CNG_PrepareSignatureECC(BYTE *encoded_sig, DWORD encoded_size, BYTE **sig_value, DWORD *sig_len) { CERT_ECC_SIGNATURE *ecc_sig; DWORD size; int i; - if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_ECC_SIGNATURE, - encoded_sig, encoded_size, - CRYPT_DECODE_ALLOC_FLAG, NULL, &ecc_sig, &size)) + if (!CryptDecodeObjectEx(X509_ASN_ENCODING, X509_ECC_SIGNATURE, encoded_sig, encoded_size, + CRYPT_DECODE_ALLOC_FLAG, NULL, &ecc_sig, &size)) return FALSE; if (!ecc_sig->r.cbData || !ecc_sig->s.cbData) @@ -2621,8 +2605,8 @@ static BOOL prepare_bcrypt_signature_ecc(BYTE *encoded_sig, DWORD encoded_size, return TRUE; } -static BOOL prepare_bcrypt_signature(PCERT_PUBLIC_KEY_INFO pubKeyInfo, - const CERT_SIGNED_CONTENT_INFO *signedCert, BYTE **sig_value, DWORD *sig_len) +static BOOL CNG_PrepareSignature(CERT_PUBLIC_KEY_INFO *pubKeyInfo, const CERT_SIGNED_CONTENT_INFO *signedCert, + BYTE **sig_value, DWORD *sig_len) { BYTE *encoded_sig; BOOL ret = FALSE; @@ -2644,7 +2628,7 @@ static BOOL prepare_bcrypt_signature(PCERT_PUBLIC_KEY_INFO pubKeyInfo, encoded_sig[i] = signedCert->Signature.pbData[signedCert->Signature.cbData - i - 1]; if (!strcmp(pubKeyInfo->Algorithm.pszObjId, szOID_ECC_PUBLIC_KEY)) - ret = prepare_bcrypt_signature_ecc(encoded_sig, signedCert->Signature.cbData, sig_value, sig_len); + ret = CNG_PrepareSignatureECC(encoded_sig, signedCert->Signature.cbData, sig_value, sig_len); else { FIXME("Unsupported public key type: %s\n", debugstr_a(pubKeyInfo->Algorithm.pszObjId)); @@ -2655,55 +2639,47 @@ static BOOL prepare_bcrypt_signature(PCERT_PUBLIC_KEY_INFO pubKeyInfo, return ret; } -static BOOL verify_signature_bcrypt(HCRYPTPROV_LEGACY hCryptProv, - DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pubKeyInfo, - const CERT_SIGNED_CONTENT_INFO *signedCert, PCCRYPT_OID_INFO info) +static BOOL CNG_VerifySignature(HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType, + CERT_PUBLIC_KEY_INFO *pubKeyInfo, const CERT_SIGNED_CONTENT_INFO *signedCert, const CRYPT_OID_INFO *info) { BCRYPT_KEY_HANDLE key = NULL; - BYTE *hash_value, *sig_value; + BYTE *hash_value = NULL, *sig_value; DWORD hash_len, sig_len; NTSTATUS status; + BOOL ret; - if (!calculate_hash_bcrypt(info->pwszCNGAlgid, signedCert, &hash_value, &hash_len)) - return FALSE; - - if (!import_bcrypt_pubkey(pubKeyInfo, &key)) - { - CryptMemFree(hash_value); - return FALSE; - } - - if (!prepare_bcrypt_signature(pubKeyInfo, signedCert, &sig_value, &sig_len)) + ret = CNG_ImportPubKey(pubKeyInfo, &key); + if (ret) { - CryptMemFree(hash_value); + ret = CNG_CalcHash(info->pwszCNGAlgid, signedCert, &hash_value, &hash_len); + if (ret) + { + ret = CNG_PrepareSignature(pubKeyInfo, signedCert, &sig_value, &sig_len); + if (ret) + { + status = BCryptVerifySignature(key, NULL, hash_value, hash_len, sig_value, sig_len, 0); + if (status) + { + FIXME("Failed to verify signature: %08x\n", status); + SetLastError(RtlNtStatusToDosError(status)); + ret = FALSE; + } + CryptMemFree(sig_value); + } + CryptMemFree(hash_value); + } BCryptDestroyKey(key); - return FALSE; - } - - status = BCryptVerifySignature(key, NULL, hash_value, hash_len, sig_value, sig_len, 0); - - BCryptDestroyKey(key); - CryptMemFree(hash_value); - CryptMemFree(sig_value); - - if (status) - { - FIXME("Failed to verify signature: %08x\n", status); - SetLastError(RtlNtStatusToDosError(status)); - return FALSE; } - return TRUE; + return ret; } -static BOOL CRYPT_VerifyCertSignatureFromPublicKeyInfo(HCRYPTPROV_LEGACY hCryptProv, - DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pubKeyInfo, - const CERT_SIGNED_CONTENT_INFO *signedCert) +static BOOL CRYPT_VerifyCertSignatureFromPublicKeyInfo(HCRYPTPROV_LEGACY hCryptProv, DWORD dwCertEncodingType, + CERT_PUBLIC_KEY_INFO *pubKeyInfo, const CERT_SIGNED_CONTENT_INFO *signedCert) { - PCCRYPT_OID_INFO info; + CCRYPT_OID_INFO *info; - info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, - signedCert->SignatureAlgorithm.pszObjId, 0); + info = CryptFindOIDInfo(CRYPT_OID_INFO_OID_KEY, signedCert->SignatureAlgorithm.pszObjId, 0); if (!info || info->dwGroupId != CRYPT_SIGN_ALG_OID_GROUP_ID) { SetLastError(NTE_BAD_ALGID); @@ -2711,9 +2687,9 @@ static BOOL CRYPT_VerifyCertSignatureFromPublicKeyInfo(HCRYPTPROV_LEGACY hCryptP } if (info->u.Algid == CALG_OID_INFO_CNG_ONLY) - return verify_signature_bcrypt(hCryptProv, dwCertEncodingType, pubKeyInfo, signedCert, info); + return CNG_VerifySignature(hCryptProv, dwCertEncodingType, pubKeyInfo, signedCert, info); else - return verify_signature_crypt(hCryptProv, dwCertEncodingType, pubKeyInfo, signedCert, info); + return CRYPT_VerifySignature(hCryptProv, dwCertEncodingType, pubKeyInfo, signedCert, info); } BOOL WINAPI CryptVerifyCertificateSignatureEx(HCRYPTPROV_LEGACY hCryptProv, diff --git a/dll/win32/crypt32/chain.c b/dll/win32/crypt32/chain.c index 89a8ddb95f..41c87b7ae7 100644 --- a/dll/win32/crypt32/chain.c +++ b/dll/win32/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; @@ -265,10 +265,10 @@ typedef struct _CertificateChain LONG ref; } CertificateChain; -BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert, DWORD *type) +DWORD CRYPT_IsCertificateSelfSigned(const CERT_CONTEXT *cert) { + DWORD size, status = 0; PCERT_EXTENSION ext; - DWORD size; BOOL ret; if ((ext = CertFindExtension(szOID_AUTHORITY_KEY_IDENTIFIER2, @@ -296,11 +296,9 @@ BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert, DWORD *type) &info->AuthorityCertIssuer.rgAltEntry[i]; if (directoryName) { - ret = CertCompareCertificateName(cert->dwCertEncodingType, - &directoryName->u.DirectoryName, &cert->pCertInfo->Issuer) - && CertCompareIntegerBlob(&info->AuthorityCertSerialNumber, - &cert->pCertInfo->SerialNumber); - if (type) *type = CERT_TRUST_HAS_NAME_MATCH_ISSUER; + if (CertCompareCertificateName(cert->dwCertEncodingType, &directoryName->u.DirectoryName, &cert->pCertInfo->Issuer) + && CertCompareIntegerBlob(&info->AuthorityCertSerialNumber, &cert->pCertInfo->SerialNumber)) + status = CERT_TRUST_HAS_NAME_MATCH_ISSUER; } else { @@ -318,17 +316,12 @@ BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert, DWORD *type) if (buf) { - CertGetCertificateContextProperty(cert, - CERT_KEY_IDENTIFIER_PROP_ID, buf, &size); - ret = !memcmp(buf, info->KeyId.pbData, size); + CertGetCertificateContextProperty(cert, CERT_KEY_IDENTIFIER_PROP_ID, buf, &size); + if (!memcmp(buf, info->KeyId.pbData, size)) + status = CERT_TRUST_HAS_KEY_MATCH_ISSUER; CryptMemFree(buf); - if (type) *type = CERT_TRUST_HAS_KEY_MATCH_ISSUER; } - else - ret = FALSE; } - else - ret = FALSE; } LocalFree(info); } @@ -346,11 +339,9 @@ BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert, DWORD *type) { if (info->CertIssuer.cbData && info->CertSerialNumber.cbData) { - ret = CertCompareCertificateName(cert->dwCertEncodingType, - &info->CertIssuer, &cert->pCertInfo->Issuer) && - CertCompareIntegerBlob(&info->CertSerialNumber, - &cert->pCertInfo->SerialNumber); - if (type) *type = CERT_TRUST_HAS_NAME_MATCH_ISSUER; + if (CertCompareCertificateName(cert->dwCertEncodingType, &info->CertIssuer, &cert->pCertInfo->Issuer) + && CertCompareIntegerBlob(&info->CertSerialNumber, &cert->pCertInfo->SerialNumber)) + status = CERT_TRUST_HAS_NAME_MATCH_ISSUER; } else if (info->KeyId.cbData) { @@ -364,28 +355,23 @@ BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert, DWORD *type) { CertGetCertificateContextProperty(cert, CERT_KEY_IDENTIFIER_PROP_ID, buf, &size); - ret = !memcmp(buf, info->KeyId.pbData, size); + if (!memcmp(buf, info->KeyId.pbData, size)) + status = CERT_TRUST_HAS_KEY_MATCH_ISSUER; CryptMemFree(buf); - if (type) *type = CERT_TRUST_HAS_KEY_MATCH_ISSUER; } - else - ret = FALSE; } - else - ret = FALSE; } - else - ret = FALSE; LocalFree(info); } } else - { - ret = CertCompareCertificateName(cert->dwCertEncodingType, - &cert->pCertInfo->Subject, &cert->pCertInfo->Issuer); - if (type) *type = CERT_TRUST_HAS_NAME_MATCH_ISSUER; - } - return ret; + if (CertCompareCertificateName(cert->dwCertEncodingType, &cert->pCertInfo->Subject, &cert->pCertInfo->Issuer)) + status = CERT_TRUST_HAS_NAME_MATCH_ISSUER; + + if (status) + status |= CERT_TRUST_IS_SELF_SIGNED; + + return status; } static void CRYPT_FreeChainElement(PCERT_CHAIN_ELEMENT element) @@ -745,8 +731,7 @@ static BOOL url_matches(LPCWSTR constraint, LPCWSTR name, /* Ignore any path or query portion of the URL. */ if (*authority_end) { - if (authority_end - name < sizeof(hostname_buf) / - sizeof(hostname_buf[0])) + if (authority_end - name < ARRAY_SIZE(hostname_buf)) { memcpy(hostname_buf, name, (authority_end - name) * sizeof(WCHAR)); @@ -1327,7 +1312,7 @@ static void CRYPT_CheckChainNameConstraints(PCERT_SIMPLE_CHAIN chain) * constraints checked unless they're the end cert. */ if (j == 0 || !CRYPT_IsCertificateSelfSigned( - chain->rgpElement[j]->pCertContext, NULL)) + chain->rgpElement[j]->pCertContext)) { CRYPT_CheckNameConstraints(nameConstraints, chain->rgpElement[j]->pCertContext->pCertInfo, @@ -1695,11 +1680,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); } @@ -1900,7 +1883,7 @@ static void CRYPT_CheckSimpleChain(CertificateChainEngine *engine, int i; BOOL pathLengthConstraintViolated = FALSE; CERT_BASIC_CONSTRAINTS2_INFO constraints = { FALSE, FALSE, 0 }; - DWORD type; + DWORD status; TRACE_(chain)("checking chain with %d elements for time %s\n", chain->cElement, filetime_to_str(time)); @@ -1912,7 +1895,7 @@ static void CRYPT_CheckSimpleChain(CertificateChainEngine *engine, dump_element(chain->rgpElement[i]->pCertContext); if (i == chain->cElement - 1) isRoot = CRYPT_IsCertificateSelfSigned( - chain->rgpElement[i]->pCertContext, NULL); + chain->rgpElement[i]->pCertContext); else isRoot = FALSE; if (!CRYPT_IsCertVersionValid(chain->rgpElement[i]->pCertContext)) @@ -1988,10 +1971,9 @@ static void CRYPT_CheckSimpleChain(CertificateChainEngine *engine, } CRYPT_CheckChainNameConstraints(chain); CRYPT_CheckChainPolicies(chain); - if (CRYPT_IsCertificateSelfSigned(rootElement->pCertContext, &type)) + if ((status = CRYPT_IsCertificateSelfSigned(rootElement->pCertContext))) { - rootElement->TrustStatus.dwInfoStatus |= - CERT_TRUST_IS_SELF_SIGNED | type; + rootElement->TrustStatus.dwInfoStatus |= status; CRYPT_CheckRootCert(engine->hRoot, rootElement); } CRYPT_CombineTrustStatus(&chain->TrustStatus, &rootElement->TrustStatus); @@ -2203,7 +2185,7 @@ static BOOL CRYPT_BuildSimpleChain(const CertificateChainEngine *engine, PCCERT_CONTEXT cert = chain->rgpElement[chain->cElement - 1]->pCertContext; while (ret && !CRYPT_IsSimpleChainCyclic(chain) && - !CRYPT_IsCertificateSelfSigned(cert, NULL)) + !CRYPT_IsCertificateSelfSigned(cert)) { PCCERT_CONTEXT issuer = CRYPT_GetIssuer(engine, world, cert, NULL, flags, &chain->rgpElement[chain->cElement - 1]->TrustStatus.dwInfoStatus); @@ -2712,19 +2694,14 @@ static void CRYPT_VerifyChainRevocation(PCERT_CHAIN_CONTEXT chain, revocationPara.pIssuerCert = chain->rgpChain[i]->rgpElement[j + 1]->pCertContext; else - revocationPara.pIssuerCert = certToCheck; - + revocationPara.pIssuerCert = NULL; ret = CertVerifyRevocation(X509_ASN_ENCODING, CERT_CONTEXT_REVOCATION_TYPE, 1, (void **)&certToCheck, revocationFlags, &revocationPara, &revocationStatus); - if (!ret && revocationStatus.dwError == CRYPT_E_NO_REVOCATION_CHECK && - revocationPara.pIssuerCert == certToCheck) - { - FIXME("Unable to find CRL for CA certificate\n"); + if (!ret && chainFlags & CERT_CHAIN_REVOCATION_CHECK_CHAIN + && revocationStatus.dwError == CRYPT_E_NO_REVOCATION_CHECK && revocationPara.pIssuerCert == NULL) ret = TRUE; - revocationStatus.dwError = 0; - } if (!ret) { @@ -3135,8 +3112,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; @@ -3426,7 +3402,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)); @@ -3708,8 +3684,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/dll/win32/crypt32/crypt32_private.h b/dll/win32/crypt32/crypt32_private.h index 5c08369f00..e58db989b7 100644 --- a/dll/win32/crypt32/crypt32_private.h +++ b/dll/win32/crypt32/crypt32_private.h @@ -341,7 +341,7 @@ void CRYPT_ImportSystemRootCertsToReg(void) DECLSPEC_HIDDEN; BOOL CRYPT_SerializeContextsToReg(HKEY key, DWORD flags, const WINE_CONTEXT_INTERFACE *contextInterface, HCERTSTORE memStore) DECLSPEC_HIDDEN; -BOOL CRYPT_IsCertificateSelfSigned(PCCERT_CONTEXT cert, DWORD *type) DECLSPEC_HIDDEN; +DWORD CRYPT_IsCertificateSelfSigned(const CERT_CONTEXT *cert) DECLSPEC_HIDDEN; /* Allocates and initializes a certificate chain engine, but without creating * the root store. Instead, it uses root, and assumes the caller has done any diff --git a/dll/win32/crypt32/decode.c b/dll/win32/crypt32/decode.c index cc028a9090..f77393eced 100644 --- a/dll/win32/crypt32/decode.c +++ b/dll/win32/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; @@ -5754,7 +5751,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; @@ -5854,7 +5851,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); @@ -5887,7 +5884,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); @@ -5944,7 +5941,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); @@ -5972,7 +5969,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); @@ -5981,7 +5978,7 @@ BOOL CRYPT_AsnDecodePKCSEnvelopedData(const BYTE *pbEncoded, DWORD cbEncoded, static BOOL WINAPI CRYPT_AsnDecodeObjectIdentifier(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, - PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) + CRYPT_DECODE_PARA *pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { DWORD bytesNeeded = 0; BOOL ret; @@ -6021,7 +6018,7 @@ static BOOL WINAPI CRYPT_AsnDecodeObjectIdentifier(DWORD dwCertEncodingType, static BOOL WINAPI CRYPT_AsnDecodeEccSignature(DWORD dwCertEncodingType, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, DWORD dwFlags, - PCRYPT_DECODE_PARA pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) + CRYPT_DECODE_PARA *pDecodePara, void *pvStructInfo, DWORD *pcbStructInfo) { BOOL ret; struct AsnDecodeSequenceItem items[] = { @@ -6035,7 +6032,7 @@ static BOOL WINAPI CRYPT_AsnDecodeEccSignature(DWORD dwCertEncodingType, __TRY { - ret = CRYPT_AsnDecodeSequence(items, sizeof(items) / sizeof(items[0]), + ret = CRYPT_AsnDecodeSequence(items, ARRAY_SIZE(items), pbEncoded, cbEncoded, dwFlags, pDecodePara, pvStructInfo, pcbStructInfo, NULL, NULL); } diff --git a/dll/win32/crypt32/encode.c b/dll/win32/crypt32/encode.c index 6f9f595f4f..62d2bc91f7 100644 --- a/dll/win32/crypt32/encode.c +++ b/dll/win32/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/dll/win32/crypt32/filestore.c b/dll/win32/crypt32/filestore.c index 0f7d8d5150..9c211e14b1 100644 --- a/dll/win32/crypt32/filestore.c +++ b/dll/win32/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/dll/win32/crypt32/main.c b/dll/win32/crypt32/main.c index c03c092edd..79a0ce1fd3 100644 --- a/dll/win32/crypt32/main.c +++ b/dll/win32/crypt32/main.c @@ -252,7 +252,8 @@ ASN1encoding_t WINAPI I_CryptGetAsn1Encoder(HCRYPTASN1MODULE x) BOOL WINAPI CryptProtectMemory(void *data, DWORD len, DWORD flags) { - FIXME("(%p %u %08x): stub\n", data, len, flags); + static int fixme_once; + if (!fixme_once++) FIXME("(%p %u %08x): stub\n", data, len, flags); return TRUE; } diff --git a/dll/win32/crypt32/msg.c b/dll/win32/crypt32/msg.c index fd43a7baeb..005fbf2c1f 100644 --- a/dll/win32/crypt32/msg.c +++ b/dll/win32/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/dll/win32/crypt32/object.c b/dll/win32/crypt32/object.c index 0320cfda1b..3dc28af0e9 100644 --- a/dll/win32/crypt32/object.c +++ b/dll/win32/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/dll/win32/crypt32/oid.c b/dll/win32/crypt32/oid.c index 42d998a242..c9b0b412cf 100644 --- a/dll/win32/crypt32/oid.c +++ b/dll/win32/crypt32/oid.c @@ -70,7 +70,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) { @@ -1007,7 +1007,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); } @@ -1020,7 +1020,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)) { @@ -1129,16 +1129,14 @@ static const DWORD dssSign[2] = { CALG_DSS_SIGN, static const DWORD mosaicSign[2] = { CALG_DSS_SIGN, CRYPT_OID_INHIBIT_SIGNATURE_FORMAT_FLAG | CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG }; -static const DWORD ecdsaSign[2] = { CALG_OID_INFO_PARAMETERS, - CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG }; +static const DWORD ecdsaSign[2] = { CALG_OID_INFO_PARAMETERS, CRYPT_OID_NO_NULL_ALGORITHM_PARA_FLAG }; static const CRYPT_DATA_BLOB rsaSignBlob = { sizeof(rsaSign), (LPBYTE)&rsaSign }; static const CRYPT_DATA_BLOB dssSignBlob = { sizeof(dssSign), (LPBYTE)dssSign }; static const CRYPT_DATA_BLOB mosaicSignBlob = { sizeof(mosaicSign), (LPBYTE)mosaicSign }; -static const CRYPT_DATA_BLOB ecdsaSignBlob = { sizeof(ecdsaSign), - (LPBYTE)ecdsaSign }; +static const CRYPT_DATA_BLOB ecdsaSignBlob = { sizeof(ecdsaSign), (BYTE *)ecdsaSign }; static const DWORD ia5String[] = { CERT_RDN_IA5_STRING, 0 }; static const DWORD numericString[] = { CERT_RDN_NUMERIC_STRING, 0 }; @@ -1160,8 +1158,8 @@ static const struct OIDInfoConstructor { UINT Algid; LPCWSTR pwszName; const CRYPT_DATA_BLOB *blob; - LPCWSTR pwszCNGAlgid; - LPCWSTR pwszCNGExtraAlgid; + const WCHAR *pwszCNGAlgid; + const WCHAR *pwszCNGExtraAlgid; } oidInfoConstructors[] = { { 1, szOID_OIWSEC_sha1, CALG_SHA1, sha1, NULL }, { 1, szOID_OIWSEC_sha1, CALG_SHA1, sha, NULL }, @@ -1412,8 +1410,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/dll/win32/crypt32/regstore.c b/dll/win32/crypt32/regstore.c index 7678bab6aa..ce32a30f3b 100644 --- a/dll/win32/crypt32/regstore.c +++ b/dll/win32/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/dll/win32/crypt32/rootstore.c b/dll/win32/crypt32/rootstore.c index cdeec74341..6cf6ec1f16 100644 --- a/dll/win32/crypt32/rootstore.c +++ b/dll/win32/crypt32/rootstore.c @@ -931,7 +931,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()); @@ -981,9 +981,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/dll/win32/crypt32/sip.c b/dll/win32/crypt32/sip.c index b0c4692c1f..f51bceb460 100644 --- a/dll/win32/crypt32/sip.c +++ b/dll/win32/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/dll/win32/crypt32/store.c b/dll/win32/crypt32/store.c index bc4ebde5f6..2b8ea1d5d8 100644 --- a/dll/win32/crypt32/store.c +++ b/dll/win32/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/dll/win32/crypt32/str.c b/dll/win32/crypt32/str.c index 1daf29f8a0..4843c4f5f1 100644 --- a/dll/win32/crypt32/str.c +++ b/dll/win32/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, diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 5ec104f769..f102b5aa95 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -58,7 +58,7 @@ reactos/dll/win32/comctl32 # Synced to Wine-3.0 reactos/dll/win32/comdlg32 # Synced to WineStaging-3.17 reactos/dll/win32/compstui # Synced to WineStaging-3.3 reactos/dll/win32/credui # Synced to WineStaging-3.17 -reactos/dll/win32/crypt32 # Synced to WineStaging-3.9 +reactos/dll/win32/crypt32 # Synced to WineStaging-3.17 reactos/dll/win32/cryptdlg # Synced to WineStaging-3.3 reactos/dll/win32/cryptdll # Synced to WineStaging-3.3 reactos/dll/win32/cryptnet # Synced to WineStaging-3.3
6 years, 2 months
1
0
0
0
01/01: [CREDUI_WINETEST] Sync with Wine Staging 3.17. CORE-15127
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=156cac53d25ebea20b6e1…
commit 156cac53d25ebea20b6e111cdd53bb193dce0898 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Mon Oct 1 12:47:02 2018 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Mon Oct 1 12:47:02 2018 +0100 [CREDUI_WINETEST] Sync with Wine Staging 3.17. CORE-15127 --- modules/rostests/winetests/credui/credui.c | 35 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/modules/rostests/winetests/credui/credui.c b/modules/rostests/winetests/credui/credui.c index 01d657d580..13fbd41c07 100644 --- a/modules/rostests/winetests/credui/credui.c +++ b/modules/rostests/winetests/credui/credui.c @@ -58,20 +58,20 @@ static void test_CredUIPromptForCredentials(void) username[0] = '\0'; password[0] = '\0'; ret = CredUIPromptForCredentialsW(NULL, NULL, NULL, 0, username, - sizeof(username)/sizeof(username[0]), - password, sizeof(password)/sizeof(password[0]), + ARRAY_SIZE(username), + password, ARRAY_SIZE(password), NULL, CREDUI_FLAGS_ALWAYS_SHOW_UI); ok(ret == ERROR_INVALID_FLAGS, "CredUIPromptForCredentials should have returned ERROR_INVALID_FLAGS instead of %d\n", ret); ret = CredUIPromptForCredentialsW(NULL, NULL, NULL, 0, username, - sizeof(username)/sizeof(username[0]), - password, sizeof(password)/sizeof(password[0]), + ARRAY_SIZE(username), + password, ARRAY_SIZE(password), NULL, CREDUI_FLAGS_ALWAYS_SHOW_UI | CREDUI_FLAGS_GENERIC_CREDENTIALS); ok(ret == ERROR_INVALID_PARAMETER, "CredUIPromptForCredentials should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret); ret = CredUIPromptForCredentialsW(NULL, wszServerName, NULL, 0, username, - sizeof(username)/sizeof(username[0]), - password, sizeof(password)/sizeof(password[0]), + ARRAY_SIZE(username), + password, ARRAY_SIZE(password), NULL, CREDUI_FLAGS_SHOW_SAVE_CHECK_BOX); ok(ret == ERROR_INVALID_PARAMETER, "CredUIPromptForCredentials should have returned ERROR_INVALID_PARAMETER instead of %d\n", ret); @@ -86,8 +86,8 @@ static void test_CredUIPromptForCredentials(void) 'C','R','E','D','U','I','_','F','L','A','G','S','_','E','X','P','E','C','T','_','C','O','N','F','I','R','M','A','T','I','O','N',0}; ret = CredUIPromptForCredentialsW(NULL, wszServerName, NULL, 0, username, - sizeof(username)/sizeof(username[0]), - password, sizeof(password)/sizeof(password[0]), + ARRAY_SIZE(username), + password, ARRAY_SIZE(password), &save, CREDUI_FLAGS_EXPECT_CONFIRMATION); ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret); if (ret == ERROR_SUCCESS) @@ -97,10 +97,9 @@ static void test_CredUIPromptForCredentials(void) } credui_info.pszCaptionText = wszCaption1; - ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, - ERROR_ACCESS_DENIED, - username, sizeof(username)/sizeof(username[0]), - password, sizeof(password)/sizeof(password[0]), + ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, ERROR_ACCESS_DENIED, + username, ARRAY_SIZE(username), + password, ARRAY_SIZE(password), &save, CREDUI_FLAGS_EXPECT_CONFIRMATION); ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret); if (ret == ERROR_SUCCESS) @@ -111,8 +110,8 @@ static void test_CredUIPromptForCredentials(void) credui_info.pszCaptionText = wszCaption2; ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0, - username, sizeof(username)/sizeof(username[0]), - password, sizeof(password)/sizeof(password[0]), + username, ARRAY_SIZE(username), + password, ARRAY_SIZE(password), NULL, CREDUI_FLAGS_INCORRECT_PASSWORD|CREDUI_FLAGS_EXPECT_CONFIRMATION); ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret); if (ret == ERROR_SUCCESS) @@ -125,8 +124,8 @@ static void test_CredUIPromptForCredentials(void) save = TRUE; credui_info.pszCaptionText = wszCaption3; ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0, - username, sizeof(username)/sizeof(username[0]), - password, sizeof(password)/sizeof(password[0]), + username, ARRAY_SIZE(username), + password, ARRAY_SIZE(password), &save, CREDUI_FLAGS_DO_NOT_PERSIST|CREDUI_FLAGS_EXPECT_CONFIRMATION); ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret); ok(save, "save flag should have been untouched\n"); @@ -134,8 +133,8 @@ static void test_CredUIPromptForCredentials(void) save = FALSE; credui_info.pszCaptionText = wszCaption4; ret = CredUIPromptForCredentialsW(&credui_info, wszServerName, NULL, 0, - username, sizeof(username)/sizeof(username[0]), - password, sizeof(password)/sizeof(password[0]), + username, ARRAY_SIZE(username), + password, ARRAY_SIZE(password), &save, CREDUI_FLAGS_PERSIST|CREDUI_FLAGS_EXPECT_CONFIRMATION); ok(ret == ERROR_SUCCESS || ret == ERROR_CANCELLED, "CredUIPromptForCredentials failed with error %d\n", ret); ok(!save, "save flag should have been untouched\n");
6 years, 2 months
1
0
0
0
← Newer
1
...
32
33
34
35
36
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Results per page:
10
25
50
100
200