kaktus621/GPS-Logger — Issue #1: nofs.c: sizo of buffer
Author: quasseln
Created: 2012-02-17 20:44:00+00:00
State: open

Hello,

i think there is an error in nofs.c:

In Line 16 the write-buffer is set to be a array of size NOFS_BUFFER_SIZE = 512.
In the writeString-function the new end of data (ETX) may be written at position 512 which exceeds the size of the buffer by one. This problem only occurs, when the last char of pString is written to the last byte of the buffer, i.e. when fCurrentByte == 511.

Easiest solution: Insert

if (fCurrentByte == NOFS_BUFFER_SIZE) {
nofs_flush();
fCurrentSector++;
fCurrentByte = 0;
}

before :
sectorBuf[fCurrentByte] = ETX;