Changeset 13655

Show
Ignore:
Timestamp:
02/01/08 14:51:55 (3 months ago)
Author:
rouault
Message:

Fix potential buffer overflow in case of bad PNM file

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/frmts/raw/pnmdataset.cpp

    r13254 r13655  
    156156    const char  *pszSrc = (const char *) poOpenInfo->pabyHeader; 
    157157    char        szToken[512]; 
    158     int         iIn, iOut, iToken = 0, nWidth =-1, nHeight=-1, nMaxValue=-1; 
     158    int         iIn, iToken = 0, nWidth =-1, nHeight=-1, nMaxValue=-1; 
     159    unsigned int iOut; 
    159160 
    160161    iIn = 2; 
     
    163164        iOut = 0; 
    164165        szToken[0] = '\0'; 
    165         while( iIn < poOpenInfo->nHeaderBytes ) 
     166        while( iOut < sizeof(szToken) && iIn < poOpenInfo->nHeaderBytes ) 
    166167        { 
    167168            if( pszSrc[iIn] == '#' )