Menu

#41 Bug related to reading DGs : markedOffset in CardFileInputStream is not being reset to 0 when resetting the input streaù

v1.0_(example)
closed
nobody
None
1
2019-03-06
2018-12-13
No

Hello

There is a bug related to reading DGs as CardFileInputStream objects.

As determined by the SCUBA API, markSupported()returns true forCardFileInputStream objects. However, when trying to "rewind" the CardFileInputStream, the field markedOffset keeps the value 2 instead of being reset to 0. In the following, I present the steps to reproduce the bug :

// Open DG1 as a CardFileInputStream
CardFileInputStream  is1 = passportService.getInputStream(PassportService.EF_DG1);

// Mark the current positon (0) for reset()
is1.mark(is1.getLength());

// Get DG1File object 
DG1File dg1 = new DG1File(is1);

// Repositions to the position at the time the mark method was last called (0)
is1.reset();

// Try and read the input stream
byte[] buff = new byte[1024];
int bytesRead = 0;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while((bytesRead = is1.read(buff, 0, 1024)) != -1)
{
    baos.write(buff, 0, bytesRead);
}

// buff contains the content of is1 but starting from the position 2 (offset 2)

By debugging the code, we find that markedOffset field in is1 was set to 2 even after the reset, resulting in buff containing the content of DG1 but starting from the offset 2.

Cheers

Discussion

  • Martijn Oostdijk

    Should be fixed in 0.7.10. Re-open if not.

     
  • Martijn Oostdijk

    • status: open --> closed
     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB