[gdal] 02/02: Add upstream patch to fix crash with SQLite 3.10.0.
Sebastiaan Couwenberg
sebastic at moszumanska.debian.org
Wed Feb 10 16:17:37 UTC 2016
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to branch master
in repository gdal.
commit a771e571957bd90f2e216cdebbb7249cc0d95a03
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Wed Feb 10 17:05:09 2016 +0100
Add upstream patch to fix crash with SQLite 3.10.0.
---
debian/changelog | 1 +
debian/patches/series | 1 +
debian/patches/sqlite-3.10.0 | 87 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 89 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 4d6c910..c0378ed 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
gdal (1.11.3+dfsg-3) UNRELEASED; urgency=medium
* Update Vcs-Git URL to use HTTPS.
+ * Add upstream patch to fix crash with SQLite 3.10.0.
-- Bas Couwenberg <sebastic at debian.org> Wed, 10 Feb 2016 17:00:34 +0100
diff --git a/debian/patches/series b/debian/patches/series
index fdad713..a329723 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -29,3 +29,4 @@ hardening
recommanded-typo
perl-vendor
libkml-pkgconfig
+sqlite-3.10.0
diff --git a/debian/patches/sqlite-3.10.0 b/debian/patches/sqlite-3.10.0
new file mode 100644
index 0000000..e724133
--- /dev/null
+++ b/debian/patches/sqlite-3.10.0
@@ -0,0 +1,87 @@
+Description: SQLite: fix crash on Unix systems with SQLite >= 3.10.0 when xCurrentTimeInt function is called
+Author: Even Rouault <even.rouault at mines-paris.org>
+Origin: https://trac.osgeo.org/gdal/changeset/33412
+Bug: https://trac.osgeo.org/gdal/ticket/6360
+
+--- a/ogr/ogrsf_frmts/sqlite/ogrsqlitevfs.cpp
++++ b/ogr/ogrsf_frmts/sqlite/ogrsqlitevfs.cpp
+@@ -422,11 +422,51 @@ static int OGRSQLiteVFSSleep (sqlite3_vf
+ return pUnderlyingVFS->xSleep(pUnderlyingVFS, microseconds);
+ }
+
+-static int OGRSQLiteVFSCurrentTime (sqlite3_vfs* pVFS, double* p1)
++// Derived for sqlite3.c implementation of unixCurrentTime64 and winCurrentTime64
++#ifdef WIN32
++#include <windows.h>
++static int OGRSQLiteVFSCurrentTimeInt64 (sqlite3_vfs* /*pVFS*/, sqlite3_int64 *piNow)
+ {
+- sqlite3_vfs* pUnderlyingVFS = GET_UNDERLYING_VFS(pVFS);
+- //CPLDebug("SQLITE", "OGRSQLiteVFSCurrentTime()");
+- return pUnderlyingVFS->xCurrentTime(pUnderlyingVFS, p1);
++ FILETIME ft;
++ static const sqlite3_int64 winFiletimeEpoch = 23058135*(sqlite3_int64)8640000;
++ static const sqlite3_int64 max32BitValue =
++ (sqlite3_int64)2000000000 + (sqlite3_int64)2000000000 +
++ (sqlite3_int64)294967296;
++
++#if defined(_WIN32_WCE)
++ SYSTEMTIME time;
++ GetSystemTime(&time);
++ /* if SystemTimeToFileTime() fails, it returns zero. */
++ if (!SystemTimeToFileTime(&time,&ft)){
++ return SQLITE_ERROR;
++ }
++#else
++ GetSystemTimeAsFileTime( &ft );
++#endif
++ *piNow = winFiletimeEpoch +
++ ((((sqlite3_int64)ft.dwHighDateTime)*max32BitValue) +
++ (sqlite3_int64)ft.dwLowDateTime)/(sqlite3_int64)10000;
++ return SQLITE_OK;
++}
++#else
++#include <sys/time.h>
++static int OGRSQLiteVFSCurrentTimeInt64 (sqlite3_vfs* /*pVFS*/, sqlite3_int64 *piNow)
++{
++ struct timeval sNow;
++ static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000;
++ (void)gettimeofday(&sNow, NULL); /* Cannot fail given valid arguments */
++ *piNow = unixEpoch + 1000*(sqlite3_int64)sNow.tv_sec + sNow.tv_usec/1000;
++
++ return SQLITE_OK;
++}
++#endif
++
++static int OGRSQLiteVFSCurrentTime (sqlite3_vfs* /*pVFS*/, double* p1)
++{
++ sqlite3_int64 i = 0;
++ int rc = OGRSQLiteVFSCurrentTimeInt64(NULL, &i);
++ *p1 = i/86400000.0;
++ return rc;
+ }
+
+ static int OGRSQLiteVFSGetLastError (sqlite3_vfs* pVFS, int p1, char *p2)
+@@ -449,7 +489,11 @@ sqlite3_vfs* OGRSQLiteCreateVFS(pfnNotif
+ pVFSAppData->pfnUserData = pfnUserData;
+ pVFSAppData->nCounter = 0;
+
++#if SQLITE_VERSION_NUMBER >= 3008000L /* perhaps not the minimal version that defines xCurrentTimeInt64, but who cares */
++ pMyVFS->iVersion = 2;
++#else
+ pMyVFS->iVersion = 1;
++#endif
+ pMyVFS->szOsFile = sizeof(OGRSQLiteFileStruct);
+ pMyVFS->mxPathname = pDefaultVFS->mxPathname;
+ pMyVFS->zName = pVFSAppData->szVFSName;
+@@ -466,6 +510,11 @@ sqlite3_vfs* OGRSQLiteCreateVFS(pfnNotif
+ pMyVFS->xSleep = OGRSQLiteVFSSleep;
+ pMyVFS->xCurrentTime = OGRSQLiteVFSCurrentTime;
+ pMyVFS->xGetLastError = OGRSQLiteVFSGetLastError;
++#if SQLITE_VERSION_NUMBER >= 3008000L /* perhaps not the minimal version that defines xCurrentTimeInt64, but who cares */
++ if( pMyVFS->iVersion >= 2 )
++ pMyVFS->xCurrentTimeInt64 = OGRSQLiteVFSCurrentTimeInt64;
++#endif
++
+ return pMyVFS;
+ }
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/gdal.git
More information about the Pkg-grass-devel
mailing list