owncloud / owncloud/android

[BUG] Crash when mimetype is empty

Open
#2,984 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Crash Needs info Type:bug
Dominant language
Kotlin
Stars
4.2k
Forks
3.1k
Avg merge
1d 12h
Merged PRs (30d)
7

Description

When the server returns an empty mimetype on a PROPFIND, the app will crash because it tries to figure out weather the current resource element is a direcotry or not by comparing the returned mimetype against the string DIR. However since the returned mimetype is null the app crashes:

java.lang.String.equalsIgnoreCase(java.lang.String)' on a null object reference
        at com.owncloud.android.utils.FileStorageUtils.createOCFileFromRemoteFile(FileStorageUtils.java:108)
        at com.owncloud.android.operations.SynchronizeFolderOperation.mergeRemoteFolder(SynchronizeFolderOperation.java:337)
        at com.owncloud.android.operations.SynchronizeFolderOperation.run(SynchronizeFolderOperation.java:225)
        at com.owncloud.android.lib.common.operations.RemoteOperation.runOperation(RemoteOperation.java:240)
        at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:205)
        at com.owncloud.android.operations.common.SyncOperation.execute(SyncOperation.java:87)
        at com.owncloud.android.operations.RefreshFolderOperation.run(RefreshFolderOperation.java:143)
        at com.owncloud.android.lib.common.operations.RemoteOperation.runOperation(RemoteOperation.java:240)
        at com.owncloud.android.lib.common.operations.RemoteOperation.run(RemoteOperation.java:259)

This does normally not happen as the server should always send a mimetype, however if he does not we aparently must be prepared.

Steps to reproduce:

  1. Use mitm proxy and intercept response
  2. Pull down to refresh inside files view
  3. When response of propfind is send remove content inside the <contenttype></contenttype> tag

This may sometimes happen when a user creates a file without file ending, or if a file without file ending is shared.

fix: https://github.com/owncloud/android/pull/2986

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at FileStorageUtils.createOCFileFromRemoteFile in FileStorageUtils.java around line 108, then trace the call from SynchronizeFolderOperation.mergeRemoteFolder. Reproduce the empty case with the mitm proxy steps and review PR 2986; done means a PROPFIND with an empty mimetype no longer crashes during refresh.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.