Changeset 15081

Show
Ignore:
Timestamp:
07/30/08 15:23:58 (4 months ago)
Author:
dmorissette
Message:

Update from AVCE00 master for ticket #1989: Avoid scanning the whole E00
input file in AVCE00ReadOpenE00() if the file does not start with an EXP line

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/ogr/ogrsf_frmts/avc/HISTORY.TXT

    r15077 r15081  
    1818- Detect compressed E00 input files and refuse to open them instead of 
    1919  crashing (bug 1928, GDAL/OGR ticket 2513) 
     20 
     21- Avoid scanning the whole E00 input file in AVCE00ReadOpenE00() if the file 
     22  does not start with an EXP line (GDAL/OGR ticket 1989) 
    2023 
    2124 
     
    297300 
    298301--------- 
    299 $Id: HISTORY.TXT,v 1.31 2008/07/30 16:17:46 dmorissette Exp $ 
     302$Id: HISTORY.TXT,v 1.32 2008/07/30 18:35:53 dmorissette Exp $ 
  • trunk/gdal/ogr/ogrsf_frmts/avc/avc_e00read.c

    r15077 r15081  
    11/********************************************************************** 
    2  * $Id: avc_e00read.c,v 1.26 2008/07/30 16:17:46 dmorissette Exp $ 
     2 * $Id: avc_e00read.c,v 1.28 2008/07/30 19:22:18 dmorissette Exp $ 
    33 * 
    44 * Name:     avc_e00read.c 
     
    3333 * 
    3434 * $Log: avc_e00read.c,v $ 
     35 * Revision 1.28  2008/07/30 19:22:18  dmorissette 
     36 * Move detection of EXP header directly in AVCE00ReadOpenE00() and use 
     37 * VSIFGets() instead of CPLReadLine() to avoid problem with huge one line 
     38 * files (GDAL/OGR ticket #1989) 
     39 * 
     40 * Revision 1.27  2008/07/30 18:35:53  dmorissette 
     41 * Avoid scanning the whole E00 input file in AVCE00ReadOpenE00() if the 
     42 * file does not start with an EXP line (GDAL/OGR ticket 1989) 
     43 * 
    3544 * Revision 1.26  2008/07/30 16:17:46  dmorissette 
    3645 * Detect compressed E00 input files and refuse to open them instead of 
     
    400409    FILE             *fp; 
    401410    char             *p; 
     411    char             szHeader[10]; 
    402412 
    403413    CPLErrorReset(); 
     
    417427    } 
    418428 
    419     if (NULL == (fp = fopen(pszE00FileName, "r"))) 
     429    if (NULL == (fp = VSIFOpen(pszE00FileName, "r"))) 
    420430        return NULL; 
     431 
     432    /*----------------------------------------------------------------- 
     433     * Make sure the file starts with a "EXP  0" or "EXP  1" header 
     434     *----------------------------------------------------------------*/ 
     435    if (VSIFGets(szHeader, 5, fp) == NULL || !EQUALN("EXP ", szHeader, 4) ) 
     436    { 
     437        CPLError(CE_Failure, CPLE_OpenFailed,  
     438                 "This does not look like a E00 file: does not start with " 
     439                 "a EXP header." ); 
     440        VSIFClose(fp); 
     441        return NULL; 
     442    } 
     443    VSIRewind(fp); 
    421444 
    422445    /*----------------------------------------------------------------- 
     
    543566    if (psRead->hFile) 
    544567    { 
    545         fclose(psRead->hFile); 
     568        VSIFClose(psRead->hFile); 
    546569        psRead->hFile = 0; 
    547570    } 
     
    13411364        if (bFirstLine) 
    13421365        { 
    1343             /* Look for the first non-empty line, trying to detect compressed 
    1344              * E00 files. If the file is compressed, the first line of data 
    1345              * should be 79 or 80 characters long and contain several '~'  
    1346              * characters. 
     1366            /* Look for the first non-empty line, after the EXP header, 
     1367             * trying to detect compressed E00 files. If the file is  
     1368             * compressed, the first line of data should be 79 or 80 chars 
     1369             * long and contain several '~' characters. 
    13471370             */ 
    13481371            int nLen = strlen(pszLine);