Possible buffer overflow in FileIOSystem

Issue #75 new
NoTuxNoBux created an issue

If I use FileIOSystem as IOSystem, I get various errors, such as glTF files failing with GLTF: Unable to read JSON.

Inspecting the source code for it, I notice that FileIOStream.Read seems to have two issues:

  • The second argument is set to m_fileStream.Position, which results in a buffer overflow, because this is not the position in the stream the read should start, but the offset into the buffer where the data is written.
  • This Read function of the stream does not return the actual amount of bytes read, but instead returns the passed count again (the former can be less than the latter).

Replacing the last two lines with the following should do the trick, I think (and fixes the reading for me):

return Stream.Read(dataRead, 0, (int)count);

Comments (2)

  1. Log in to comment