external/libcmis/0003-HttpSession-fix-regression-setting-wrong-type-of-CUR.patch
 |   81 ++++++++++
 external/libcmis/UnpackedTarball_libcmis.mk                                    
  |    1 
 2 files changed, 82 insertions(+)

New commits:
commit 584c01394ff06072b11ef4bd4bffb9e7f2d31e81
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Mon Nov 6 18:48:37 2023 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Tue Nov 7 10:10:54 2023 +0100

    libcmis: fix regression setting wrong type of CURLOPT_SEEKFUNCTION
    
    Change-Id: I45421bbe13626aa843380e77f589e793328f99d4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159010
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git 
a/external/libcmis/0003-HttpSession-fix-regression-setting-wrong-type-of-CUR.patch
 
b/external/libcmis/0003-HttpSession-fix-regression-setting-wrong-type-of-CUR.patch
new file mode 100644
index 000000000000..424fd9e0ea0f
--- /dev/null
+++ 
b/external/libcmis/0003-HttpSession-fix-regression-setting-wrong-type-of-CUR.patch
@@ -0,0 +1,81 @@
+From 3e6eb4cefd22498824247d91ab4c125deb3277da Mon Sep 17 00:00:00 2001
+From: Michael Stahl <michael.st...@allotropia.de>
+Date: Mon, 6 Nov 2023 18:41:37 +0100
+Subject: [PATCH 3/3] HttpSession: fix regression setting wrong type of
+ CURLOPT_SEEKFUNCTION
+
+(regression from commit 1b8a646b1d63bfa760d154dd7e51f6298d4a9899)
+---
+ src/libcmis/http-session.cxx | 28 +++++++++++++++++++++++++---
+ 1 file changed, 25 insertions(+), 3 deletions(-)
+
+diff --git a/src/libcmis/http-session.cxx b/src/libcmis/http-session.cxx
+index 8787c50..d7b1a5e 100644
+--- a/src/libcmis/http-session.cxx
++++ b/src/libcmis/http-session.cxx
+@@ -31,6 +31,7 @@
+ #include <cctype>
+ #include <memory>
+ #include <string>
++#include <assert.h>
+ 
+ #include <libxml/parser.h>
+ #include <libxml/tree.h>
+@@ -110,6 +111,27 @@ namespace
+         return errCode;
+     }
+ 
++    int lcl_seekStream(void* data, curl_off_t offset, int origin)
++    {
++        std::ios_base::seekdir dir = {};
++        switch (origin)
++        {
++            case SEEK_SET: dir = std::ios_base::beg; break;
++            case SEEK_CUR: dir = std::ios_base::cur; break;
++            case SEEK_END: dir = std::ios_base::end; break;
++            default: assert(false); break;
++        }
++        istream& is = *(static_cast<istream*>(data));
++        is.clear();
++        is.seekg(offset, dir);
++        if (!is.good())
++        {
++            fprintf(stderr, "rewind failed\n");
++            return CURL_SEEKFUNC_FAIL;
++        }
++        return CURL_SEEKFUNC_OK;
++    }
++
+     template<typename T>
+     class ScopeGuard
+     {
+@@ -328,7 +350,7 @@ libcmis::HttpResponsePtr HttpSession::httpPatchRequest( 
string url, istream& is,
+     curl_easy_setopt( m_curlHandle, CURLOPT_UPLOAD, 1 );
+     curl_easy_setopt( m_curlHandle, CURLOPT_CUSTOMREQUEST, "PATCH" );
+ #if (LIBCURL_VERSION_MAJOR > 7) || (LIBCURL_VERSION_MAJOR == 7 && 
LIBCURL_VERSION_MINOR >= 85)
+-    curl_easy_setopt( m_curlHandle, CURLOPT_SEEKFUNCTION, lcl_ioctlStream );
++    curl_easy_setopt( m_curlHandle, CURLOPT_SEEKFUNCTION, lcl_seekStream );
+     curl_easy_setopt( m_curlHandle, CURLOPT_SEEKDATA, &isOriginal );
+ #else
+     curl_easy_setopt( m_curlHandle, CURLOPT_IOCTLFUNCTION, lcl_ioctlStream );
+@@ -420,7 +442,7 @@ libcmis::HttpResponsePtr HttpSession::httpPutRequest( 
string url, istream& is, v
+     curl_easy_setopt( m_curlHandle, CURLOPT_READFUNCTION, lcl_readStream );
+     curl_easy_setopt( m_curlHandle, CURLOPT_UPLOAD, 1 );
+ #if (LIBCURL_VERSION_MAJOR > 7) || (LIBCURL_VERSION_MAJOR == 7 && 
LIBCURL_VERSION_MINOR >= 85)
+-    curl_easy_setopt( m_curlHandle, CURLOPT_SEEKFUNCTION, lcl_ioctlStream );
++    curl_easy_setopt( m_curlHandle, CURLOPT_SEEKFUNCTION, lcl_seekStream );
+     curl_easy_setopt( m_curlHandle, CURLOPT_SEEKDATA, &isOriginal );
+ #else
+     curl_easy_setopt( m_curlHandle, CURLOPT_IOCTLFUNCTION, lcl_ioctlStream );
+@@ -513,7 +535,7 @@ libcmis::HttpResponsePtr HttpSession::httpPostRequest( 
const string& url, istrea
+     curl_easy_setopt( m_curlHandle, CURLOPT_READFUNCTION, lcl_readStream );
+     curl_easy_setopt( m_curlHandle, CURLOPT_POST, 1 );
+ #if (LIBCURL_VERSION_MAJOR > 7) || (LIBCURL_VERSION_MAJOR == 7 && 
LIBCURL_VERSION_MINOR >= 85)
+-    curl_easy_setopt( m_curlHandle, CURLOPT_SEEKFUNCTION, lcl_ioctlStream );
++    curl_easy_setopt( m_curlHandle, CURLOPT_SEEKFUNCTION, lcl_seekStream );
+     curl_easy_setopt( m_curlHandle, CURLOPT_SEEKDATA, &isOriginal );
+ #else
+     curl_easy_setopt( m_curlHandle, CURLOPT_IOCTLFUNCTION, lcl_ioctlStream );
+-- 
+2.41.0
+
diff --git a/external/libcmis/UnpackedTarball_libcmis.mk 
b/external/libcmis/UnpackedTarball_libcmis.mk
index 1ef846aa2b4b..1a1678e5a67c 100644
--- a/external/libcmis/UnpackedTarball_libcmis.mk
+++ b/external/libcmis/UnpackedTarball_libcmis.mk
@@ -16,6 +16,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libcmis,1))
 $(eval $(call gb_UnpackedTarball_add_patches,libcmis,\
        external/libcmis/0001-fix-regression-in-HttpSession-initProtocols.patch 
\
        
external/libcmis/0002-HttpSession-add-a-callback-that-can-be-used-to-confi.patch
 \
+       
external/libcmis/0003-HttpSession-fix-regression-setting-wrong-type-of-CUR.patch
 \
 ))
 
 # vim: set noet sw=4 ts=4:

Reply via email to