Compare commits

...
Sign in to create a new pull request.

5 commits

Author SHA1 Message Date
Troy Dawson
fa620b0f54 Backport double free fix to epel7 (#2054306) 2023-02-09 12:14:12 -08:00
Sandro Mani
f0a1a20e50 Update shapelib_backports.patch 2014-04-06 00:19:19 +02:00
Sandro Mani
70fd35bce4 Backport some fixes from the gdal bundled shapelib 2014-04-06 00:03:22 +02:00
Sandro Mani
24b7b4b367 Fix changelog date 2014-02-03 14:03:33 +01:00
Sandro Mani
0fbc3d42e1 Initial package for epel 2014-02-03 13:56:58 +01:00
2 changed files with 212 additions and 116 deletions

View file

@ -1,9 +1,6 @@
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: 2%{?dist}
Version: 1.3.0
Release: 3%{?dist}
Summary: C library for handling ESRI Shapefiles
# The core library is dual-licensed LGPLv2 or MIT.
# Some contributed files have different licenses:
@ -21,6 +18,8 @@ Source: http://download.osgeo.org/shapelib/%{name}-1.3.0.tar.gz
#
# 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
BuildRequires: proj-devel >= 4.4.1
@ -48,6 +47,7 @@ This package contains various utility programs distributed with shapelib.
%prep
%setup -q -n %{name}-1.3.0
%patch0 -p1
%patch1 -p1
%build
NOCONFIGURE=1 sh ./autogen.sh
@ -78,116 +78,11 @@ find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
%{_bindir}/*
%changelog
* Thu Aug 08 2013 Sandro Mani <manisandro@gmail.com> - 1.3.0f-2
- Add missing licenses
* Mon Feb 06 2023 Chris Muzyn <chris.muzyn@gmail.com> - 1.3.0-3
- Backport double free fix to epel7
* Mon Aug 05 2013 Sandro Mani <manisandro@gmail.com> - 1.3.0f-1
- Update to 1.3.0 final
* Sun Apr 06 2014 Sandro Mani <manisandro@gmail.com> - 1.3.0-2
- Backport some fixes from the gdal bundled shapelib
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.0b2-10.1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.0b2-9.1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.0b2-8.1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
* Thu Apr 21 2011 Karsten Hopp <karsten@redhat.com> 1.3.0b2-7.1
- remove endian definition from Makefile, leave it to endian.h
* Wed Feb 09 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.0b2-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
* Wed May 19 2010 Lucian Langa <cooly@gnome.eu.org> - 1.3.0b2-6
- update to latest upstream beta
* Tue Mar 09 2010 Lucian Langa <cooly@gnome.eu.org> - 1.3.0b1-5
- update to latest upstream version
* Fri Feb 19 2010 Lucian Langa <cooly@gnome.eu.org> - 1.2.10-2.20100216cvs
- update patch0-3 fix undefined symbols
* Tue Feb 16 2010 Lucian Langa <cooly@gnome.eu.org> - 1.2.10-1.20100216cvs
- revert to latest cvs snapshot
* Thu Feb 04 2010 Lucian Langa <cooly@gnome.eu.org> - 1.3.0b1-4
- misc cleanups
* Thu Feb 04 2010 Lucian Langa <cooly@gnome.eu.org> - 1.3.0b1-3
- do not package static libfiles (#556094)
* Thu Jan 07 2010 Lucian Langa <cooly@gnome.eu.org> - 1.3.0b1-2
- fix patch2 - no not depend on gdal
* Thu Jan 07 2010 Lucian Langa <cooly@gnome.eu.org> - 1.3.0b1-1
- misc cleanups
- update BR
- fix source0
- update to latest upstream snapshot
* Sun Jul 26 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2.10-20.20060304cvs
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
* Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.2.10-19.20060304cvs
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
* Thu Sep 4 2008 Tom "spot" Callaway <tcallawa@redhat.com> - 1.2.10-18.20060304cvs
- fix patch application
* Thu Sep 4 2008 Tom "spot" Callaway <tcallawa@redhat.com> - 1.2.10-17.20060304cvs
- fix license tag
* Tue Feb 19 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 1.2.10-16.20060304cvs
- Autorebuild for GCC 4.3
* Sun Oct 21 2007 Shawn McCann <mccann0011@hotmail.com> - 1.2.10-15.20060304cvs
- Fix for bug 339931
* Sat Sep 16 2006 Shawn McCann <mccann0011@hotmail.com> - 1.2.10-12.20060304cvs
- Rebuild for FC6
* Sun Mar 5 2006 Shawn McCann <mccann0011@hotmail.com> - 1.2.10-11.20060304cvs
- Fixed a makefile bug that messed up parallel builds
* Sat Mar 4 2006 Shawn McCann <mccann0011@hotmail.com> - 1.2.10-10.20060304cvs
- Upgraded to cvs snapshot taken on March 4, 2006
* Sat Mar 4 2006 Shawn McCann <mccann0011@hotmail.com> - 1.2.10-9
- Rebuild for Fedora Extras 5
* Mon Apr 11 2005 Michael Schwendt <mschwendt[AT]users.sf.net> - 1.2.10-8
- Fix "invalid lvalue in assignment" for GCC4.
* Fri Apr 8 2005 Michael Schwendt <mschwendt[AT]users.sf.net>
- rebuilt
* Sun Feb 13 2005 David Woodhouse <dwmw2@infradead.org> 0:1.2.10-6
- Don't hard-code endianness; just use endian.h
* Wed Dec 15 2004 David M. Kaplan <dmk@erizo.ucdavis.edu> 0:1.2.10-5
- Patched patch and spec file according to suggestions of Michael Schwendt
- In particular, this separates the building from the installing in the rpm.
* Thu Aug 12 2004 David M. Kaplan <dmk@erizo.ucdavis.edu> 0:1.2.10-0.fdr.4
- Moved RPM_OPT_FLAGS out of make files.
- Removed backup files from patch.
- Made sure that make was using the appropriate libdir.
* Mon Dec 22 2003 David M. Kaplan <dmk@erizo.ucdavis.edu> 0:1.2.10-0.fdr.3
- Added url tag, changed copyright to license and changed permissions on patch file.
* Mon Dec 22 2003 David M. Kaplan <dmk@erizo.ucdavis.edu> 0:1.2.10-0.fdr.2
- Add source URL
- Removed proj requirement as it is automatically detected.
- Added epoch to proj-devel requirement
- Fixed post and postun
- Changed group to Development/Libraries, although this appears to be only
somewhat satisfactory.
- Removed "which make"
* Wed Nov 5 2003 David M. Kaplan <dmk@erizo.ucdavis.edu> 0:1.2.10-0.fdr.1
- Updated to 1.2.10 release
- Major changes to spec for Fedora
- Changes to Makefile patch for Fedora
- Split off devel package
* Mon Feb 03 2014 Sandro Mani <manisandro@gmail.com> - 1.3.0-1
- Initial package for epel7

201
shapelib_backports.patch Normal file
View file

@ -0,0 +1,201 @@
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;
}
diff --git a/contrib/shpsort.c b/contrib/shpsort.c
index ae0bf6f..305648b 100644
--- a/contrib/shpsort.c
+++ b/contrib/shpsort.c
@@ -279,7 +279,6 @@ static char ** split(const char *arg, const char *delim)
free(result[--i]);
}
free(result);
- free(copy);
return NULL;
}
result = tmp;
--
2.31.1