Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-5160

NIOFSDirectory, SimpleFSDirectory (others?) don't properly handle valid file and FileChannel read conditions

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.4, 6.0
    • Fix Version/s: 4.5, 6.0
    • Component/s: None
    • Labels:
      None

      Description

      Around line 190 of NIOFSDirectory, the loop to read in bytes doesn't properly handle the -1 condition that can be returned from FileChannel.read(). If it returns -1, then it will move the file pointer back and you will enter an infinite loop. SimpleFSDirectory displays the same characteristics, although I have only seen the issue on NIOFSDirectory.

      The code in question from NIOFSDirectory:

      try {
              while (readLength > 0) {
                final int limit;
                if (readLength > chunkSize) {
                  // LUCENE-1566 - work around JVM Bug by breaking
                  // very large reads into chunks
                  limit = readOffset + chunkSize;
                } else {
                  limit = readOffset + readLength;
                }
                bb.limit(limit);
                int i = channel.read(bb, pos);
                pos += i;
                readOffset += i;
                readLength -= i;
              }
      

        Attachments

        Issue Links

          Activity

            People

            • Assignee:
              gsingers Grant Ingersoll
              Reporter:
              gsingers Grant Ingersoll

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment