1844{
1847 char szErrorMsg[160];
1850
1851
1852
1853
1854 if( hEntity < 0 || hEntity >= psSHP->nRecords )
1856
1857
1858
1859
1860 if( psSHP->panRecOffset[hEntity] == 0 && psSHP->fpSHX !=
SHPLIB_NULLPTR )
1861 {
1862 unsigned int nOffset, nLength;
1863
1864 if( psSHP->sHooks.FSeek( psSHP->fpSHX, 100 + 8 * hEntity, 0 ) != 0 ||
1865 psSHP->sHooks.FRead( &nOffset, 1, 4, psSHP->fpSHX ) != 4 ||
1866 psSHP->sHooks.FRead( &nLength, 1, 4, psSHP->fpSHX ) != 4 )
1867 {
1869 snprintf(
str,
sizeof(
str),
1870 "Error in fseek()/fread() reading object from .shx file at offset %d",
1871 100 + 8 * hEntity);
1872 str[
sizeof(
str)-1] =
'\0';
1873
1874 psSHP->sHooks.Error(
str );
1876 }
1879
1880 if( nOffset >
STATIC_CAST(
unsigned int, INT_MAX) )
1881 {
1883 snprintf(
str,
sizeof(
str),
1884 "Invalid offset for entity %d", hEntity);
1885 str[
sizeof(
str)-1] =
'\0';
1886
1887 psSHP->sHooks.Error(
str );
1889 }
1890 if( nLength >
STATIC_CAST(
unsigned int, INT_MAX / 2 - 4) )
1891 {
1893 snprintf(
str,
sizeof(
str),
1894 "Invalid length for entity %d", hEntity);
1895 str[
sizeof(
str)-1] =
'\0';
1896
1897 psSHP->sHooks.Error(
str );
1899 }
1900
1901 psSHP->panRecOffset[hEntity] = nOffset*2;
1902 psSHP->panRecSize[hEntity] = nLength*2;
1903 }
static void SwapWord(int length, void *wordP)
#define STATIC_CAST(type, x)