Update to 1.4.0-RC1

epel9
Sandro Mani 8 years ago
parent d3b5771581
commit 73b2409c2e

1
.gitignore vendored

@ -1,2 +1,3 @@
shapelib-1.3.0b2.tar.gz
/shapelib-1.3.0.tar.gz
/shapelib-1.4.0RC1.tar.gz

@ -1,9 +1,8 @@
%global pre RC1
Name: shapelib
# Note: the f stands for "final". Since the NVR for 1.3.0b2 was 1.3.0b2-x and not 1.3.0-0.x.b2,
# and since for RPM 1.3.0 < 1.3.0b2, this is the only way to specifiy that 1.3.0 > 1.3.0b2
# without bumping the epoch.
Version: 1.3.0f
Release: 9%{?dist}
Version: 1.4.0
Release: 0.1%{?pre:.%pre}%{?dist}
Summary: C library for handling ESRI Shapefiles
# The core library is dual-licensed LGPLv2 or MIT.
# Some contributed files have different licenses:
@ -12,19 +11,10 @@ Summary: C library for handling ESRI Shapefiles
# - contrib/dbfcat.c: Public domain
License: (LGPLv2+ or MIT) and GPLv2+ and Public Domain
URL: http://shapelib.maptools.org/
Source: http://download.osgeo.org/shapelib/%{name}-1.3.0.tar.gz
# This patch replaces the handmade makefiles with autotools scripts. This patch was generated by
# git clone https://github.com/manisandro/shapelib.git
# cd shapelib
# git checkout autotools
# git diff master..autotools > shapelib_autotools.patch
#
# Upstream is notified about these modifications: http://bugzilla.maptools.org/show_bug.cgi?id=2447
Patch0: shapelib_autotools.patch
# Backports from gdal bundled shapelib
Patch1: shapelib_backports.patch
BuildRequires: autoconf automake libtool
Source: http://download.osgeo.org/shapelib/%{name}-%{version}%{pre}.tar.gz
BuildRequires: gcc
BuildRequires: make
BuildRequires: proj-devel >= 4.4.1
%description
@ -33,6 +23,7 @@ simple C programs for reading, writing and updating (to a
limited extent) ESRI Shapefiles, and the associated
attribute file (.dbf).
%package devel
Summary: Development files for shapelib
Requires: %{name}%{?_isa} = %{version}-%{release}
@ -40,6 +31,7 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
This package contains libshp and the appropriate header files.
%package tools
Summary: shapelib utility programs
Requires: %{name}%{?_isa} = %{version}-%{release}
@ -49,15 +41,12 @@ This package contains various utility programs distributed with shapelib.
%prep
%setup -q -n %{name}-1.3.0
%patch0 -p1
%patch1 -p1
%autosetup
%build
NOCONFIGURE=1 sh ./autogen.sh
%configure --disable-static
make %{?_smp_mflags}
%make_build
%install
@ -75,7 +64,7 @@ find %{buildroot} -name '*.la' -exec rm -f {} ';'
%files
%doc README README.tree ChangeLog web/*.html
%license COPYING
%{_libdir}/libshp.so.*
%{_libdir}/libshp.so.1*
%files devel
%{_includedir}/shapefil.h
@ -88,6 +77,9 @@ find %{buildroot} -name '*.la' -exec rm -f {} ';'
%changelog
* Wed Dec 07 2016 Sandro Mani <manisandro@gmail.com> - 1.4.0-0.1.RC1
- Update to 1.4.0-RC1
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.0f-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

File diff suppressed because it is too large Load Diff

@ -1,185 +0,0 @@
diff --git a/dbfopen.c b/dbfopen.c
index fbe7b06..69d8098 100644
--- a/dbfopen.c
+++ b/dbfopen.c
@@ -687,15 +687,22 @@ DBFCreateLL( const char * pszFilename, const char * pszCodePage, SAHooks *psHook
/* -------------------------------------------------------------------- */
fp = psHooks->FOpen( pszFullname, "wb" );
if( fp == NULL )
+ {
+ free( pszBasename );
+ free( pszFullname );
return( NULL );
+ }
psHooks->FWrite( &chZero, 1, 1, fp );
psHooks->FClose( fp );
fp = psHooks->FOpen( pszFullname, "rb+" );
if( fp == NULL )
+ {
+ free( pszBasename );
+ free( pszFullname );
return( NULL );
-
+ }
sprintf( pszFullname, "%s.cpg", pszBasename );
if( pszCodePage != NULL )
diff --git a/shptree.c b/shptree.c
index 409134e..4fccfab 100644
--- a/shptree.c
+++ b/shptree.c
@@ -93,6 +93,7 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
+#include <limits.h>
#ifdef USE_CPL
#include "cpl_error.h"
@@ -844,22 +845,23 @@ void SHPCloseDiskTree( SHPTreeDiskHandle hDiskTree )
static int
SHPSearchDiskTreeNode( SHPTreeDiskHandle hDiskTree, double *padfBoundsMin, double *padfBoundsMax,
int **ppanResultBuffer, int *pnBufferMax,
- int *pnResultCount, int bNeedSwap )
+ int *pnResultCount, int bNeedSwap, int nRecLevel )
{
- int i;
- int offset;
- int numshapes, numsubnodes;
+ unsigned int i;
+ unsigned int offset;
+ unsigned int numshapes, numsubnodes;
double adfNodeBoundsMin[2], adfNodeBoundsMax[2];
+ int nFReadAcc;
/* -------------------------------------------------------------------- */
/* Read and unswap first part of node info. */
/* -------------------------------------------------------------------- */
- hDiskTree->sHooks.FRead( &offset, 4, 1, hDiskTree->fpQIX );
+ nFReadAcc = (int)hDiskTree->sHooks.FRead( &offset, 4, 1, hDiskTree->fpQIX );
if ( bNeedSwap ) SwapWord ( 4, &offset );
- hDiskTree->sHooks.FRead( adfNodeBoundsMin, sizeof(double), 2, hDiskTree->fpQIX );
- hDiskTree->sHooks.FRead( adfNodeBoundsMax, sizeof(double), 2, hDiskTree->fpQIX );
+ nFReadAcc += (int)hDiskTree->sHooks.FRead( adfNodeBoundsMin, sizeof(double), 2, hDiskTree->fpQIX );
+ nFReadAcc += (int)hDiskTree->sHooks.FRead( adfNodeBoundsMax, sizeof(double), 2, hDiskTree->fpQIX );
if ( bNeedSwap )
{
SwapWord( 8, adfNodeBoundsMin + 0 );
@@ -868,9 +870,30 @@ SHPSearchDiskTreeNode( SHPTreeDiskHandle hDiskTree, double *padfBoundsMin, doubl
SwapWord( 8, adfNodeBoundsMax + 1 );
}
- hDiskTree->sHooks.FRead( &numshapes, 4, 1, hDiskTree->fpQIX );
+ nFReadAcc += (int)hDiskTree->sHooks.FRead( &numshapes, 4, 1, hDiskTree->fpQIX );
if ( bNeedSwap ) SwapWord ( 4, &numshapes );
+ /* Check that we could read all previous values */
+ if( nFReadAcc != 1 + 2 + 2 + 1 )
+ {
+ hDiskTree->sHooks.Error("I/O error");
+ return FALSE;
+ }
+
+ /* Sanity checks to avoid int overflows in later computation */
+ if( offset > INT_MAX - sizeof(int) )
+ {
+ hDiskTree->sHooks.Error("Invalid value for offset");
+ return FALSE;
+ }
+
+ if( numshapes > (INT_MAX - offset - sizeof(int)) / sizeof(int) ||
+ numshapes > INT_MAX / sizeof(int) - *pnResultCount )
+ {
+ hDiskTree->sHooks.Error("Invalid value for numshapes");
+ return FALSE;
+ }
+
/* -------------------------------------------------------------------- */
/* If we don't overlap this node at all, we can just fseek() */
/* pass this node info and all subnodes. */
@@ -890,13 +913,31 @@ SHPSearchDiskTreeNode( SHPTreeDiskHandle hDiskTree, double *padfBoundsMin, doubl
{
if( *pnResultCount + numshapes > *pnBufferMax )
{
- *pnBufferMax = (int) ((*pnResultCount + numshapes + 100) * 1.25);
- *ppanResultBuffer = (int *)
+ int* pNewBuffer;
+
+ *pnBufferMax = (*pnResultCount + numshapes + 100) * 5 / 4;
+
+ if( *pnBufferMax > INT_MAX / sizeof(int) )
+ *pnBufferMax = *pnResultCount + numshapes;
+
+ pNewBuffer = (int *)
SfRealloc( *ppanResultBuffer, *pnBufferMax * sizeof(int) );
+
+ if( pNewBuffer == NULL )
+ {
+ hDiskTree->sHooks.Error("Out of memory error");
+ return FALSE;
+ }
+
+ *ppanResultBuffer = pNewBuffer;
}
- hDiskTree->sHooks.FRead( *ppanResultBuffer + *pnResultCount,
- sizeof(int), numshapes, hDiskTree->fpQIX );
+ if( hDiskTree->sHooks.FRead( *ppanResultBuffer + *pnResultCount,
+ sizeof(int), numshapes, hDiskTree->fpQIX ) != numshapes )
+ {
+ hDiskTree->sHooks.Error("I/O error");
+ return FALSE;
+ }
if (bNeedSwap )
{
@@ -910,14 +951,23 @@ SHPSearchDiskTreeNode( SHPTreeDiskHandle hDiskTree, double *padfBoundsMin, doubl
/* -------------------------------------------------------------------- */
/* Process the subnodes. */
/* -------------------------------------------------------------------- */
- hDiskTree->sHooks.FRead( &numsubnodes, 4, 1, hDiskTree->fpQIX );
+ if( hDiskTree->sHooks.FRead( &numsubnodes, 4, 1, hDiskTree->fpQIX ) != 1 )
+ {
+ hDiskTree->sHooks.Error("I/O error");
+ return FALSE;
+ }
if ( bNeedSwap ) SwapWord ( 4, &numsubnodes );
+ if( numsubnodes > 0 && nRecLevel == 32 )
+ {
+ hDiskTree->sHooks.Error("Shape tree is too deep");
+ return FALSE;
+ }
for(i=0; i<numsubnodes; i++)
{
if( !SHPSearchDiskTreeNode( hDiskTree, padfBoundsMin, padfBoundsMax,
ppanResultBuffer, pnBufferMax,
- pnResultCount, bNeedSwap ) )
+ pnResultCount, bNeedSwap, nRecLevel + 1 ) )
return FALSE;
}
@@ -1014,7 +1064,7 @@ int* SHPSearchDiskTreeEx( SHPTreeDiskHandle hDiskTree,
/* -------------------------------------------------------------------- */
if( !SHPSearchDiskTreeNode( hDiskTree, padfBoundsMin, padfBoundsMax,
&panResultBuffer, &nBufferMax,
- pnShapeCount, bNeedSwap ) )
+ pnShapeCount, bNeedSwap, 0 ) )
{
if( panResultBuffer != NULL )
free( panResultBuffer );
@@ -1025,6 +1075,10 @@ int* SHPSearchDiskTreeEx( SHPTreeDiskHandle hDiskTree,
/* Sort the id array */
/* -------------------------------------------------------------------- */
qsort(panResultBuffer, *pnShapeCount, sizeof(int), compare_ints);
+
+ /* To distinguish between empty intersection from error case */
+ if( panResultBuffer == NULL )
+ panResultBuffer = (int*) calloc(1, sizeof(int));
return panResultBuffer;
}

@ -1 +1 @@
2ff7d0b21d4b7506b452524492795f77 shapelib-1.3.0.tar.gz
f53bba643d15f472ff80bc73ffa4881f shapelib-1.4.0RC1.tar.gz

Loading…
Cancel
Save