[gdal] 01/01: Add upstream patch to fix crash with SQLite 3.10.0.

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Wed Feb 10 16:17:36 UTC 2016


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch experimental-2.0
in repository gdal.

commit 629f376f4f3572355730726861ccd10cbd9fc645
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 d71fafc..5031a34 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,7 @@ gdal (2.0.2+dfsg-1) UNRELEASED; urgency=medium
   * New upstream release.
   * Drop hardening patch, applied upstream. Refresh remaining patches.
   * Add patches for various typos.
+  * Add upstream patch to fix crash with SQLite 3.10.0.
 
  -- Bas Couwenberg <sebastic at debian.org>  Mon, 01 Feb 2016 17:13:48 +0100
 
diff --git a/debian/patches/series b/debian/patches/series
index 6c50974..69ae111 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -17,3 +17,4 @@ retrieve-typo.patch
 instantiate-typo.patch
 supported-typo.patch
 transform-typo.patch
+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..5aec39b
--- /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/33411
+Bug: https://trac.osgeo.org/gdal/ticket/6360
+
+--- a/ogr/ogrsf_frmts/sqlite/ogrsqlitevfs.cpp
++++ b/ogr/ogrsf_frmts/sqlite/ogrsqlitevfs.cpp
+@@ -380,11 +380,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)
+@@ -407,7 +447,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;
+@@ -424,6 +468,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