Hi,

Just by chance, I happened to spot some buggy code in FileDocumentProvider:

https://github.com/eclipse-platform/eclipse.platform.ui/blob/master/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java#L389

   int n= 0;
   do {
        int bytes= contentStream.read(new
   byte[IContentDescription.BOM_UTF_8.length]);
        if (bytes == -1)
            throw new IOException();
        n += bytes;
   } while (n < IContentDescription.BOM_UTF_8.length);

The array length should be IContentDescription.BOM_UTF_8.length_- n_ - otherwise this could read more bytes than intended.

It's probably never happened in practice, because nobody uses UTF-8 BOM and because in practice filestream.read doesn't return less bytes than requested except at the end of the file.

Note: Although Github issues seem to be the proper way to report issues in this component, Github has decided I shouldn't be allowed to raise Github issues without linking my phone number.
_______________________________________________
platform-dev mailing list
platform-dev@eclipse.org
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/platform-dev

Reply via email to