[Libreoffice-commits] core.git: Branch 'feature/cib_contract57b' - 2 commits - external/curl scripting/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Nov 6 10:38:42 UTC 2018


 external/curl/CVE-2017-1000254.patch    |   50 +++++++++++++++++++++++
 external/curl/CVE-2018-1000120.patch    |   67 ++++++++++++++++++++++++++++++++
 external/curl/CVE-2018-14618.patch      |   66 +++++++++++++++++++++++++++++++
 external/curl/UnpackedTarball_curl.mk   |    3 +
 scripting/source/pyprov/pythonscript.py |   30 +++++++++++++-
 5 files changed, 214 insertions(+), 2 deletions(-)

New commits:
commit 27235eb29daaaa3601bd24853fcbd7ee1b255591
Author:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
AuthorDate: Mon Sep 10 06:16:58 2018 +0200
Commit:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Tue Nov 6 11:35:03 2018 +0100

    curl: fix CVE-2017-1000254 & CVE-2018-14618/1000120
    
    * still don't upgrade to new release, no idea how the new windows
      build system likes targeting Win XP which is still supported in 5.4
    
    Change-Id: If9c235d2c3e1902f154cae570a9719945112fe33
    (cherry picked from commit 8d86210e1d113f5688015ea197d7b04b173899fb)

diff --git a/external/curl/CVE-2017-1000254.patch b/external/curl/CVE-2017-1000254.patch
new file mode 100644
index 000000000000..2e2af20f7258
--- /dev/null
+++ b/external/curl/CVE-2017-1000254.patch
@@ -0,0 +1,50 @@
+From 29b251362e1839d7094993edbed8f9467069773f Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel at haxx.se>
+Date: Mon, 25 Sep 2017 00:35:22 +0200
+Subject: [PATCH] FTP: zero terminate the entry path even on bad input
+
+... a single double quote could leave the entry path buffer without a zero
+terminating byte. CVE-2017-1000254
+
+Test 1152 added to verify.
+
+Reported-by: Max Dymond
+Bug: https://curl.haxx.se/docs/adv_20171004.html
+---
+ lib/ftp.c               |  7 ++++--
+ tests/data/Makefile.inc |  1 +
+ tests/data/test1152     | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 67 insertions(+), 2 deletions(-)
+ create mode 100644 tests/data/test1152
+
+diff -urN curl.org/lib/ftp.c curl/lib/ftp.c
+--- curl.org/lib/ftp.c	2016-12-19 09:15:11.000000000 +0100
++++ curl/lib/ftp.c	2018-09-10 05:52:32.148633155 +0200
+@@ -2825,6 +2825,7 @@
+         char *ptr=&data->state.buffer[4];  /* start on the first letter */
+         char *dir;
+         char *store;
++        bool entry_extracted = FALSE;
+ 
+         dir = malloc(nread + 1);
+         if(!dir)
+@@ -2856,7 +2857,7 @@
+               }
+               else {
+                 /* end of path */
+-                *store = '\0'; /* zero terminate */
++                entry_extracted = TRUE;
+                 break; /* get out of this loop */
+               }
+             }
+@@ -2865,7 +2866,9 @@
+             store++;
+             ptr++;
+           }
+-
++          *store = '\0'; /* zero terminate */
++        }
++        if(entry_extracted) {
+           /* If the path name does not look like an absolute path (i.e.: it
+              does not start with a '/'), we probably need some server-dependent
+              adjustments. For example, this is the case when connecting to
diff --git a/external/curl/CVE-2018-1000120.patch b/external/curl/CVE-2018-1000120.patch
new file mode 100644
index 000000000000..6da1b1b3dcce
--- /dev/null
+++ b/external/curl/CVE-2018-1000120.patch
@@ -0,0 +1,67 @@
+From a6ae0fbe9c50733e0f645f5bd16e1db38c592c3d Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel at haxx.se>
+Date: Wed, 31 Jan 2018 08:40:11 +0100
+Subject: [PATCH] FTP: reject path components with control codes
+
+Refuse to operate when given path components featuring byte values lower
+than 32.
+
+Previously, inserting a %00 sequence early in the directory part when
+using the 'singlecwd' ftp method could make curl write a zero byte
+outside of the allocated buffer.
+
+Test case 340 verifies.
+
+CVE-2018-1000120
+Reported-by: Duy Phan Thanh
+Bug: https://curl.haxx.se/docs/adv_2018-9cd6.html
+---
+ lib/ftp.c               |  8 ++++----
+ tests/data/Makefile.inc |  3 +++
+ tests/data/test340      | 40 ++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 47 insertions(+), 4 deletions(-)
+ create mode 100644 tests/data/test340
+
+diff --git a/lib/ftp.c b/lib/ftp.c
+index fec591918..e2cc38b62 100644
+--- a/lib/ftp.c
++++ b/lib/ftp.c
+@@ -3192,11 +3192,11 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
+     ftpc->known_filesize = -1;
+   }
+ 
+   if(!result)
+     /* get the "raw" path */
+-    result = Curl_urldecode(data, path_to_use, 0, &path, NULL, FALSE);
++    result = Curl_urldecode(data, path_to_use, 0, &path, NULL, TRUE);
+   if(result) {
+     /* We can limp along anyway (and should try to since we may already be in
+      * the error path) */
+     ftpc->ctl_valid = FALSE; /* mark control connection as bad */
+     connclose(conn, "FTP: out of memory!"); /* mark for connection closure */
+@@ -4153,11 +4153,11 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
+         dirlen++;
+ 
+       result = Curl_urldecode(conn->data, slash_pos ? cur_pos : "/",
+                               slash_pos ? dirlen : 1,
+                               &ftpc->dirs[0], NULL,
+-                              FALSE);
++                              TRUE);
+       if(result) {
+         freedirs(ftpc);
+         return result;
+       }
+       ftpc->dirdepth = 1; /* we consider it to be a single dir */
+@@ -4260,11 +4260,11 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
+     /* prevpath is "raw" so we convert the input path before we compare the
+        strings */
+     size_t dlen;
+     char *path;
+     CURLcode result =
+-      Curl_urldecode(conn->data, data->state.path, 0, &path, &dlen, FALSE);
++      Curl_urldecode(conn->data, data->state.path, 0, &path, &dlen, TRUE);
+     if(result) {
+       freedirs(ftpc);
+       return result;
+     }
+ 
diff --git a/external/curl/CVE-2018-14618.patch b/external/curl/CVE-2018-14618.patch
new file mode 100644
index 000000000000..40f08e7305c1
--- /dev/null
+++ b/external/curl/CVE-2018-14618.patch
@@ -0,0 +1,66 @@
+From 57d299a499155d4b327e341c6024e293b0418243 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel at haxx.se>
+Date: Mon, 13 Aug 2018 10:35:52 +0200
+Subject: [PATCH] Curl_ntlm_core_mk_nt_hash: return error on too long password
+
+... since it would cause an integer overflow if longer than (max size_t
+/ 2).
+
+This is CVE-2018-14618
+
+Bug: https://curl.haxx.se/docs/CVE-2018-14618.html
+Closes #2756
+Reported-by: Zhaoyang Wu
+---
+ lib/curl_ntlm_core.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/lib/curl_ntlm_core.c b/lib/curl_ntlm_core.c
+index e27cab353c..922e85a926 100644
+--- a/lib/curl_ntlm_core.c
++++ b/lib/curl_ntlm_core.c
+@@ -526,6 +526,15 @@
+ 
+ #endif /* USE_NTLM_V2 && !USE_WINDOWS_SSPI */
+ 
++#ifndef SIZE_T_MAX
++/* some limits.h headers have this defined, some don't */
++#if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
++#define SIZE_T_MAX 18446744073709551615U
++#else
++#define SIZE_T_MAX 4294967295U
++#endif
++#endif
++
+ /*
+  * Set up nt hashed passwords
+  * @unittest: 1600
+@@ -557,8 +557,11 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data,
+                                    unsigned char *ntbuffer /* 21 bytes */)
+ {
+   size_t len = strlen(password);
+-  unsigned char *pw = malloc(len * 2);
++  unsigned char *pw;
+   CURLcode result;
++  if(len > SIZE_T_MAX/2) /* avoid integer overflow */
++    return CURLE_OUT_OF_MEMORY;
++  pw = len ? malloc(len * 2) : strdup("");
+   if(!pw)
+     return CURLE_OUT_OF_MEMORY;
+ 
+@@ -621,15 +630,6 @@
+   return CURLE_OK;
+ }
+ 
+-#ifndef SIZE_T_MAX
+-/* some limits.h headers have this defined, some don't */
+-#if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
+-#define SIZE_T_MAX 18446744073709551615U
+-#else
+-#define SIZE_T_MAX 4294967295U
+-#endif
+-#endif
+-
+ /* This creates the NTLMv2 hash by using NTLM hash as the key and Unicode
+  * (uppercase UserName + Domain) as the data
+  */
diff --git a/external/curl/UnpackedTarball_curl.mk b/external/curl/UnpackedTarball_curl.mk
index 1179153959a5..88aecc718fb5 100644
--- a/external/curl/UnpackedTarball_curl.mk
+++ b/external/curl/UnpackedTarball_curl.mk
@@ -27,6 +27,9 @@ $(eval $(call gb_UnpackedTarball_add_patches,curl,\
 	external/curl/CVE-2017-8816.patch \
 	external/curl/CVE-2018-1000005.patch \
 	external/curl/CVE-2018-1000007.patch \
+	external/curl/CVE-2018-14618.patch \
+	external/curl/CVE-2017-1000254.patch \
+	external/curl/CVE-2018-1000120.patch \
 ))
 
 ifeq ($(SYSTEM_NSS),)
