Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-54558

We are using File.mkdirs() method without checking its return value

    Details

      Description

      We are using File.mkdirs() method without checking its return value, so mkdir can fail and we don't throw any exception or process the error condition

      I have detected this problem at com.liferay.portal.util.FileImpl at some Staging operations, but this issue can be found at other portal objects:

      com.liferay.portal.aspectj.WeavingClassLoader
      com.liferay.portal.deploy.DeployUtil
      com.liferay.portal.image.FileSystemHook
      com.liferay.portal.image.SpriteProcessorImpl
      com.liferay.portal.jcr.jackrabbit.JCRFactoryImpl
      com.liferay.portal.scripting.ruby.RubyExecutor
      com.liferay.portal.servlet.filters.aggregate.AggregateFilter
      com.liferay.portal.servlet.filters.dynamiccss.DynamicCSSFilter
      com.liferay.portal.servlet.filters.dynamiccss.DynamicCSSUtil
      com.liferay.portal.util.FileImpl
      com.liferay.portlet.documentlibrary.store.AdvancedFileSystemStore
      com.liferay.portlet.documentlibrary.store.FileSystemStore
      com.liferay.portlet.documentlibrary.store.S3Store
      

      As a solution, we should change the invocation of mkdir with FileUtils.forceMkdir this method throws a IOException in case of error at directory creation operation.

      https://commons.apache.org/proper/commons-io/javadocs/api-2.1/org/apache/commons/io/FileUtils.html#forceMkdir%28java.io.File%29

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  4 years, 29 weeks, 4 days ago

                  Packages

                  Version Package
                  6.2.4 CE GA5
                  6.2.X EE
                  7.0.0 M5