[Libreoffice-commits] core.git: connectivity/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Fri Sep 10 17:58:44 UTC 2021
connectivity/source/drivers/firebird/Connection.cxx | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
New commits:
commit 51269c4d28c04ebd2c0047772b7373e0bebec219
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Fri Sep 10 18:15:48 2021 +0200
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Fri Sep 10 19:58:07 2021 +0200
tdf#115547: Fix DB path handling
1. The code used wrong procedure to convert file URLs to local paths.
It assumed that it's enough to just strip the leading 'file://', which
is only sometimes true on Unix-like systems; on Windows, this converts
a valid 'file:///C:/path/file.ext' to '/C:/path/file.ext', where the
leading slash is then treated as a network path, resulting in errors.
2. It is incorrect to assume the same length for UTF-16 and UTF-8
encoded URLs coming from untrusted source (like user file). It may
contain non-ASCII characters (be an IRL), and then the assumption
would fail.
Change-Id: Ie2ea6c8cb9a690975db956fa025bf926a8010984
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121885
Reviewed-by: Lionel Mamane <lionel at mamane.lu>
Tested-by: Jenkins
diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx
index 6c150fe2fb8f..eb0c100b0fc1 100644
--- a/connectivity/source/drivers/firebird/Connection.cxx
+++ b/connectivity/source/drivers/firebird/Connection.cxx
@@ -49,6 +49,7 @@
#include <unotools/tempfile.hxx>
#include <unotools/localfilehelper.hxx>
+#include <osl/file.hxx>
#include <rtl/strbuf.hxx>
#include <sal/log.hxx>
@@ -205,7 +206,7 @@ void Connection::construct(const OUString& url, const Sequence< PropertyValue >&
if (!xFileAccess->exists(m_sFirebirdURL))
bIsNewDatabase = true;
- m_sFirebirdURL = m_sFirebirdURL.copy(OUString("file://").getLength());
+ osl::FileBase::getSystemPathFromFileURL(m_sFirebirdURL, m_sFirebirdURL);
}
}
@@ -274,11 +275,12 @@ void Connection::construct(const OUString& url, const Sequence< PropertyValue >&
ISC_STATUS_ARRAY status; /* status vector */
ISC_STATUS aErr;
+ const OString sFirebirdURL = OUStringToOString(m_sFirebirdURL, RTL_TEXTENCODING_UTF8);
if (bIsNewDatabase)
{
aErr = isc_create_database(status,
- m_sFirebirdURL.getLength(),
- OUStringToOString(m_sFirebirdURL,RTL_TEXTENCODING_UTF8).getStr(),
+ sFirebirdURL.getLength(),
+ sFirebirdURL.getStr(),
&m_aDBHandle,
dpbBuffer.size(),
dpbBuffer.c_str(),
@@ -296,8 +298,8 @@ void Connection::construct(const OUString& url, const Sequence< PropertyValue >&
}
aErr = isc_attach_database(status,
- m_sFirebirdURL.getLength(),
- OUStringToOString(m_sFirebirdURL, RTL_TEXTENCODING_UTF8).getStr(),
+ sFirebirdURL.getLength(),
+ sFirebirdURL.getStr(),
&m_aDBHandle,
dpbBuffer.size(),
dpbBuffer.c_str());
More information about the Libreoffice-commits
mailing list