1833{
1836 char szErrorMsg[160];
1839
1840
1841
1842
1843 if( hEntity < 0 || hEntity >= psSHP->nRecords )
1845
1846
1847
1848
1849 if( psSHP->panRecOffset[hEntity] == 0 && psSHP->fpSHX !=
SHPLIB_NULLPTR )
1850 {
1851 unsigned int nOffset, nLength;
1852
1853 if( psSHP->sHooks.FSeek( psSHP->fpSHX, 100 + 8 * hEntity, 0 ) != 0 ||
1854 psSHP->sHooks.FRead( &nOffset, 1, 4, psSHP->fpSHX ) != 4 ||
1855 psSHP->sHooks.FRead( &nLength, 1, 4, psSHP->fpSHX ) != 4 )
1856 {
1858 snprintf(
str,
sizeof(
str),
1859 "Error in fseek()/fread() reading object from .shx file at offset %d",
1860 100 + 8 * hEntity);
1861 str[
sizeof(
str)-1] =
'\0';
1862
1863 psSHP->sHooks.Error(
str );
1865 }
1868
1869 if( nOffset >
STATIC_CAST(
unsigned int, INT_MAX) )
1870 {
1872 snprintf(
str,
sizeof(
str),
1873 "Invalid offset for entity %d", hEntity);
1874 str[
sizeof(
str)-1] =
'\0';
1875
1876 psSHP->sHooks.Error(
str );
1878 }
1879 if( nLength >
STATIC_CAST(
unsigned int, INT_MAX / 2 - 4) )
1880 {
1882 snprintf(
str,
sizeof(
str),
1883 "Invalid length for entity %d", hEntity);
1884 str[
sizeof(
str)-1] =
'\0';
1885
1886 psSHP->sHooks.Error(
str );
1888 }
1889
1890 psSHP->panRecOffset[hEntity] = nOffset*2;
1891 psSHP->panRecSize[hEntity] = nLength*2;
1892 }
static void SwapWord(int length, void *wordP)
#define STATIC_CAST(type, x)