Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-447

Possible NPE in FileSystemUtils.freeSpaceWindows; FilenameUtils.normalize can return null

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

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • None

    Description

      There is a possible NPE in FileSystemUtils.freeSpaceWindows.
      FilenameUtils.normalize can return null so the path.length() will NPE

      For example, ".." returns null.

      I'm not entirely sure why the path needs to be normalised, apart from converting / to \. Even that seems a bit dubious - why should the user want to return the freespace for a Unix-style path on a Windows system?

      And if it does need to be normalised, why not use the File class, which handles / to \ conversion transparently?

      A short term fix would be to return IAE for paths that normalise to null.
      However that would not allow the use of paths such as ".." - though at least that would not cause NPE.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            sebb Sebb
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment