winehq.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
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
January 2019
----- 2025 -----
February 2025
January 2025
----- 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
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
499 discussions
Start a n
N
ew thread
Orhan Kavrakoğlu : crypt32/tests: Add tests for CryptHashCertificate2.
by Alexandre Julliard
29 Jan '19
29 Jan '19
Module: wine Branch: master Commit: 558cdd7a2b2985a2ab4a3a5e3a28876012e06797 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=558cdd7a2b2985a2ab4a3a5e…
Author: Orhan Kavrakoğlu <aibok42(a)gmail.com> Date: Tue Jan 29 08:17:19 2019 +0300 crypt32/tests: Add tests for CryptHashCertificate2. Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=46516
Signed-off-by: Orhan Kavrakoğlu <aibok42(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/crypt32/tests/cert.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/dlls/crypt32/tests/cert.c b/dlls/crypt32/tests/cert.c index f653741..e4f4c59 100644 --- a/dlls/crypt32/tests/cert.c +++ b/dlls/crypt32/tests/cert.c @@ -21,6 +21,8 @@ #include <stdio.h> #include <stdarg.h> +#include <ntstatus.h> +#define WIN32_NO_STATUS #include <windef.h> #include <winbase.h> #include <winreg.h> @@ -33,6 +35,7 @@ static PCCERT_CONTEXT (WINAPI *pCertCreateSelfSignCertificate)(HCRYPTPROV_OR_NCR static BOOL (WINAPI *pCertGetValidUsages)(DWORD,PCCERT_CONTEXT*,int*,LPSTR*,DWORD*); static BOOL (WINAPI *pCryptAcquireCertificatePrivateKey)(PCCERT_CONTEXT,DWORD,void*,HCRYPTPROV_OR_NCRYPT_KEY_HANDLE*,DWORD*,BOOL*); static BOOL (WINAPI *pCryptEncodeObjectEx)(DWORD,LPCSTR,const void*,DWORD,PCRYPT_ENCODE_PARA,void*,DWORD*); +static BOOL (WINAPI *pCryptHashCertificate2)(LPCWSTR, DWORD, void*, const BYTE*, DWORD, BYTE*, DWORD*); static BOOL (WINAPI * pCryptVerifyCertificateSignatureEx) (HCRYPTPROV, DWORD, DWORD, void *, DWORD, void *, DWORD, void *); @@ -53,6 +56,7 @@ static void init_function_pointers(void) GET_PROC(hCrypt32, CertGetValidUsages) GET_PROC(hCrypt32, CryptAcquireCertificatePrivateKey) GET_PROC(hCrypt32, CryptEncodeObjectEx) + GET_PROC(hCrypt32, CryptHashCertificate2) GET_PROC(hCrypt32, CryptVerifyCertificateSignatureEx) GET_PROC(hAdvapi32, CryptAcquireContextA) @@ -1784,6 +1788,80 @@ static void testCryptHashCert(void) ok(!memcmp(hash, knownHash, sizeof(knownHash)), "Unexpected hash\n"); } +static void testCryptHashCert2(void) +{ + static const BYTE emptyHash[] = { 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, + 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, + 0x09 }; + static const BYTE knownHash[] = { 0xae, 0x9d, 0xbf, 0x6d, 0xf5, 0x46, 0xee, + 0x8b, 0xc5, 0x7a, 0x13, 0xba, 0xc2, 0xb1, 0x04, 0xf2, 0xbf, 0x52, 0xa8, + 0xa2 }; + static const BYTE toHash[] = "abcdefghijklmnopqrstuvwxyz0123456789.,;!?:"; + BOOL ret; + BYTE hash[20]; + DWORD hashLen; + const WCHAR SHA1[] = { 'S', 'H', 'A', '1', '\0' }; + const WCHAR invalidAlgorithm[] = { '_', 'S', 'H', 'O', 'U', 'L', 'D', + 'N', 'O', 'T', + 'E', 'X', 'I', 'S', 'T', '_', '\0' }; + + if (!pCryptHashCertificate2) + { + win_skip("CryptHashCertificate2() is not available\n"); + return; + } + + /* Test empty hash */ + hashLen = sizeof(hash); + ret = pCryptHashCertificate2(SHA1, 0, NULL, NULL, 0, hash, &hashLen); + ok(ret, "CryptHashCertificate2 failed: %08x\n", GetLastError()); + ok(hashLen == sizeof(hash), "Got unexpected size of hash %d\n", hashLen); + ok(!memcmp(hash, emptyHash, sizeof(emptyHash)), "Unexpected hash of nothing\n"); + + /* Test known hash */ + hashLen = sizeof(hash); + ret = pCryptHashCertificate2(SHA1, 0, NULL, toHash, sizeof(toHash), hash, &hashLen); + ok(ret, "CryptHashCertificate2 failed: %08x\n", GetLastError()); + ok(hashLen == sizeof(hash), "Got unexpected size of hash %d\n", hashLen); + ok(!memcmp(hash, knownHash, sizeof(knownHash)), "Unexpected hash\n"); + + /* Test null hash size pointer just sets hash size */ + hashLen = 0; + ret = pCryptHashCertificate2(SHA1, 0, NULL, toHash, sizeof(toHash), NULL, &hashLen); + ok(ret, "CryptHashCertificate2 failed: %08x\n", GetLastError()); + ok(hashLen == sizeof(hash), "Hash size not set correctly (%d)\n", hashLen); + + /* Null algorithm ID crashes Windows implementations */ + if (0) { + /* Test null algorithm ID */ + hashLen = sizeof(hash); + ret = pCryptHashCertificate2(NULL, 0, NULL, toHash, sizeof(toHash), hash, &hashLen); + } + + /* Test invalid algorithm */ + hashLen = sizeof(hash); + SetLastError(0xdeadbeef); + ret = pCryptHashCertificate2(invalidAlgorithm, 0, NULL, toHash, sizeof(toHash), hash, &hashLen); + ok(!ret && GetLastError() == STATUS_NOT_FOUND, + "Expected STATUS_NOT_FOUND (0x%08x), got 0x%08x\n", STATUS_NOT_FOUND, GetLastError()); + + /* Test hash buffer too small */ + hashLen = sizeof(hash) / 2; + SetLastError(0xdeadbeef); + ret = pCryptHashCertificate2(SHA1, 0, NULL, toHash, sizeof(toHash), hash, &hashLen); + ok(!ret && GetLastError() == ERROR_MORE_DATA, + "Expected ERROR_MORE_DATA (%d), got %d\n", ERROR_MORE_DATA, GetLastError()); + + /* Null hash length crashes Windows implementations */ + if (0) { + /* Test hashLen null with hash */ + ret = pCryptHashCertificate2(SHA1, 0, NULL, toHash, sizeof(toHash), hash, NULL); + + /* Test hashLen null with no hash */ + ret = pCryptHashCertificate2(SHA1, 0, NULL, toHash, sizeof(toHash), NULL, NULL); + } +} + static void verifySig(HCRYPTPROV csp, const BYTE *toSign, size_t toSignLen, const BYTE *sig, unsigned int sigLen) { @@ -4074,6 +4152,7 @@ START_TEST(cert) testLinkCert(); testCryptHashCert(); + testCryptHashCert2(); testCertSigs(); testSignAndEncodeCert(); testCreateSelfSignCert();
1
0
0
0
Orhan Kavrakoğlu : crypt32: Implement CryptHashCertificate2.
by Alexandre Julliard
29 Jan '19
29 Jan '19
Module: wine Branch: master Commit: d3c606954b8ee341f5984d15fc9f9cb637fb557b URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d3c606954b8ee341f5984d15…
Author: Orhan Kavrakoğlu <aibok42(a)gmail.com> Date: Tue Jan 29 08:17:17 2019 +0300 crypt32: Implement CryptHashCertificate2. Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=46516
Signed-off-by: Orhan Kavrakoğlu <aibok42(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/crypt32/cert.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++ dlls/crypt32/crypt32.spec | 1 + include/wincrypt.h | 4 ++++ 3 files changed, 58 insertions(+) diff --git a/dlls/crypt32/cert.c b/dlls/crypt32/cert.c index eb646cd..f4cde69 100644 --- a/dlls/crypt32/cert.c +++ b/dlls/crypt32/cert.c @@ -2213,6 +2213,59 @@ BOOL WINAPI CryptHashCertificate(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, return ret; } +BOOL WINAPI CryptHashCertificate2(LPCWSTR pwszCNGHashAlgid, DWORD dwFlags, + void *pvReserved, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash, + DWORD *pcbComputedHash) +{ + BCRYPT_HASH_HANDLE hash = NULL; + BCRYPT_ALG_HANDLE alg = NULL; + NTSTATUS status; + DWORD hash_len; + DWORD hash_len_size; + + TRACE("(%s, %08x, %p, %p, %d, %p, %p)\n", debugstr_w(pwszCNGHashAlgid), + dwFlags, pvReserved, pbEncoded, cbEncoded, pbComputedHash, pcbComputedHash); + + if ((status = BCryptOpenAlgorithmProvider(&alg, pwszCNGHashAlgid, NULL, 0))) + { + if (status == STATUS_NOT_IMPLEMENTED) + status = STATUS_NOT_FOUND; + goto done; + } + + if ((status = BCryptCreateHash(alg, &hash, NULL, 0, NULL, 0, 0))) + goto done; + + if ((status = BCryptGetProperty(hash, BCRYPT_HASH_LENGTH, (BYTE *)&hash_len, sizeof(hash_len), &hash_len_size, 0))) + goto done; + + if (!pbComputedHash) + { + *pcbComputedHash = hash_len; + goto done; + } + + if (*pcbComputedHash < hash_len) + { + status = ERROR_MORE_DATA; + goto done; + } + + *pcbComputedHash = hash_len; + + if ((status = BCryptHashData(hash, (BYTE *)pbEncoded, cbEncoded, 0))) + goto done; + + if ((status = BCryptFinishHash(hash, pbComputedHash, hash_len, 0))) + goto done; + +done: + if (hash) BCryptDestroyHash(hash); + if (alg) BCryptCloseAlgorithmProvider(alg, 0); + if (status) SetLastError(status); + return !status; +} + BOOL WINAPI CryptHashPublicKeyInfo(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, DWORD dwFlags, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, BYTE *pbComputedHash, DWORD *pcbComputedHash) diff --git a/dlls/crypt32/crypt32.spec b/dlls/crypt32/crypt32.spec index 1815a1d..4399f7c 100644 --- a/dlls/crypt32/crypt32.spec +++ b/dlls/crypt32/crypt32.spec @@ -136,6 +136,7 @@ @ stdcall CryptGetOIDFunctionAddress(long long str long ptr ptr) @ stdcall CryptGetOIDFunctionValue(long str str wstr ptr ptr ptr) @ stdcall CryptHashCertificate(long long long ptr long ptr ptr) +@ stdcall CryptHashCertificate2(wstr long ptr ptr long ptr ptr) @ stdcall CryptHashMessage(ptr long long ptr ptr ptr ptr ptr ptr) @ stdcall CryptHashPublicKeyInfo(long long long long ptr ptr ptr) @ stdcall CryptHashToBeSigned(ptr long ptr long ptr ptr) diff --git a/include/wincrypt.h b/include/wincrypt.h index 5036ff5..8d9106e 100644 --- a/include/wincrypt.h +++ b/include/wincrypt.h @@ -4387,6 +4387,10 @@ BOOL WINAPI CryptHashCertificate(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, DWORD dwFlags, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash, DWORD *pcbComputedHash); +BOOL WINAPI CryptHashCertificate2(LPCWSTR pwszCNGHashAlgid, DWORD dwFlags, + void *pvReserved, const BYTE *pbEncoded, DWORD cbEncoded, BYTE *pbComputedHash, + DWORD *pcbComputedHash); + BOOL WINAPI CryptHashPublicKeyInfo(HCRYPTPROV_LEGACY hCryptProv, ALG_ID Algid, DWORD dwFlags, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, BYTE *pbComputedHash, DWORD *pcbComputedHash);
1
0
0
0
Zebediah Figura : msi: Don' t check the primary keys when handling MSIMODIFY_DELETE.
by Alexandre Julliard
29 Jan '19
29 Jan '19
Module: wine Branch: master Commit: 96b6d6b58725f17f3faabeeffe82d2b8bd5f0445 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=96b6d6b58725f17f3faabeef…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Mon Jan 28 22:11:12 2019 -0600 msi: Don't check the primary keys when handling MSIMODIFY_DELETE. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msi/table.c | 14 +------------- dlls/msi/tests/db.c | 1 + 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/dlls/msi/table.c b/dlls/msi/table.c index a2b83e2..57114ba 100644 --- a/dlls/msi/table.c +++ b/dlls/msi/table.c @@ -1835,18 +1835,6 @@ static UINT msi_table_assign(struct tagMSIVIEW *view, MSIRECORD *rec) return TABLE_insert_row( view, rec, -1, FALSE ); } -static UINT modify_delete_row( struct tagMSIVIEW *view, MSIRECORD *rec ) -{ - MSITABLEVIEW *tv = (MSITABLEVIEW *)view; - UINT row, r; - - r = msi_table_find_row(tv, rec, &row, NULL); - if (r != ERROR_SUCCESS) - return r; - - return TABLE_delete_row(view, row); -} - static UINT msi_refresh_record( struct tagMSIVIEW *view, MSIRECORD *rec, UINT row ) { MSIRECORD *curr; @@ -1878,7 +1866,7 @@ static UINT TABLE_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode, switch (eModifyMode) { case MSIMODIFY_DELETE: - r = modify_delete_row( view, rec ); + r = TABLE_delete_row( view, row ); break; case MSIMODIFY_VALIDATE_NEW: r = table_validate_new( tv, rec, &column ); diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c index cbdfd3c..e8ae8d2 100644 --- a/dlls/msi/tests/db.c +++ b/dlls/msi/tests/db.c @@ -5498,6 +5498,7 @@ static void test_viewmodify_delete(void) ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); /* delete 2 */ + MsiRecordSetInteger(hrec, 1, 4); r = MsiViewModify(hview, MSIMODIFY_DELETE, hrec); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
1
0
0
0
Zebediah Figura : msi: Implement MSIMODIFY_REFRESH using msi_view_refresh_row().
by Alexandre Julliard
29 Jan '19
29 Jan '19
Module: wine Branch: master Commit: 05976464556385e7a7ef5d04b2a56c4830ff33cf URL:
https://source.winehq.org/git/wine.git/?a=commit;h=05976464556385e7a7ef5d04…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Mon Jan 28 22:11:11 2019 -0600 msi: Implement MSIMODIFY_REFRESH using msi_view_refresh_row(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msi/query.h | 2 ++ dlls/msi/select.c | 15 ++++++++++----- dlls/msi/tests/db.c | 4 +++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/dlls/msi/query.h b/dlls/msi/query.h index d79c14f..c0144d3 100644 --- a/dlls/msi/query.h +++ b/dlls/msi/query.h @@ -153,4 +153,6 @@ UINT msi_create_table( MSIDATABASE *db, LPCWSTR name, column_info *col_info, UINT msi_select_update( MSIVIEW *view, MSIRECORD *rec, UINT row ) DECLSPEC_HIDDEN; +UINT msi_view_refresh_row( MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD *rec ) DECLSPEC_HIDDEN; + #endif /* __WINE_MSI_QUERY_H */ diff --git a/dlls/msi/select.c b/dlls/msi/select.c index ef16e5d..b38f339 100644 --- a/dlls/msi/select.c +++ b/dlls/msi/select.c @@ -276,20 +276,25 @@ UINT msi_select_update(MSIVIEW *view, MSIRECORD *rec, UINT row) return ERROR_SUCCESS; } -static UINT SELECT_modify( struct tagMSIVIEW *view, MSIMODIFY eModifyMode, +static UINT SELECT_modify( struct tagMSIVIEW *view, MSIMODIFY mode, MSIRECORD *rec, UINT row ) { MSISELECTVIEW *sv = (MSISELECTVIEW*)view; - TRACE("%p %d %p %d\n", sv, eModifyMode, rec, row ); + TRACE("view %p, mode %d, rec %p, row %u.\n", view, mode, rec, row); if( !sv->table ) return ERROR_FUNCTION_FAILED; - if (eModifyMode == MSIMODIFY_UPDATE) + switch (mode) + { + case MSIMODIFY_REFRESH: + return msi_view_refresh_row(sv->db, view, row, rec); + case MSIMODIFY_UPDATE: return msi_select_update(view, rec, row); - - return sv->table->ops->modify( sv->table, eModifyMode, rec, row ); + default: + return sv->table->ops->modify( sv->table, mode, rec, row ); + } } static UINT SELECT_delete( struct tagMSIVIEW *view ) diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c index 09ba4b8..cbdfd3c 100644 --- a/dlls/msi/tests/db.c +++ b/dlls/msi/tests/db.c @@ -3618,6 +3618,7 @@ static void test_join(void) r = MsiViewFetch(hview, &hrec); ok( r == ERROR_SUCCESS, "failed to fetch view: %d\n", r ); + check_record(hrec, 2, "alveolar", "procerus"); r = MsiRecordSetStringA( hrec, 1, "epicranius" ); ok( r == ERROR_SUCCESS, "failed to set string: %d\n", r ); @@ -3627,7 +3628,8 @@ static void test_join(void) /* try another valid operation for joins */ r = MsiViewModify(hview, MSIMODIFY_REFRESH, hrec); - todo_wine ok( r == ERROR_SUCCESS, "failed to refresh row: %d\n", r ); + ok( r == ERROR_SUCCESS, "failed to refresh row: %d\n", r ); + check_record(hrec, 2, "epicranius", "procerus"); /* try an invalid operation for joins */ r = MsiViewModify(hview, MSIMODIFY_DELETE, hrec);
1
0
0
0
Zebediah Figura : msi: Factor out msi_view_refresh_row().
by Alexandre Julliard
29 Jan '19
29 Jan '19
Module: wine Branch: master Commit: 31628cee6e2ba63a1a08672d89ccd8d10836bf7e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=31628cee6e2ba63a1a08672d…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Mon Jan 28 22:11:10 2019 -0600 msi: Factor out msi_view_refresh_row(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msi/msiquery.c | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/dlls/msi/msiquery.c b/dlls/msi/msiquery.c index 30c4f65..bea08c2 100644 --- a/dlls/msi/msiquery.c +++ b/dlls/msi/msiquery.c @@ -287,7 +287,7 @@ UINT WINAPI MsiDatabaseOpenViewW(MSIHANDLE hdb, return ret; } -UINT msi_view_get_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD **rec) +UINT msi_view_refresh_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD *rec) { UINT row_count = 0, col_count = 0, i, ival, ret, type; @@ -300,13 +300,6 @@ UINT msi_view_get_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD **rec) if (!col_count) return ERROR_INVALID_PARAMETER; - if (row >= row_count) - return ERROR_NO_MORE_ITEMS; - - *rec = MSI_CreateRecord(col_count); - if (!*rec) - return ERROR_FUNCTION_FAILED; - for (i = 1; i <= col_count; i++) { ret = view->ops->get_column_info(view, i, NULL, &type, NULL, NULL); @@ -323,7 +316,7 @@ UINT msi_view_get_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD **rec) ret = view->ops->fetch_stream(view, row, i, &stm); if ((ret == ERROR_SUCCESS) && stm) { - MSI_RecordSetIStream(*rec, i, stm); + MSI_RecordSetIStream(rec, i, stm); IStream_Release(stm); } else @@ -342,28 +335,48 @@ UINT msi_view_get_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD **rec) if (! (type & MSITYPE_VALID)) ERR("Invalid type!\n"); - /* check if it's nul (0) - if so, don't set anything */ - if (!ival) - continue; - if (type & MSITYPE_STRING) { int len; - const WCHAR *sval = msi_string_lookup( db->strings, ival, &len ); - msi_record_set_string( *rec, i, sval, len ); + const WCHAR *sval = msi_string_lookup(db->strings, ival, &len); + msi_record_set_string(rec, i, sval, len); } else { if ((type & MSI_DATASIZEMASK) == 2) - MSI_RecordSetInteger(*rec, i, ival - (1<<15)); + MSI_RecordSetInteger(rec, i, ival ? ival - (1<<15) : MSI_NULL_INTEGER); else - MSI_RecordSetInteger(*rec, i, ival - (1u<<31)); + MSI_RecordSetInteger(rec, i, ival - (1u<<31)); } } return ERROR_SUCCESS; } +UINT msi_view_get_row(MSIDATABASE *db, MSIVIEW *view, UINT row, MSIRECORD **rec) +{ + UINT row_count = 0, col_count = 0, r; + MSIRECORD *object; + + TRACE("view %p, row %u, rec %p.\n", view, row, rec); + + if ((r = view->ops->get_dimensions(view, &row_count, &col_count))) + return r; + + if (row >= row_count) + return ERROR_NO_MORE_ITEMS; + + if (!(object = MSI_CreateRecord( col_count ))) + return ERROR_OUTOFMEMORY; + + if ((r = msi_view_refresh_row(db, view, row, object))) + msiobj_release( &object->hdr ); + else + *rec = object; + + return r; +} + UINT MSI_ViewFetch(MSIQUERY *query, MSIRECORD **prec) { MSIVIEW *view;
1
0
0
0
Zebediah Figura : msi: Implement UPDATE queries using msi_select_update().
by Alexandre Julliard
29 Jan '19
29 Jan '19
Module: wine Branch: master Commit: 40a08f8362c191b51db07a483c4f41fa61158c76 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=40a08f8362c191b51db07a48…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Mon Jan 28 22:11:09 2019 -0600 msi: Implement UPDATE queries using msi_select_update(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msi/query.h | 2 ++ dlls/msi/select.c | 2 +- dlls/msi/update.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dlls/msi/query.h b/dlls/msi/query.h index 063fbb9..d79c14f 100644 --- a/dlls/msi/query.h +++ b/dlls/msi/query.h @@ -151,4 +151,6 @@ MSIRECORD *msi_query_merge_record( UINT fields, const column_info *vl, MSIRECORD UINT msi_create_table( MSIDATABASE *db, LPCWSTR name, column_info *col_info, MSICONDITION persistent ) DECLSPEC_HIDDEN; +UINT msi_select_update( MSIVIEW *view, MSIRECORD *rec, UINT row ) DECLSPEC_HIDDEN; + #endif /* __WINE_MSI_QUERY_H */ diff --git a/dlls/msi/select.c b/dlls/msi/select.c index 9d3d887..ef16e5d 100644 --- a/dlls/msi/select.c +++ b/dlls/msi/select.c @@ -230,7 +230,7 @@ static UINT SELECT_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *na type, temporary, table_name ); } -static UINT msi_select_update(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row) +UINT msi_select_update(MSIVIEW *view, MSIRECORD *rec, UINT row) { MSISELECTVIEW *sv = (MSISELECTVIEW*)view; UINT r, i, col, type, val; diff --git a/dlls/msi/update.c b/dlls/msi/update.c index e61342d..4aa0344 100644 --- a/dlls/msi/update.c +++ b/dlls/msi/update.c @@ -113,7 +113,7 @@ static UINT UPDATE_execute( struct tagMSIVIEW *view, MSIRECORD *record ) for ( i=0; i<row_count; i++ ) { - r = wv->ops->set_row( wv, i, values, (1 << col_count) - 1 ); + r = msi_select_update( wv, values, i ); if (r != ERROR_SUCCESS) break; }
1
0
0
0
Zebediah Figura : msi: Support setting streams in msi_select_update().
by Alexandre Julliard
29 Jan '19
29 Jan '19
Module: wine Branch: master Commit: 044c1dd23b307a0b7f2188855d5bf6e479cefd5e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=044c1dd23b307a0b7f218885…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Mon Jan 28 22:11:08 2019 -0600 msi: Support setting streams in msi_select_update(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msi/alter.c | 1 + dlls/msi/create.c | 1 + dlls/msi/delete.c | 1 + dlls/msi/distinct.c | 1 + dlls/msi/drop.c | 1 + dlls/msi/insert.c | 1 + dlls/msi/msipriv.h | 7 +++++++ dlls/msi/select.c | 7 +++++-- dlls/msi/storages.c | 41 +++++++++++++++++++++++++++++++++++++++++ dlls/msi/streams.c | 14 ++++++++++++++ dlls/msi/table.c | 17 +++++++++++++++++ dlls/msi/update.c | 1 + dlls/msi/where.c | 21 +++++++++++++++++++++ 13 files changed, 112 insertions(+), 2 deletions(-) diff --git a/dlls/msi/alter.c b/dlls/msi/alter.c index d1a481e..5c5893c 100644 --- a/dlls/msi/alter.c +++ b/dlls/msi/alter.c @@ -221,6 +221,7 @@ static const MSIVIEWOPS alter_ops = NULL, NULL, NULL, + NULL, ALTER_execute, ALTER_close, ALTER_get_dimensions, diff --git a/dlls/msi/create.c b/dlls/msi/create.c index 3c00b70..2777954 100644 --- a/dlls/msi/create.c +++ b/dlls/msi/create.c @@ -131,6 +131,7 @@ static const MSIVIEWOPS create_ops = NULL, NULL, NULL, + NULL, CREATE_execute, CREATE_close, CREATE_get_dimensions, diff --git a/dlls/msi/delete.c b/dlls/msi/delete.c index e2e0e34..81bd9d7 100644 --- a/dlls/msi/delete.c +++ b/dlls/msi/delete.c @@ -173,6 +173,7 @@ static const MSIVIEWOPS delete_ops = NULL, NULL, NULL, + NULL, DELETE_execute, DELETE_close, DELETE_get_dimensions, diff --git a/dlls/msi/distinct.c b/dlls/msi/distinct.c index 5bd5bf8..e102adb 100644 --- a/dlls/msi/distinct.c +++ b/dlls/msi/distinct.c @@ -256,6 +256,7 @@ static const MSIVIEWOPS distinct_ops = NULL, NULL, NULL, + NULL, DISTINCT_execute, DISTINCT_close, DISTINCT_get_dimensions, diff --git a/dlls/msi/drop.c b/dlls/msi/drop.c index 60a9202..89fac9d 100644 --- a/dlls/msi/drop.c +++ b/dlls/msi/drop.c @@ -101,6 +101,7 @@ static const MSIVIEWOPS drop_ops = NULL, NULL, NULL, + NULL, DROP_execute, DROP_close, DROP_get_dimensions, diff --git a/dlls/msi/insert.c b/dlls/msi/insert.c index ed913c0..f1185ee 100644 --- a/dlls/msi/insert.c +++ b/dlls/msi/insert.c @@ -327,6 +327,7 @@ static const MSIVIEWOPS insert_ops = NULL, NULL, NULL, + NULL, INSERT_execute, INSERT_close, INSERT_get_dimensions, diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 3ff5ac2..e4d2a62 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -257,6 +257,13 @@ typedef struct tagMSIVIEWOPS UINT (*set_string)( struct tagMSIVIEW *view, UINT row, UINT col, const WCHAR *val, int len ); /* + * set_stream - set the stream value at {row, col} + * This function has undefined behaviour if the column does not contain + * streams. + */ + UINT (*set_stream)( struct tagMSIVIEW *view, UINT row, UINT col, IStream *stream ); + + /* * set_row - sets values in a row as specified by mask * * Similar semantics to fetch_int diff --git a/dlls/msi/select.c b/dlls/msi/select.c index c6e7b20..9d3d887 100644 --- a/dlls/msi/select.c +++ b/dlls/msi/select.c @@ -234,6 +234,7 @@ static UINT msi_select_update(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row) { MSISELECTVIEW *sv = (MSISELECTVIEW*)view; UINT r, i, col, type, val; + IStream *stream; LPCWSTR str; for (i = 0; i < sv->num_cols; i++) @@ -249,8 +250,9 @@ static UINT msi_select_update(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row) if (MSITYPE_IS_BINARY(type)) { - ERR("Cannot modify binary data!\n"); - return ERROR_FUNCTION_FAILED; + if (MSI_RecordGetIStream(rec, i + 1, &stream)) + return ERROR_FUNCTION_FAILED; + r = sv->table->ops->set_stream(sv->table, row, col, stream); } else if (type & MSITYPE_STRING) { @@ -311,6 +313,7 @@ static const MSIVIEWOPS select_ops = SELECT_fetch_stream, NULL, NULL, + NULL, SELECT_set_row, SELECT_insert_row, NULL, diff --git a/dlls/msi/storages.c b/dlls/msi/storages.c index 76a0e2e..521b6e8 100644 --- a/dlls/msi/storages.c +++ b/dlls/msi/storages.c @@ -153,6 +153,46 @@ done: return hr; } +static UINT STORAGES_set_stream( MSIVIEW *view, UINT row, UINT col, IStream *stream ) +{ + MSISTORAGESVIEW *sv = (MSISTORAGESVIEW *)view; + IStorage *stg, *substg, *prev; + const WCHAR *name; + HRESULT hr; + UINT r; + + TRACE("view %p, row %u, col %u, stream %p.\n", view, row, col, stream); + + if ((r = stream_to_storage(stream, &stg))) + return r; + + name = msi_string_lookup(sv->db->strings, sv->storages[row].str_index, NULL); + + hr = IStorage_CreateStorage(sv->db->storage, name, + STGM_WRITE | STGM_SHARE_EXCLUSIVE, + 0, 0, &substg); + if (FAILED(hr)) + { + IStorage_Release(stg); + return ERROR_FUNCTION_FAILED; + } + + hr = IStorage_CopyTo(stg, 0, NULL, NULL, substg); + if (FAILED(hr)) + { + IStorage_Release(substg); + IStorage_Release(stg); + return ERROR_FUNCTION_FAILED; + } + IStorage_Release(substg); + + prev = sv->storages[row].storage; + sv->storages[row].storage = stg; + if (prev) IStorage_Release(prev); + + return ERROR_SUCCESS; +} + static UINT STORAGES_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask) { MSISTORAGESVIEW *sv = (MSISTORAGESVIEW *)view; @@ -404,6 +444,7 @@ static const MSIVIEWOPS storages_ops = STORAGES_fetch_stream, NULL, STORAGES_set_string, + STORAGES_set_stream, STORAGES_set_row, STORAGES_insert_row, STORAGES_delete_row, diff --git a/dlls/msi/streams.c b/dlls/msi/streams.c index 2d458ad..bc02fb2 100644 --- a/dlls/msi/streams.c +++ b/dlls/msi/streams.c @@ -110,6 +110,19 @@ static UINT STREAMS_set_string( struct tagMSIVIEW *view, UINT row, UINT col, con return ERROR_FUNCTION_FAILED; } +static UINT STREAMS_set_stream( MSIVIEW *view, UINT row, UINT col, IStream *stream ) +{ + MSISTREAMSVIEW *sv = (MSISTREAMSVIEW *)view; + IStream *prev; + + TRACE("view %p, row %u, col %u, stream %p.\n", view, row, col, stream); + + prev = sv->db->streams[row].stream; + IStream_AddRef(sv->db->streams[row].stream = stream); + if (prev) IStream_Release(prev); + return ERROR_SUCCESS; +} + static UINT STREAMS_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask) { MSISTREAMSVIEW *sv = (MSISTREAMSVIEW *)view; @@ -340,6 +353,7 @@ static const MSIVIEWOPS streams_ops = STREAMS_fetch_stream, NULL, STREAMS_set_string, + STREAMS_set_stream, STREAMS_set_row, STREAMS_insert_row, STREAMS_delete_row, diff --git a/dlls/msi/table.c b/dlls/msi/table.c index f26ab9f..a2b83e2 100644 --- a/dlls/msi/table.c +++ b/dlls/msi/table.c @@ -1357,6 +1357,22 @@ done: return r; } +static UINT TABLE_set_stream( MSIVIEW *view, UINT row, UINT col, IStream *stream ) +{ + MSITABLEVIEW *tv = (MSITABLEVIEW *)view; + WCHAR *name; + UINT r; + + TRACE("row %u, col %u, stream %p.\n", row, col, stream); + + if ((r = get_stream_name( tv, row - 1, &name ))) + return r; + + r = add_stream( tv->db, name, stream ); + msi_free( name ); + return r; +} + static UINT get_table_value_from_record( MSITABLEVIEW *tv, MSIRECORD *rec, UINT iField, UINT *pvalue ) { MSICOLUMNINFO columninfo; @@ -2126,6 +2142,7 @@ static const MSIVIEWOPS table_ops = TABLE_fetch_stream, TABLE_set_int, TABLE_set_string, + TABLE_set_stream, TABLE_set_row, TABLE_insert_row, TABLE_delete_row, diff --git a/dlls/msi/update.c b/dlls/msi/update.c index af629d2..e61342d 100644 --- a/dlls/msi/update.c +++ b/dlls/msi/update.c @@ -204,6 +204,7 @@ static const MSIVIEWOPS update_ops = NULL, NULL, NULL, + NULL, UPDATE_execute, UPDATE_close, UPDATE_get_dimensions, diff --git a/dlls/msi/where.c b/dlls/msi/where.c index eaadac4..66de85b 100644 --- a/dlls/msi/where.c +++ b/dlls/msi/where.c @@ -299,6 +299,26 @@ static UINT WHERE_set_string(struct tagMSIVIEW *view, UINT row, UINT col, const return table->view->ops->set_string(table->view, rows[table->table_index], col, val, len); } +static UINT WHERE_set_stream(MSIVIEW *view, UINT row, UINT col, IStream *stream) +{ + MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view; + JOINTABLE *table; + UINT *rows; + UINT r; + + TRACE("view %p, row %u, col %u, stream %p.\n", wv, row, col, stream); + + r = find_row(wv, row, &rows); + if (r != ERROR_SUCCESS) + return r; + + table = find_table(wv, col, &col); + if (!table) + return ERROR_FUNCTION_FAILED; + + return table->view->ops->set_stream(table->view, rows[table->table_index], col, stream); +} + static UINT WHERE_set_row( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask ) { MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view; @@ -1098,6 +1118,7 @@ static const MSIVIEWOPS where_ops = WHERE_fetch_stream, WHERE_set_int, WHERE_set_string, + WHERE_set_stream, WHERE_set_row, NULL, WHERE_delete_row,
1
0
0
0
Hans Leidekker : crypt32: Initial implementation of PFXImportCertStore.
by Alexandre Julliard
29 Jan '19
29 Jan '19
Module: wine Branch: master Commit: 226fd5cb2345f65f520e765251706b6ea83802e4 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=226fd5cb2345f65f520e7652…
Author: Hans Leidekker <hans(a)codeweavers.com> Date: Mon Jan 28 15:38:38 2019 +0100 crypt32: Initial implementation of PFXImportCertStore. Signed-off-by: Hans Leidekker <hans(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/crypt32/Makefile.in | 2 + dlls/crypt32/crypt32_private.h | 3 + dlls/crypt32/decode.c | 14 --- dlls/crypt32/encode.c | 14 --- dlls/crypt32/main.c | 6 + dlls/crypt32/pfx.c | 238 +++++++++++++++++++++++++++++++++++++ dlls/crypt32/tests/store.c | 264 +++++++++++++++++++++++++++++++++++++++++ include/wincrypt.h | 12 +- 8 files changed, 523 insertions(+), 30 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=226fd5cb2345f65f520e…
1
0
0
0
Nikolay Sivov : dwrite: Validate 'VDMX' data before using it.
by Alexandre Julliard
29 Jan '19
29 Jan '19
Module: wine Branch: master Commit: 2ca9aa16b2e68cc3e4bfa4fe45c6676a6aed0b89 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=2ca9aa16b2e68cc3e4bfa4fe…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Tue Jan 29 10:06:45 2019 +0300 dwrite: Validate 'VDMX' data before using it. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dwrite/dwrite_private.h | 3 +- dlls/dwrite/font.c | 5 +-- dlls/dwrite/opentype.c | 82 ++++++++++++++++++++++++++------------------ 3 files changed, 54 insertions(+), 36 deletions(-) diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 2d20b41..3595503 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -229,7 +229,8 @@ extern HRESULT opentype_get_font_info_strings(const void*,DWRITE_INFORMATIONAL_S extern HRESULT opentype_get_font_familyname(struct file_stream_desc*,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN; extern HRESULT opentype_get_font_facename(struct file_stream_desc*,WCHAR*,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN; extern HRESULT opentype_get_typographic_features(IDWriteFontFace*,UINT32,UINT32,UINT32,UINT32*,DWRITE_FONT_FEATURE_TAG*) DECLSPEC_HIDDEN; -extern BOOL opentype_get_vdmx_size(const void*,INT,UINT16*,UINT16*) DECLSPEC_HIDDEN; +extern BOOL opentype_get_vdmx_size(const struct dwrite_fonttable *table, INT ppem, UINT16 *ascent, + UINT16 *descent) DECLSPEC_HIDDEN; extern unsigned int opentype_get_cpal_palettecount(const struct dwrite_fonttable *table) DECLSPEC_HIDDEN; extern unsigned int opentype_get_cpal_paletteentrycount(const struct dwrite_fonttable *table) DECLSPEC_HIDDEN; extern HRESULT opentype_get_cpal_entries(const struct dwrite_fonttable *table, unsigned int palette, diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 372578e..d1e4fb9 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -374,9 +374,10 @@ static FLOAT get_font_prop_vec_dotproduct(const struct dwrite_font_propvec *left return left->stretch * right->stretch + left->style * right->style + left->weight * right->weight; } -static const void* get_fontface_vdmx(struct dwrite_fontface *fontface) +static const struct dwrite_fonttable *get_fontface_vdmx(struct dwrite_fontface *fontface) { - return get_fontface_table(&fontface->IDWriteFontFace4_iface, MS_VDMX_TAG, &fontface->vdmx); + get_fontface_table(&fontface->IDWriteFontFace4_iface, MS_VDMX_TAG, &fontface->vdmx); + return &fontface->vdmx; } static const struct dwrite_fonttable *get_fontface_gasp(struct dwrite_fontface *fontface) diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c index 35cf838..f92febd 100644 --- a/dlls/dwrite/opentype.c +++ b/dlls/dwrite/opentype.c @@ -343,14 +343,14 @@ typedef struct { TT_NameRecord nameRecord[1]; } TT_NAME_V0; -struct VDMX_Header +struct vdmx_header { WORD version; - WORD numRecs; - WORD numRatios; + WORD num_recs; + WORD num_ratios; }; -struct VDMX_Ratio +struct vdmx_ratio { BYTE bCharSet; BYTE xRatio; @@ -358,20 +358,21 @@ struct VDMX_Ratio BYTE yEndRatio; }; -struct VDMX_group -{ - WORD recs; - BYTE startsz; - BYTE endsz; -}; - -struct VDMX_vTable +struct vdmx_vtable { WORD yPelHeight; SHORT yMax; SHORT yMin; }; +struct vdmx_group +{ + WORD recs; + BYTE startsz; + BYTE endsz; + struct vdmx_vtable entries[1]; +}; + typedef struct { CHAR FeatureTag[4]; WORD Feature; @@ -1911,13 +1912,14 @@ HRESULT opentype_get_typographic_features(IDWriteFontFace *fontface, UINT32 scri return *count > max_tagcount ? E_NOT_SUFFICIENT_BUFFER : S_OK; } -static const struct VDMX_group *find_vdmx_group(const struct VDMX_Header *hdr) +static unsigned int find_vdmx_group(const struct vdmx_header *hdr) { - WORD num_ratios, i, group_offset = 0; - struct VDMX_Ratio *ratios = (struct VDMX_Ratio*)(hdr + 1); + WORD num_ratios, i; + const struct vdmx_ratio *ratios = (struct vdmx_ratio *)(hdr + 1); BYTE dev_x_ratio = 1, dev_y_ratio = 1; + unsigned int group_offset = 0; - num_ratios = GET_BE_WORD(hdr->numRatios); + num_ratios = GET_BE_WORD(hdr->num_ratios); for (i = 0; i < num_ratios; i++) { @@ -1932,42 +1934,56 @@ static const struct VDMX_group *find_vdmx_group(const struct VDMX_Header *hdr) break; } } - if (group_offset) - return (const struct VDMX_group *)((BYTE *)hdr + group_offset); - return NULL; + + return group_offset; } -BOOL opentype_get_vdmx_size(const void *data, INT emsize, UINT16 *ascent, UINT16 *descent) +BOOL opentype_get_vdmx_size(const struct dwrite_fonttable *vdmx, INT emsize, UINT16 *ascent, UINT16 *descent) { - const struct VDMX_Header *hdr = (const struct VDMX_Header*)data; - const struct VDMX_group *group; - const struct VDMX_vTable *tables; - WORD recs, i; + unsigned int num_ratios, num_recs, group_offset, i; + const struct vdmx_header *header; + const struct vdmx_group *group; + + if (!vdmx->exists) + return FALSE; + + num_ratios = table_read_be_word(vdmx, FIELD_OFFSET(struct vdmx_header, num_ratios)); + num_recs = table_read_be_word(vdmx, FIELD_OFFSET(struct vdmx_header, num_recs)); + + header = table_read_ensure(vdmx, 0, sizeof(*header) + num_ratios * sizeof(struct vdmx_ratio) + + num_recs * sizeof(*group)); + + if (!header) + return FALSE; - if (!data) + group_offset = find_vdmx_group(header); + if (!group_offset) return FALSE; - group = find_vdmx_group(hdr); + num_recs = table_read_be_word(vdmx, group_offset); + group = table_read_ensure(vdmx, group_offset, FIELD_OFFSET(struct vdmx_group, entries[num_recs])); + if (!group) return FALSE; - recs = GET_BE_WORD(group->recs); - if (emsize < group->startsz || emsize >= group->endsz) return FALSE; + if (emsize < group->startsz || emsize >= group->endsz) + return FALSE; - tables = (const struct VDMX_vTable *)(group + 1); - for (i = 0; i < recs; i++) { - WORD ppem = GET_BE_WORD(tables[i].yPelHeight); + for (i = 0; i < num_recs; ++i) + { + WORD ppem = GET_BE_WORD(group->entries[i].yPelHeight); if (ppem > emsize) { FIXME("interpolate %d\n", emsize); return FALSE; } if (ppem == emsize) { - *ascent = (SHORT)GET_BE_WORD(tables[i].yMax); - *descent = -(SHORT)GET_BE_WORD(tables[i].yMin); + *ascent = (SHORT)GET_BE_WORD(group->entries[i].yMax); + *descent = -(SHORT)GET_BE_WORD(group->entries[i].yMin); return TRUE; } } + return FALSE; }
1
0
0
0
Nikolay Sivov : dwrite: Validate 'sbix' data before using it.
by Alexandre Julliard
29 Jan '19
29 Jan '19
Module: wine Branch: master Commit: f73ba331c18577942a371b98a724f2a44f6565ca URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f73ba331c18577942a371b98…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Tue Jan 29 10:06:44 2019 +0300 dwrite: Validate 'sbix' data before using it. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dwrite/opentype.c | 125 +++++++++++++++++++++++++++---------------------- 1 file changed, 68 insertions(+), 57 deletions(-) diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c index 261d00c..35cf838 100644 --- a/dlls/dwrite/opentype.c +++ b/dlls/dwrite/opentype.c @@ -243,30 +243,34 @@ typedef struct { USHORT numberOfHMetrics; } TT_HHEA; -typedef struct { +struct sbix_header +{ WORD version; WORD flags; - DWORD numStrikes; - DWORD strikeOffset[1]; -} sbix_header; + DWORD num_strikes; + DWORD strike_offset[1]; +}; -typedef struct { +struct sbix_strike +{ WORD ppem; WORD ppi; - DWORD glyphDataOffsets[1]; -} sbix_strike; + DWORD glyphdata_offsets[1]; +}; -typedef struct { +struct sbix_glyph_data +{ WORD originOffsetX; WORD originOffsetY; - DWORD graphicType; + DWORD graphic_type; BYTE data[1]; -} sbix_glyph_data; +}; -typedef struct { +struct maxp +{ DWORD version; - WORD numGlyphs; -} maxp; + WORD num_glyphs; +}; struct cblc_header { @@ -2221,67 +2225,74 @@ static BOOL opentype_has_font_table(IDWriteFontFace4 *fontface, UINT32 tag) return exists; } -static DWORD opentype_get_sbix_formats(IDWriteFontFace4 *fontface) +static unsigned int opentype_get_sbix_formats(IDWriteFontFace4 *fontface) { - UINT32 size, s, num_strikes; - const sbix_header *header; - UINT16 g, num_glyphs; - BOOL exists = FALSE; - const maxp *maxp; - const void *data; - DWORD ret = 0; - void *context; - HRESULT hr; + unsigned int num_strikes, num_glyphs, i, j, ret = 0; + const struct sbix_header *sbix_header; + struct dwrite_fonttable table; - hr = IDWriteFontFace4_TryGetFontTable(fontface, MS_MAXP_TAG, &data, &size, &context, &exists); - if (FAILED(hr) || !exists) + memset(&table, 0, sizeof(table)); + table.exists = TRUE; + + if (!get_fontface_table(fontface, MS_MAXP_TAG, &table)) return 0; - maxp = data; - num_glyphs = GET_BE_WORD(maxp->numGlyphs); + num_glyphs = table_read_be_word(&table, FIELD_OFFSET(struct maxp, num_glyphs)); - IDWriteFontFace4_ReleaseFontTable(fontface, context); + IDWriteFontFace4_ReleaseFontTable(fontface, table.context); - if (FAILED(IDWriteFontFace4_TryGetFontTable(fontface, MS_SBIX_TAG, &data, &size, &context, &exists))) { - WARN("Failed to get 'sbix' table, %#x\n", hr); - return 0; - } + memset(&table, 0, sizeof(table)); + table.exists = TRUE; - header = data; - num_strikes = GET_BE_DWORD(header->numStrikes); + if (!get_fontface_table(fontface, MS_SBIX_TAG, &table)) + return 0; - for (s = 0; s < num_strikes; s++) { - sbix_strike *strike = (sbix_strike *)((BYTE *)header + GET_BE_DWORD(header->strikeOffset[s])); + num_strikes = table_read_be_dword(&table, FIELD_OFFSET(struct sbix_header, num_strikes)); + sbix_header = table_read_ensure(&table, 0, FIELD_OFFSET(struct sbix_header, strike_offset[num_strikes])); - for (g = 0; g < num_glyphs; g++) { - DWORD offset = GET_BE_DWORD(strike->glyphDataOffsets[g]); - DWORD offset_next = GET_BE_DWORD(strike->glyphDataOffsets[g + 1]); - sbix_glyph_data *glyph_data; - DWORD format; + if (sbix_header) + { + for (i = 0; i < num_strikes; ++i) + { + unsigned int strike_offset = GET_BE_DWORD(sbix_header->strike_offset[i]); + const struct sbix_strike *strike = table_read_ensure(&table, strike_offset, + FIELD_OFFSET(struct sbix_strike, glyphdata_offsets[num_glyphs + 1])); - if (offset == offset_next) + if (!strike) continue; - glyph_data = (sbix_glyph_data *)((BYTE *)strike + offset); - switch (format = glyph_data->graphicType) + for (j = 0; j < num_glyphs; j++) { - case MS_PNG__TAG: - ret |= DWRITE_GLYPH_IMAGE_FORMATS_PNG; - break; - case MS_JPG__TAG: - ret |= DWRITE_GLYPH_IMAGE_FORMATS_JPEG; - break; - case MS_TIFF_TAG: - ret |= DWRITE_GLYPH_IMAGE_FORMATS_TIFF; - break; - default: - format = GET_BE_DWORD(format); - FIXME("unexpected bitmap format %s\n", debugstr_an((char *)&format, 4)); + unsigned int offset = GET_BE_DWORD(strike->glyphdata_offsets[j]); + unsigned int next_offset = GET_BE_DWORD(strike->glyphdata_offsets[j + 1]); + const struct sbix_glyph_data *glyph_data; + + if (offset == next_offset) + continue; + + glyph_data = table_read_ensure(&table, strike_offset + offset, sizeof(*glyph_data)); + if (!glyph_data) + continue; + + switch (glyph_data->graphic_type) + { + case MS_PNG__TAG: + ret |= DWRITE_GLYPH_IMAGE_FORMATS_PNG; + break; + case MS_JPG__TAG: + ret |= DWRITE_GLYPH_IMAGE_FORMATS_JPEG; + break; + case MS_TIFF_TAG: + ret |= DWRITE_GLYPH_IMAGE_FORMATS_TIFF; + break; + default: + FIXME("unexpected bitmap format %s\n", debugstr_tag(GET_BE_DWORD(glyph_data->graphic_type))); + } } } } - IDWriteFontFace4_ReleaseFontTable(fontface, context); + IDWriteFontFace4_ReleaseFontTable(fontface, table.context); return ret; }
1
0
0
0
← Newer
1
...
7
8
9
10
11
12
13
...
50
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Results per page:
10
25
50
100
200