commit 2128cbd13f93bd7e2414a4bf63302735b7b1c04a
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Oct 18 20:39:23 2018 +0100
Commit:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Tue Nov 6 11:34:51 2018 +0100

    keep pyuno script processing below base uri
    
    Change-Id: Icc13fb7193fb1e7c50e0df286161a10b4ed636c7
    Reviewed-on: https://gerrit.libreoffice.org/62173
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    Tested-by: Michael Stahl <Michael.Stahl at cib.de>
    (cherry picked from commit 34e9072344067010b82124a3a104b20c73da9f0c)

diff --git a/scripting/source/pyprov/pythonscript.py b/scripting/source/pyprov/pythonscript.py
index a2fc4f055a10..9609b6d94640 100644
--- a/scripting/source/pyprov/pythonscript.py
+++ b/scripting/source/pyprov/pythonscript.py
@@ -24,6 +24,7 @@ import imp
 import time
 import ast
 import platform
+from com.sun.star.uri.RelativeUriExcessParentSegments import RETAIN
 
 try:
     unicode
@@ -211,8 +212,33 @@ class MyUriHelper:
 
     def scriptURI2StorageUri( self, scriptURI ):
         try:
-            myUri = self.m_uriRefFac.parse(scriptURI)
-            ret = self.m_baseUri + "/" + myUri.getName().replace( "|", "/" )
+            # base path to the python script location
+            sBaseUri = self.m_baseUri + "/"
+            xBaseUri = self.m_uriRefFac.parse(sBaseUri)
+
+            # path to the .py file + "$functionname, arguments, etc
+            xStorageUri = self.m_uriRefFac.parse(scriptURI)
+            sStorageUri = xStorageUri.getName().replace( "|", "/" );
+
+            # path to the .py file, relative to the base
+            sFileUri = sStorageUri[0:sStorageUri.find("$")]
+            xFileUri = self.m_uriRefFac.parse(sFileUri)
+            if not xFileUri:
+                message = "pythonscript: invalid relative uri '" + sFileUri+ "'"
+                log.debug( message )
+                raise RuntimeException( message )
+
+            # absolute path to the .py file
+            xAbsScriptUri = self.m_uriRefFac.makeAbsolute(xBaseUri, xFileUri, True, RETAIN)
+            sAbsScriptUri = xAbsScriptUri.getUriReference()
+
+            # ensure py file is under the base path
+            if not sAbsScriptUri.startswith(sBaseUri):
+                message = "pythonscript: storage uri '" + sAbsScriptUri + "' not in base uri '" + self.m_baseUri + "'"
+                log.debug( message )
+                raise RuntimeException( message )
+
+            ret = sBaseUri + sStorageUri
             log.debug( "converting scriptURI="+scriptURI + " to storageURI=" + ret )
             return ret
         except UnoException as e:


More information about the Libreoffice-commits mailing list