itinance / react-native-fs

Native filesystem access for react-native
MIT License
4.89k stars 954 forks source link

Coverity Issues - Resource leak and URI manipulation #1189

Open vamsigp opened 11 months ago

vamsigp commented 11 months ago

Hello, We use coverity in our project and it shows few issues in the file - RNFSManager.java

  1. Resource Leak - In the method - public void read(String filepath, int length, int position, Promise promise), inputstream is not closed and hence it leaks -
  2. Resource Leak - In the method - public void readFile(String filepath, Promise promise), inputStream variable is not closed and hence it leaks when it goes out of scope
  3. Resource Leak - In the method - public void hash(String filepath, String algorithm, Promise promise), inputStream variable is not closed and hence it leaks when it goes out of scope.
  4. Filesystem path, filename, or URI manipulation (A user-controllable string is used as part or all of a filesystem path, filename, or URI (uniform resource identifier)) - In the method - public void stat(String filepath, Promise promise) - String originalFilepath = getOriginalFilepath(filepath, true); originalFilePath is resultant from RNFSManager.java, where it is result of cursor which may be errorprone.

Request to triage. Thanks