logo separator

[mkgmap-dev] Corrupt img directory on large image files

From Steffen Neumann sn at litotes.de on Sun Oct 24 13:32:51 BST 2010

Hello,

building my own maps with mkgmap I found a strange behavior, probably a bug.

Phenomenon:
I built an full-blown img from a single 46Mb source, let's say 
63240090.osm.gz. No errors in mkgmap so far. Got the 63240090.img and 
the gmapsupp.img. The gmapsupp.img is empty - no maps in it. The 
63240090.img seems fine but is invalid.
I know that I could increase the block size to get rid of the large 
source but this is not the point.

Analysis:
The img starts with 0x400 bytes header. Then, due to the size of the 
source 2 header directory blocks follow. The normal directory blocks 
start subsequently at 0x800 with 63240090RGN. Unfortunately this first
block at 0x800 contains size 0 and starts with sequence number 0x01. So 
I assume that the missing first block has been overwritten by the 2nd 
header block.

Suggested code changes:
In package uk.me.parabola.imgfmt.sys
in file directory.java
in function void sync()
replace: int forHeader = (blocks + (blockSize - 1)) / blockSize;
by: int forHeader = (blocks + DirectoryEntry.SLOTS_PER_ENTRY - 
1)/DirectoryEntry.SLOTS_PER_ENTRY;
The calculation of forHeader is obviously wrong what in turn causes the 
position needed for other blocks to be wrong too.
2 lines later there's an assert to ensure a forHeader of 1. This could 
be removed. The rest of the code seems to be aware of multiple header 
blocks.

If someone tells me a place were I could store the sample source I will 
do so.

I've no experience in respect of the code change procedures, so could 
one of you guys check-in the changes?

By the way - I wonder why nobody else remarked this before.

cheers,
Steffen




More information about the mkgmap-dev mailing list