From 49ba2028824cd57aeaa80e1330627ec324948a19 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Thu, 19 Jan 2017 06:54:01 +0100 Subject: [PATCH] Added patch to fix return type of shlwapi.SHAddDataBlock. Also fixes parsing of multiline From: headers in staging/patchutils.py. --- patches/patchinstall.sh | 16 +++ ...x-the-return-value-of-SHAddDataBlock.patch | 132 ++++++++++++++++++ patches/shlwapi-SHAddDataBlock/definition | 1 + staging/patchutils.py | 22 +-- 4 files changed, 162 insertions(+), 9 deletions(-) create mode 100644 patches/shlwapi-SHAddDataBlock/0001-shlwapi-Fix-the-return-value-of-SHAddDataBlock.patch create mode 100644 patches/shlwapi-SHAddDataBlock/definition diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 931e5bc1..3f65d126 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -334,6 +334,7 @@ patch_enable_all () enable_shell32_Toolbar_Bitmaps="$1" enable_shell32_UnixFS="$1" enable_shlwapi_AssocGetPerceivedType="$1" + enable_shlwapi_SHAddDataBlock="$1" enable_shlwapi_SHMapHandle="$1" enable_shlwapi_UrlCombine="$1" enable_stdole32_idl_Typelib="$1" @@ -1213,6 +1214,9 @@ patch_enable () shlwapi-AssocGetPerceivedType) enable_shlwapi_AssocGetPerceivedType="$2" ;; + shlwapi-SHAddDataBlock) + enable_shlwapi_SHAddDataBlock="$2" + ;; shlwapi-SHMapHandle) enable_shlwapi_SHMapHandle="$2" ;; @@ -7167,6 +7171,18 @@ if test "$enable_shlwapi_AssocGetPerceivedType" -eq 1; then ) >> "$patchlist" fi +# Patchset shlwapi-SHAddDataBlock +# | +# | Modified files: +# | * dlls/shlwapi/clist.c, dlls/shlwapi/tests/clist.c +# | +if test "$enable_shlwapi_SHAddDataBlock" -eq 1; then + patch_apply shlwapi-SHAddDataBlock/0001-shlwapi-Fix-the-return-value-of-SHAddDataBlock.patch + ( + echo '+ { "Hermès BÉLUSCA-MAÏTO", "shlwapi: Fix the return value of SHAddDataBlock.", 1 },'; + ) >> "$patchlist" +fi + # Patchset shlwapi-SHMapHandle # | # | Modified files: diff --git a/patches/shlwapi-SHAddDataBlock/0001-shlwapi-Fix-the-return-value-of-SHAddDataBlock.patch b/patches/shlwapi-SHAddDataBlock/0001-shlwapi-Fix-the-return-value-of-SHAddDataBlock.patch new file mode 100644 index 00000000..a0710c12 --- /dev/null +++ b/patches/shlwapi-SHAddDataBlock/0001-shlwapi-Fix-the-return-value-of-SHAddDataBlock.patch @@ -0,0 +1,132 @@ +From 0cf3e133b7ab01d7d1facf955263bd9b8a0ed28e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Herm=C3=A8s=20B=C3=89LUSCA-MA=C3=8FTO?= + +Date: Tue, 17 Jan 2017 23:46:31 +0100 +Subject: shlwapi: Fix the return value of SHAddDataBlock + +This patch fixes the return type and value of SHAddDataBlock. +The corresponding test (shlwapi's clist) is adjusted to reflect +those changes. Tested on Windows 2003 and 7. + +In addition I set, in SHRemoveDataBlock, the lpList pointer +to NULL, to respect the fact it's a pointer, not just a number. + +Signed-off-by: Hermes Belusca-Maito +--- + dlls/shlwapi/clist.c | 14 +++++++------- + dlls/shlwapi/tests/clist.c | 21 +++++++++------------ + 2 files changed, 16 insertions(+), 19 deletions(-) + +diff --git a/dlls/shlwapi/clist.c b/dlls/shlwapi/clist.c +index 52bee37c9e4..77917b35469 100644 +--- a/dlls/shlwapi/clist.c ++++ b/dlls/shlwapi/clist.c +@@ -65,19 +65,19 @@ static inline LPDATABLOCK_HEADER NextItem(LPDBLIST lpList) + * the call returns S_OK but does not actually add the element. + * See SHWriteDataBlockList. + */ +-HRESULT WINAPI SHAddDataBlock(LPDBLIST* lppList, const DATABLOCK_HEADER *lpNewItem) ++BOOL WINAPI SHAddDataBlock(LPDBLIST* lppList, const DATABLOCK_HEADER *lpNewItem) + { + LPDATABLOCK_HEADER lpInsertAt = NULL; + ULONG ulSize; + + TRACE("(%p,%p)\n", lppList, lpNewItem); + +- if(!lppList || !lpNewItem ) +- return E_INVALIDARG; ++ if(!lppList || !lpNewItem) ++ return FALSE; + + if (lpNewItem->cbSize < sizeof(DATABLOCK_HEADER) || + lpNewItem->dwSignature == CLIST_ID_CONTAINER) +- return S_OK; ++ return FALSE; + + ulSize = lpNewItem->cbSize; + +@@ -134,9 +134,9 @@ HRESULT WINAPI SHAddDataBlock(LPDBLIST* lppList, const DATABLOCK_HEADER *lpNewIt + lpInsertAt = NextItem(lpInsertAt); + lpInsertAt->cbSize = 0; + +- return lpNewItem->cbSize; ++ return TRUE; + } +- return S_OK; ++ return FALSE; + } + + /************************************************************************* +@@ -354,7 +354,7 @@ VOID WINAPI SHFreeDataBlockList(LPDBLIST lpList) + */ + BOOL WINAPI SHRemoveDataBlock(LPDBLIST* lppList, DWORD dwSignature) + { +- LPDATABLOCK_HEADER lpList = 0; ++ LPDATABLOCK_HEADER lpList = NULL; + LPDATABLOCK_HEADER lpItem = NULL; + LPDATABLOCK_HEADER lpNext; + ULONG ulNewSize; +diff --git a/dlls/shlwapi/tests/clist.c b/dlls/shlwapi/tests/clist.c +index b930470806e..309b3335ec1 100644 +--- a/dlls/shlwapi/tests/clist.c ++++ b/dlls/shlwapi/tests/clist.c +@@ -218,7 +218,7 @@ static IStreamVtbl iclvt = + static HMODULE SHLWAPI_hshlwapi = 0; + + static VOID (WINAPI *pSHLWAPI_19)(LPSHLWAPI_CLIST); +-static HRESULT (WINAPI *pSHLWAPI_20)(LPSHLWAPI_CLIST*,LPCSHLWAPI_CLIST); ++static BOOL (WINAPI *pSHLWAPI_20)(LPSHLWAPI_CLIST*,LPCSHLWAPI_CLIST); + static BOOL (WINAPI *pSHLWAPI_21)(LPSHLWAPI_CLIST*,ULONG); + static LPSHLWAPI_CLIST (WINAPI *pSHLWAPI_22)(LPSHLWAPI_CLIST,ULONG); + static HRESULT (WINAPI *pSHLWAPI_17)(IStream*, SHLWAPI_CLIST*); +@@ -292,6 +292,7 @@ static void test_CList(void) + struct dummystream streamobj; + LPSHLWAPI_CLIST list = NULL; + LPCSHLWAPI_CLIST item = SHLWAPI_CLIST_items; ++ BOOL bRet; + HRESULT hRet; + LPSHLWAPI_CLIST inserted; + BYTE buff[64]; +@@ -312,10 +313,10 @@ static void test_CList(void) + buff[sizeof(SHLWAPI_CLIST)+i] = i*2; + + /* Add it */ +- hRet = pSHLWAPI_20(&list, inserted); +- ok(hRet > S_OK, "failed list add\n"); ++ bRet = pSHLWAPI_20(&list, inserted); ++ ok(bRet == TRUE, "failed list add\n"); + +- if (hRet > S_OK) ++ if (bRet == TRUE) + { + ok(list && list->ulSize, "item not added\n"); + +@@ -390,11 +391,8 @@ static void test_CList(void) + inserted = (LPSHLWAPI_CLIST)buff; + inserted->ulSize = sizeof(SHLWAPI_CLIST) -1; + inserted->ulId = 33; +- +- /* The call succeeds but the item is not inserted, except on some early +- * versions which return failure. Wine behaves like later versions. +- */ +- pSHLWAPI_20(&list, inserted); ++ bRet = pSHLWAPI_20(&list, inserted); ++ ok(bRet == FALSE, "Expected failure\n"); + + inserted = pSHLWAPI_22(list, 33); + ok(inserted == NULL, "inserted bad element size\n"); +@@ -402,9 +400,8 @@ static void test_CList(void) + inserted = (LPSHLWAPI_CLIST)buff; + inserted->ulSize = 44; + inserted->ulId = ~0U; +- +- /* See comment above, some early versions fail this call */ +- pSHLWAPI_20(&list, inserted); ++ bRet = pSHLWAPI_20(&list, inserted); ++ ok(bRet == FALSE, "Expected failure\n"); + + item = SHLWAPI_CLIST_items; + +-- +2.11.0 + diff --git a/patches/shlwapi-SHAddDataBlock/definition b/patches/shlwapi-SHAddDataBlock/definition new file mode 100644 index 00000000..693e563e --- /dev/null +++ b/patches/shlwapi-SHAddDataBlock/definition @@ -0,0 +1 @@ +Fixes: Fix return type of shlwapi.SHAddDataBlock diff --git a/staging/patchutils.py b/staging/patchutils.py index f454bfbe..ab37bdfc 100644 --- a/staging/patchutils.py +++ b/staging/patchutils.py @@ -135,6 +135,16 @@ class _PatchReader(object): tmp, self.peeked = self.peeked, None return tmp[1] + def read_multiline(self): + """Read multiline data from a patch file.""" + line = self.read().rstrip("\r\n") + while True: + tmp = self.peek() + if not tmp.startswith(" "): break + line += tmp.rstrip("\r\n") + self.read() + return line + def read_hunk(self): """Read one hunk from a patch file.""" line = self.peek() @@ -341,18 +351,12 @@ def read_patch(filename, fp=None): break elif line.startswith("From: "): - header['author'], header['email'] = _parse_author(line[6:]) + author = fp.read_multiline()[6:] + header['author'], header['email'] = _parse_author(author) header.pop('signedoffby', None) - fp.read() elif line.startswith("Subject: "): - subject = line[9:].rstrip("\r\n") - fp.read() - while True: - line = fp.peek() - if not line.startswith(" "): break - subject += line.rstrip("\r\n") - fp.read() + subject = fp.read_multiline()[9:] subject, revision = _parse_subject(subject) if not subject.endswith("."): subject += "." subject = re.sub('^([^:]*: *)([a-z])', lambda x: "%s%s" %