Opened 3 years ago

Closed 3 years ago

#5268 closed defect (fixed)

RMF DEM (*.mtw) decompression bug

Reported by: yupsi Owned by: warmerdam
Priority: normal Milestone: 1.10.2
Component: GDAL_Raster Version: svn-trunk
Severity: normal Keywords:
Cc:

Description (last modified by yupsi)

/trunk/gdal/frmts/rmf/rmfdem.cpp contains a decompression algorithm for RMF DEM data. Here is a part of the file that deals with 3-byte integer records:

238	            case TYPE_INT24:
239	                if ( nSizeIn < 3 * nCount )
240	                    break;
241	                if ( nSizeOut < nCount )
242	                    break;
243	                nSizeIn -= 3 * nCount;
244	                nSizeOut -= nCount;
245	
246	                while ( nCount-- > 0 )
247	                {
248	                    nCode =*((GInt32 *)pabyTempIn) & 0x0FFF;
249	                    pabyTempIn += 3;
250	                    if ( nCode > RANGE_INT24 )
251	                        nCode |= INV_INT24;
252	                    *paiOut++ = ( nCode == OUT_INT24 ) ?
253	                        OUT_INT32 : iPrev += nCode;
254	                }
255	                break;

I experienced receiving inconsistent data from this function, and then fixed it by replacing 0x0FFF with 0x00FFFFFF at line 248. It makes sense. 0x0FFF might have been copypasted from TYPE_INT12 case and then neglected. Original code author (dron) hasn't responded to my e-mail, so I'm just leaving this here.

Change History (2)

comment:1 Changed 3 years ago by yupsi

Description: modified (diff)

comment:2 Changed 3 years ago by Even Rouault

Component: defaultGDAL_Raster
Milestone: 1.10.2
Resolution: fixed
Status: newclosed

Although I couldn't check with a dataset, your fix makes sense. Fixed in trunk r26529 and branches/1.10 r26530

Note: See TracTickets for help on using tickets.