summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2023-11-06 18:48:37 +0100
committerMiklos Vajna <vmiklos@collabora.com>2023-11-16 16:49:44 +0100
commit3dcd5b0af324a50d9ea6e9f1b9110408d8c6e882 (patch)
treea7ba53d250b3a8853ecf9d2812e4e324469c7f12
parent0fb2a1051c23222c79e6fe486fa0abb566d0c2d2 (diff)
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.stahl@allotropia.de> (cherry picked from commit 584c01394ff06072b11ef4bd4bffb9e7f2d31e81) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159031 Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de> (cherry picked from commit e8661e19a50e5d1ef987794f230f0b50f64fd37f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159453 Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Tested-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--external/libcmis/0003-HttpSession-fix-regression-setting-wrong-type-of-CUR.patch81
-rw-r--r--external/libcmis/UnpackedTarball_libcmis.mk1
2 files changed, 82 insertions, 0 deletions
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.stahl@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: