Back to the main page.

Bug 200 - read_sbin_data does not check whether fseek failed

Status CLOSED FIXED
Reported 2010-11-03 16:40:00 +0100
Modified 2011-02-23 13:51:01 +0100
Product: FieldTrip
Component: fileio
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P1 normal
Assigned to: Joseph Dien
URL:
Tags:
Depends on:
Blocks:
See also:

German Gomez-Herrero - 2010-11-03 16:40:39 +0100

There is a potential bug on lines 91-92 of read_sbin_data. Since the return status of function fseek is not checked, it might happen that fseek failed for whatever reason and still a data chunk will be read in line 94. This can result in a sneaky bug if, for instance, the header of the EGI binary file would be corrupted and say that the length of the file (in samples) is longer than the actual length. In such a case read_sbin_data would keep reading repeatedly the first data chunk in the file (in line 94), when trying to move the file pointer beyond the end of the file. Although you should be able to trust the EGI file header, we have found that in some of our EGI files the headers had wrong information regarding the length of the file (we are still investigating why). That's why, I would recommend checking always the return status of fseek so that an error can be triggered if we are trying to read samples beyond the end of file.


Robert Oostenveld - 2010-12-06 22:08:57 +0100

Dear Joe can you have a look at this bug? thanks, Robert


Joseph Dien - 2011-02-13 21:23:36 +0100

Code changed as suggested. Thanks for the report!


Robert Oostenveld - 2011-02-23 13:51:01 +0100

I closed all bugs that were in the RESOLVED/FIXED or otherwise RESOLVED state.